/* Blat — wygląd w duchu Gapy: jeden cienki pasek, ciche szarości, tryb jasny i ciemny */
:root {
  --r: 8px;
  --bg: #f7f7f5; --text: #1a1a19; --text2: #4a4945; --muted: #8a8984; --muted2: #a3a29d;
  --soft: #efeeea; --hover: #ecebe7; --line: #e6e5e1; --card: #ffffff; --cardline: #ecebe7;
  --ring: #1a1a19; --pill: #ffffff; --pillsh: 0 1px 2px rgba(0, 0, 0, .08);
  --tip: #1a1a19; --tiptext: #f7f7f5;
  --menu: #ffffff; --menush: 0 0 0 1px rgba(0, 0, 0, .06), 0 10px 30px rgba(0, 0, 0, .10);
  --itemsh: 0 0 0 1px rgba(0, 0, 0, .05), 0 1px 3px rgba(0, 0, 0, .05);
  --dot: rgba(0, 0, 0, .10);
  --ph: #e8e7e2;
  --guide: #e5484d;
  --danger: #c4372f;
  --iz: 1; /* odwrotność powiększenia — stała grubość linii */
  color-scheme: light;
}
[data-theme=dark] {
  --bg: #161616; --text: #e9e9e7; --text2: #c4c4c1; --muted: #8d8d89; --muted2: #6f6f6c;
  --soft: #222221; --hover: #242423; --line: #2a2a29; --card: #1d1d1c; --cardline: #2a2a29;
  --ring: #e9e9e7; --pill: #363635; --pillsh: 0 1px 2px rgba(0, 0, 0, .4);
  --tip: #e9e9e7; --tiptext: #161616;
  --menu: #232322; --menush: 0 0 0 1px rgba(255, 255, 255, .07), 0 12px 36px rgba(0, 0, 0, .5);
  --itemsh: 0 0 0 1px rgba(255, 255, 255, .06), 0 2px 6px rgba(0, 0, 0, .3);
  --dot: rgba(255, 255, 255, .09);
  --ph: #232322;
  --guide: #ff6369;
  --danger: #ff6b62;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
svg { display: block; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.wordmark { font-size: 14px; font-weight: 600; letter-spacing: -.01em; text-decoration: none; color: var(--text); }

/* ---------- przyciski (jak w Gapie) */
.ib {
  width: 30px; height: 30px; border-radius: 7px; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.ib:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.ib[aria-pressed=true] { background: var(--soft); color: var(--text); }
.tb {
  height: 30px; padding: 0 9px; border-radius: 7px; color: var(--text2);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: none;
}
.tb:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.tb svg { color: var(--muted); }
.tb:hover svg { color: var(--text); }
.sep { width: 1px; height: 16px; background: var(--line); margin: 0 6px; flex: none; }
.gap { flex: 1 1 0; min-width: 8px; }

.seg { display: flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--soft); flex: none; }
.seg button { height: 26px; padding: 0 10px; border-radius: 6px; color: var(--muted); white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed=true] { background: var(--pill); box-shadow: var(--pillsh); color: var(--text); }

.btn {
  height: 32px; padding: 0 14px; border-radius: 8px; background: var(--soft); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover:not(:disabled) { background: var(--text); opacity: .88; }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-wide { width: 100%; height: 38px; }

.field {
  width: 100%; height: 36px; padding: 0 12px; border: 0; border-radius: 8px; outline: 0;
  background: var(--soft); color: var(--text);
}
.field::placeholder { color: var(--muted); }
.field:focus { box-shadow: 0 0 0 1px var(--line) inset, 0 0 0 1px var(--ring); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); font-size: 12px; min-height: 1.4em; margin: 6px 0 0; }

/* ---------- logowanie */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-box { width: 100%; max-width: 320px; }
.auth-box .wordmark { display: block; font-size: 22px; margin: 0 0 24px; }
.auth-box form { display: grid; gap: 8px; }
.auth-box p { margin: 0 0 10px; color: var(--text2); }
.auth-foot { margin-top: 28px; display: flex; gap: 6px; }
.dev-link { word-break: break-all; font-size: 12px; color: var(--muted); }

/* ---------- lista projektów */
.page-bar { display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 12px 0 20px; }
.page { max-width: 720px; margin: 0 auto; padding: 32px 24px 80px; }
.sec { font-size: 11.5px; color: var(--muted); margin: 0 0 8px; padding: 0 10px; font-weight: 400; }
.plist { list-style: none; margin: 0 0 28px; padding: 0; }
.plist a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 9px 10px; border-radius: 7px; text-decoration: none; color: var(--text2);
}
.plist a:hover { background: var(--hover); color: var(--text); }
.plist .pname { font-size: 14px; color: var(--text); }
.plist .meta { color: var(--muted2); font-size: 12px; white-space: nowrap; }
.new-project { display: flex; gap: 6px; max-width: 420px; padding: 0 10px; }
.empty { color: var(--muted); padding: 10px; }

/* ---------- tablica */
.board-view { position: fixed; inset: 0; overflow: hidden; display: flex; flex-direction: column; }
.topbar {
  flex: none; height: 52px; display: flex; align-items: center; gap: 4px;
  padding: 0 12px; padding-top: env(safe-area-inset-top);
  min-width: 0; position: relative; z-index: 20; background: var(--bg);
}
.crumbs { display: flex; align-items: center; min-width: 0; gap: 2px; font-size: 13px; }
.crumbs a.wordmark { padding: 4px 6px; border-radius: 6px; }
.crumbs a.wordmark:hover { background: var(--hover); }
.crumbs i { font-style: normal; color: var(--muted2); opacity: .6; flex: none; padding: 0 2px; }
.crumbs .pname { padding: 4px 6px; border-radius: 6px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 28vw; }
.crumbs .pname.editable { cursor: text; }
.crumbs .pname.editable:hover { background: var(--hover); }
.boards { margin-left: 8px; max-width: 36vw; overflow-x: auto; scrollbar-width: none; }
.boards::-webkit-scrollbar { display: none; }
.zoomctl { display: flex; align-items: center; gap: 0; }
.zoomctl .pct { min-width: 50px; height: 30px; border-radius: 7px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.zoomctl .pct:hover { background: var(--hover); color: var(--text); }
.people { display: flex; align-items: center; gap: 4px; }
.avatars { display: flex; padding: 0 4px; }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center;
  font-size: 10px; font-weight: 600; letter-spacing: .02em;
  background: var(--soft); color: var(--text2); box-shadow: 0 0 0 2px var(--bg);
}
.avatar.owner { background: var(--text); color: var(--bg); }
.avatars .avatar + .avatar { margin-left: -5px; }

.stagewrap { position: relative; flex: 1; min-height: 0; }
.canvas {
  position: absolute; inset: 0; overflow: hidden;
  touch-action: none; cursor: default; background: var(--bg);
}
.canvas.dots {
  background-image: radial-gradient(circle, var(--dot) 1px, transparent 1.3px);
  background-size: 24px 24px;
}
.canvas.panning, .canvas.space { cursor: grab; }
.canvas.panning { cursor: grabbing; }
.canvas.drop-target::after {
  content: ""; position: absolute; inset: 10px; border: 1.5px dashed var(--muted);
  border-radius: 12px; pointer-events: none;
}
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }

