:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1d1c1a;
  --muted: #6f6b64;
  --line: #e4e1da;
  --accent: #d9480f;
  --accent-text: #ffffff;
  --danger: #c92a2a;
  --placeholder: #e9e6e0;
  --shadow: 0 8px 30px rgb(0 0 0 / 0.12);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413;
    --surface: #1e1d1b;
    --surface-2: #282724;
    --text: #ecebe8;
    --muted: #9b978f;
    --line: #2f2d2a;
    --accent: #ff7a45;
    --accent-text: #1a0d06;
    --danger: #ff6b6b;
    --placeholder: #24231f;
    --shadow: 0 8px 30px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #141413;
  --surface: #1e1d1b;
  --surface-2: #282724;
  --text: #ecebe8;
  --muted: #9b978f;
  --line: #2f2d2a;
  --accent: #ff7a45;
  --accent-text: #1a0d06;
  --danger: #ff6b6b;
  --placeholder: #24231f;
  --shadow: 0 8px 30px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }

h1, h2 { margin: 0; letter-spacing: -0.01em; }
a { color: inherit; }
code, kbd {
  font: 0.85em ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2);
  border-radius: 5px;
  padding: 1px 5px;
}
.muted { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-small { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 16px; }

.icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- logo ---------- */
.logo {
  display: block;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  box-shadow: 0 0 0 1px var(--line);
}
.logo-lg { width: 96px; height: 96px; border-radius: 22px; }

/* ---------- splash ---------- */
.splash {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.splash-card {
  max-width: 420px;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 16px;
}
.splash-card h1 { font-size: 32px; }
.splash-card p { margin: 0 0 8px; color: var(--muted); }

/* ---------- app shell ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; text-decoration: none; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.user { position: relative; }
.avatar-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; overflow: hidden; background: var(--surface-2); cursor: pointer; }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-btn::before { content: attr(data-initial); color: var(--text); font-weight: 600; }
.avatar-btn:has(img:not([hidden]))::before { content: none; }
.menu {
  position: absolute;
  right: 0;
  top: 44px;
  min-width: 240px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.menu-head { display: grid; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 14px; }
.menu-head span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }

.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg));
  font-size: 14px;
}

.body { display: grid; grid-template-columns: 220px minmax(0, 1fr); }

.boards {
  position: sticky;
  top: 64px;
  align-self: start;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 20px 12px;
}
.nav-group { display: grid; gap: 2px; }
.nav-label {
  margin: 20px 12px 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.nav-item {
  display: block;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item[aria-current="page"] { background: var(--text); color: var(--bg); }
.nav-new { margin-top: 6px; width: 100%; color: var(--muted); }

main { padding: 20px 24px 80px; min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 12px; min-height: 40px; margin-bottom: 20px; }
.toolbar h1 { font-size: 26px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-actions { display: flex; gap: 4px; }

/* ---------- grid ---------- */
.grid { display: flex; gap: 16px; align-items: flex-start; }
.col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.pin {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--placeholder);
  cursor: zoom-in;
}
.pin img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.35s, transform 0.35s;
}
.pin.loaded img { opacity: 1; }
.pin:hover img { transform: scale(1.03); }
.pin::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 0);
  transition: background 0.2s;
}
.pin:hover::after { background: rgb(0 0 0 / 0.08); }
.pin.uploading { cursor: progress; }
.pin.uploading img { opacity: 0.45; }
.pin.uploading::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid rgb(255 255 255 / 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.pin.broken { background: repeating-linear-gradient(45deg, var(--placeholder) 0 10px, var(--surface-2) 10px 20px); }

.loading { display: grid; place-items: center; padding: 80px 0; }
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 80px 16px; }
.empty p { margin: 0 0 8px; }
.empty p:first-child { font-size: 18px; font-weight: 600; }
.empty .btn { margin-top: 8px; }