.item { position: absolute; user-select: none; -webkit-user-select: none; touch-action: none; border-radius: var(--r); }
.item.selected { outline: calc(1.5px * var(--iz)) solid var(--ring); outline-offset: calc(4px * var(--iz)); }
.item.uploading { opacity: .5; }

.item-image img {
  width: 100%; height: 100%; display: block; object-fit: cover; border-radius: var(--r);
  pointer-events: none; background: var(--ph); -webkit-user-drag: none;
}
.item-note {
  background: var(--card); box-shadow: var(--itemsh);
  padding: 14px 16px; font-size: 15px; line-height: 1.5; color: var(--text);
  overflow: hidden; white-space: pre-wrap; word-wrap: break-word;
}
.item-note.empty-note::before { content: attr(data-empty); color: var(--muted); }
.item-note textarea {
  position: absolute; inset: 0; width: 100%; height: 100%; border-radius: var(--r);
  border: 0; outline: 0; resize: none; padding: 14px 16px;
  font-size: 15px; line-height: 1.5; background: var(--card); color: var(--text);
  user-select: text; -webkit-user-select: text;
}
.item-link, .item-file {
  background: var(--card); box-shadow: var(--itemsh);
  display: flex; flex-direction: column; overflow: hidden;
}
.item-link .preview { flex: 1 1 auto; min-height: 0; background: var(--ph) center / cover no-repeat; }
.item-link .body, .item-file .body { padding: 10px 12px 12px; flex: 0 0 auto; min-width: 0; }
.item-link .title {
  font-size: 13px; line-height: 1.35; margin: 0 0 3px; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.item-link .site, .item-file .size { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-file { flex-direction: row; align-items: center; }
.item-file .ext {
  flex: none; margin-left: 12px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 6px;
  background: var(--soft); color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .04em;
}
.item-file .name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.handle {
  position: absolute; right: calc(-6px * var(--iz)); bottom: calc(-6px * var(--iz));
  width: calc(12px * var(--iz)); height: calc(12px * var(--iz)); border-radius: 50%;
  background: var(--bg); border: calc(1.5px * var(--iz)) solid var(--ring);
  cursor: nwse-resize; display: none; touch-action: none;
}
.item.selected .handle { display: block; }
@media (pointer: coarse) {
  .handle { width: calc(24px * var(--iz)); height: calc(24px * var(--iz)); right: calc(-12px * var(--iz)); bottom: calc(-12px * var(--iz)); }
}

/* linie przyciągania */
.guides { position: absolute; left: 0; top: 0; pointer-events: none; }
.guide { position: absolute; background: var(--guide); }
.guide.v { width: calc(1px * var(--iz)); }
.guide.h { height: calc(1px * var(--iz)); }

/* pasek nad zaznaczeniem — jak menu w Gapie */
.selbar {
  position: absolute; z-index: 15; transform: translate(-50%, -100%);
  display: flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--menu); box-shadow: var(--menush); border-radius: 9px; white-space: nowrap;
}
.selbar .tb { height: 28px; }
.selbar .tb.danger { color: var(--danger); }
.selbar .who { font-size: 11.5px; color: var(--muted); padding: 0 8px 0 6px; }

.hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  text-align: center; color: var(--muted); pointer-events: none; max-width: 300px; line-height: 1.6;
}

/* mały znacznik powiększenia przy zmianie */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: var(--tip); color: var(--tiptext); border-radius: 8px;
  padding: 8px 12px; display: flex; gap: 14px; align-items: center; font-size: 12.5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.toast button { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* okna */
.modal-back {
  position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .18);
  display: grid; place-items: center; padding: 16px;
}
[data-theme=dark] .modal-back { background: rgba(0, 0, 0, .45); }
.modal {
  background: var(--menu); box-shadow: var(--menush); border-radius: 12px;
  width: 100%; max-width: 400px; padding: 18px; max-height: calc(100vh - 32px); overflow: auto;
}
.modal h2 { font-size: 13px; font-weight: 600; margin: 0 0 14px; }
.modal form { display: grid; gap: 8px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.modal .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mlist { list-style: none; padding: 0; margin: 0 0 16px; }
.mlist li { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-radius: 7px; }
.mlist .info { flex: 1; min-width: 0; }
.mlist .info div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* pełny podgląd obrazu */
.lightbox {
  position: fixed; inset: 0; z-index: 45; background: var(--bg);
  display: grid; place-items: center; padding: 52px 24px 24px;
}
.lightbox img { max-width: 100%; max-height: calc(100vh - 76px); border-radius: var(--r); }
.lightbox .bar { position: absolute; top: 0; left: 0; right: 0; height: 52px; display: flex; align-items: center; gap: 4px; padding: 0 12px 0 16px; }
.lightbox .caption { flex: 1; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* paski przewijania jak w Gapie */
::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(127, 127, 127, .25); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

@media (max-width: 760px) {
  .tb .lbl { display: none; }
  .crumbs .pname { max-width: 30vw; }
  .boards { max-width: 30vw; }
  .zoomctl, .hide-narrow { display: none; }
  .avatars { display: none; }
}

/* narzędzia */
.tools button { width: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.canvas.tool-hand { cursor: grab; }
.canvas.tool-draw { cursor: crosshair; }
.penbar {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 16;
  display: flex; align-items: center; gap: 4px; padding: 4px 6px;
  background: var(--menu); box-shadow: var(--menush); border-radius: 9px;
}
.swatch { width: 24px; height: 24px; border-radius: 6px; display: inline-grid; place-items: center; }
.swatch i { width: 14px; height: 14px; border-radius: 50%; display: block; }
.swatch:hover { background: var(--hover); }
.swatch[aria-pressed=true] { background: var(--soft); box-shadow: 0 0 0 1px var(--line) inset; }
.swatch .w { border-radius: 4px; width: 14px; background: var(--text); }

/* zaznaczanie ramką */
.marquee {
  position: absolute; pointer-events: none;
  border: calc(1px * var(--iz)) solid var(--ring);
  background: color-mix(in srgb, var(--ring) 6%, transparent);
}

/* rysunki: klikalna tylko sama kreska */
.item-drawing { pointer-events: none; border-radius: 0; }
.item-drawing svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.item-drawing path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.item-drawing path.hit { stroke: transparent; pointer-events: stroke; cursor: default; }
.item-drawing .handle { pointer-events: auto; }
.item-drawing.selected { outline-style: dashed; }
.live-stroke { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.live-stroke path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.board-view.multi .handle { display: none !important; }
.actionsbar { display: flex; align-items: center; gap: 2px; }
.crumbs { flex: 0 1 auto; }
.boards { flex: 0 1 auto; min-width: 0; }
@media (max-width: 760px) {
  .crumbs .pname, .crumbs i { display: none; }
  .actionsbar {
    position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
    bottom: max(16px, env(safe-area-inset-bottom));
    background: var(--menu); box-shadow: var(--menush); border-radius: 12px; padding: 4px;
  }
  .actionsbar .tb { height: 34px; padding: 0 10px; }
  .actionsbar .tools button { width: 34px; height: 30px; }
  .penbar { top: auto; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 52px); }
  .toast { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 56px); }
}