/* ---------- add dialog ---------- */
.dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgb(0 0 0 / 0.4); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.dialog-head h2 { font-size: 18px; }
.dialog-head { gap: 10px; }
.dialog-head .add-board { flex: 1; min-width: 0; margin-right: auto; }
.upload-zone {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 28px 16px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.upload-zone:hover { border-color: var(--accent); background: var(--surface-2); }
.upload-zone input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.url-form { display: flex; gap: 8px; margin-top: 14px; }
.url-form input, .field select {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.hint { margin: 14px 0 0; font-size: 13px; }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  background: var(--bg);
}
.lb-stage {
  position: relative;
  display: grid;
  place-items: center;
  padding: 24px 72px;
  min-height: 0;
  cursor: zoom-out;
}
.lb-stage {
  --lb-max-h: calc(100vh - 48px);
}
/* Always the size the full-resolution image will have: as large as fits the stage, but never larger
   than the original (--full-w) — so the thumbnail shown while loading doesn't jump in size. */
.lb-stage img {
  --ratio: 1;
  --full-w: 100vw;
  width: min(100%, var(--full-w), calc(var(--lb-max-h) * var(--ratio)));
  height: auto;
  aspect-ratio: var(--ratio);
  object-fit: contain;
  border-radius: 10px;
  cursor: default;
}
.lb-nav {
  position: absolute;
  top: 50%;
  width: 48px;
  height: 48px;
  margin-top: -24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.lb-nav:disabled { opacity: 0.3; cursor: default; }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-info {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 56px 24px 24px;
  border-left: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
}
.lb-close { position: absolute; top: 12px; right: 12px; }
.lb-info h2 { font-size: 17px; word-break: break-word; }
.lb-info p { margin: 0; font-size: 14px; }
.lb-source { color: var(--accent); font-weight: 600; font-size: 14px; text-decoration: none; word-break: break-all; }
.lb-source::after { content: " ↗"; }
.field { display: grid; gap: 6px; margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field select { flex: none; width: 100%; color: var(--text); font-weight: 500; }
.lb-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---------- overlays ---------- */
.dropzone {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.dropzone div {
  padding: 24px 40px;
  border: 3px dashed var(--accent);
  border-radius: 20px;
  background: var(--surface);
  font-size: 20px;
  font-weight: 700;
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 70;
  display: grid;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  transform: translateX(-50%);
}
.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: rise 0.2s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .topbar { padding: 0 16px; height: 56px; }
  .body { display: block; }
  .boards {
    position: sticky;
    top: 56px;
    z-index: 5;
    display: flex;
    gap: 6px;
    max-height: none;
    padding: 10px 16px;
    overflow-x: auto;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }
  .nav-group { display: flex; gap: 6px; }
  .nav-label { display: none; }
  .nav-item { flex: none; padding: 6px 14px; border-radius: 999px; background: var(--surface-2); font-size: 14px; }
  .nav-new { width: auto; margin: 0; }
  main { padding: 16px 16px 60px; }
  .toolbar h1 { font-size: 22px; }
  .grid, .col { gap: 10px; }
  .pin { border-radius: 12px; }

  .lightbox { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .lb-stage { padding: 56px 12px 12px; }
  .lb-stage { --lb-max-h: 60vh; }
  .lb-nav { width: 40px; height: 40px; margin-top: -20px; font-size: 24px; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
  .lb-info { padding: 16px; border-left: 0; border-top: 1px solid var(--line); max-height: 40vh; }
  .lb-close { position: fixed; top: 8px; right: 8px; z-index: 2; background: var(--surface); }
}

/* ---------- sharing ---------- */
.toolbar { flex-wrap: wrap; justify-content: space-between; }
.toolbar-title { min-width: 0; }
.toolbar-title p { margin: 2px 0 0; font-size: 14px; }
.toolbar-title p:empty { display: none; }
.board-actions { flex-wrap: wrap; }

.nav-item { display: flex; align-items: center; gap: 8px; }
.nav-item span { overflow: hidden; text-overflow: ellipsis; }
.nav-item svg { flex: none; opacity: 0.6; }

.app:not(.public) .public-only { display: none; }
.app.public .boards,
.app.public .user { display: none; }
.app.public .body { grid-template-columns: minmax(0, 1fr); }

.note { margin: 8px 0 0; font-size: 13px; }
.note.warn { color: var(--danger); }
.splash-card .note { padding: 10px 14px; border-radius: 10px; background: var(--surface-2); color: var(--text); font-size: 14px; }

.dialog-wide { width: min(520px, calc(100vw - 32px)); }
.dialog h3 { margin: 22px 0 10px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.dialog select, .dialog input:not([type="checkbox"]):not([type="file"]) {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  min-width: 0;
}
.invite { display: flex; flex-wrap: wrap; gap: 8px; }
.invite input { flex: 1 1 200px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.people { display: grid; gap: 4px; min-height: 40px; }
.people .spinner { margin: 4px auto; width: 24px; height: 24px; }
.person { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.person-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 14px;
}
.person-avatar img { width: 100%; height: 100%; object-fit: cover; }
.person-who { display: grid; flex: 1; min-width: 0; font-size: 14px; }
.person-who strong, .person-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.person-who span { color: var(--muted); font-size: 13px; }
.dialog select.person-role { flex: none; height: 32px; padding: 0 10px; font-size: 13px; }
span.person-role { font-size: 13px; padding-right: 10px; }

.access-select { width: 100%; }
.share-link { display: flex; gap: 8px; margin-top: 20px; }
.share-link input { flex: 1; color: var(--muted); }

/* ---------- review dialog (details before upload) ---------- */
.dialog-review { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; }
.dialog-review form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.dialog-review .dialog-head { padding: 18px 20px 0; margin-bottom: 4px; }
.review-hint { margin: 0; padding: 0 20px 12px; border-bottom: 1px solid var(--line); }
.review-list { flex: 1; overflow-y: auto; padding: 4px 20px; }
.review-item { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.review-item:last-child { border-bottom: 0; }
.review-item img { width: 88px; height: 88px; object-fit: cover; border-radius: 10px; background: var(--placeholder); }
.review-fields { display: grid; gap: 6px; min-width: 0; }
.dialog .review-fields input:not([type="checkbox"]), .review-fields textarea {
  width: 100%;
  height: auto;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  resize: vertical;
}
.dialog .review-fields .review-title { font-weight: 600; }
.review-file { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
@media (max-width: 560px) {
  .review-item { grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; }
  .review-item img { width: 64px; height: 64px; }
}

/* ---------- image details: title, description, star, comments ---------- */
.lb-head { display: flex; align-items: flex-start; gap: 6px; padding-right: 32px; }
.lb-title, .lb-desc {
  width: 100%;
  margin: 0;
  padding: 4px 8px;
  margin-left: -8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
}
.lb-title { flex: 1; min-width: 0; font-size: 17px; font-weight: 700; line-height: 1.35; resize: none; overflow: hidden; }
.lb-desc { font-size: 14px; line-height: 1.5; resize: none; overflow: hidden; }
.lb-title:not([readonly]):hover, .lb-desc:not([readonly]):hover { border-color: var(--line); }
.lb-title:not([readonly]):focus, .lb-desc:not([readonly]):focus { border-color: var(--accent); background: var(--bg); outline: none; }
.lb-title[readonly], .lb-desc[readonly] { cursor: text; }
.lb-info #lb-status { margin: -6px 0 0; min-height: 0; }
.lb-info #lb-status:empty { display: none; }
.star-btn {
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.star-btn:hover { background: var(--surface-2); color: var(--text); }
.star-btn[aria-pressed="true"] { color: #f5b301; }
.lb-links { display: grid; gap: 4px; }
.lb-links:not(:has(a:not([hidden]))) { display: none; }
.lb-secondary { color: var(--muted); font-weight: 500; }


.lb-comments { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.lb-comments h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.comment-list { display: grid; gap: 14px; font-size: 14px; }
.comment-list > p { margin: 0; }
.comment.resolved { opacity: 0.6; }
.comment.reply { margin: 10px 0 0 18px; padding-left: 12px; border-left: 2px solid var(--line); }
.comment-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.comment-head time { color: var(--muted); font-size: 12px; }
.comment-avatar { width: 24px; height: 24px; font-size: 11px; }
.comment-badge { padding: 1px 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 11px; }
.comment-body { margin: 4px 0 0 32px; white-space: pre-wrap; word-break: break-word; }
.comment.reply .comment-body { margin-left: 32px; }
.comment-form { display: grid; gap: 8px; margin-top: 14px; justify-items: end; }
.comment-form textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  resize: none;
  overflow: hidden;
}
/* The details panel scrolls; its parts keep their natural height instead of shrinking to fit. */
.lb-info > * { flex-shrink: 0; }

/* A board that's still being created in Google Drive */
.nav-pending { color: var(--muted); cursor: progress; justify-content: space-between; }
.nav-pending:hover { background: none; }
.spinner-small { flex: none; width: 14px; height: 14px; border-width: 2px; }
