/* GuiltyScroll — cozy minimal. Warm oat ground, moss accent, honey highlight. */

:root {
  --bg: #f3efe9;
  --surface: #fbf8f2;
  --surface-2: #ece6dc;
  --ink: #2e2a24;
  --ink-soft: #6f675c;
  --line: #e0d8cb;
  --accent: #5c7350;
  --accent-ink: #f6f4ee;
  --honey: #c9973f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(46, 42, 36, 0.06), 0 6px 18px rgba(46, 42, 36, 0.07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #211e1a;
    --surface: #2a2621;
    --surface-2: #332e28;
    --ink: #ede7dc;
    --ink-soft: #a89e8f;
    --line: #3b352d;
    --accent: #9db58a;
    --accent-ink: #23281f;
    --honey: #d8a854;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
  }
}

:root[data-theme="light"] {
  --bg: #f3efe9; --surface: #fbf8f2; --surface-2: #ece6dc;
  --ink: #2e2a24; --ink-soft: #6f675c; --line: #e0d8cb;
  --accent: #5c7350; --accent-ink: #f6f4ee; --honey: #c9973f;
  --shadow: 0 1px 2px rgba(46, 42, 36, 0.06), 0 6px 18px rgba(46, 42, 36, 0.07);
}

:root[data-theme="dark"] {
  --bg: #211e1a; --surface: #2a2621; --surface-2: #332e28;
  --ink: #ede7dc; --ink-soft: #a89e8f; --line: #3b352d;
  --accent: #9db58a; --accent-ink: #23281f; --honey: #d8a854;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

/* The hidden attribute must always win — author display:flex/grid on a
   component would otherwise override the browser's [hidden] rule, and every
   panel of chrome would render at once. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.wordmark {
  font-family: "Zilla Slab", Georgia, serif;
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark span { color: var(--accent); }

.tabs { display: flex; gap: 4px; }

.tab {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.tab.is-active { background: var(--surface-2); color: var(--ink); }
.tab:focus-visible, .search:focus-visible, .save-input:focus-visible,
.save-btn:focus-visible, .sheet-close:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.search-row { display: flex; }

.search {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  padding: 12px 18px;
  border-radius: 999px;
}
.search::placeholder { color: var(--ink-soft); }

.save-row { display: flex; gap: 8px; }

.save-input {
  flex: 1;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  padding: 9px 16px;
  border-radius: 999px;
}

.save-btn {
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
}

/* ---------- grid of cards ---------- */

main { padding: 18px 16px 48px; max-width: 1080px; margin: 0 auto; }

.status, .empty {
  color: var(--ink-soft);
  text-align: center;
  padding: 32px 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover { transform: translateY(-2px); }

.card-thumb {
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-thumb .fallback {
  font-family: "Zilla Slab", Georgia, serif;
  font-size: 2rem;
  color: var(--ink-soft);
}

.card-platform {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: color-mix(in srgb, var(--ink) 72%, transparent);
  color: var(--bg);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
}

.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }

.card-title {
  margin: 0;
  font-family: "Zilla Slab", Georgia, serif;
  font-weight: 500;
  font-size: 1.02rem;
  line-height: 1.35;
  text-wrap: balance;
}

.card-meta { color: var(--ink-soft); font-size: 0.8rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  border: 0;
  background: var(--surface-2);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.chip:hover { background: var(--honey); color: var(--accent-ink); }

/* ---------- telegram note (website only) ---------- */

.tg-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
}
.tg-note p { margin: 0; color: var(--ink-soft); font-size: 0.9rem; max-width: 62ch; }
.tg-note a { color: var(--accent); font-weight: 600; text-decoration: none; }
.tg-note a:hover { text-decoration: underline; text-underline-offset: 3px; }

.tg-note-close {
  margin-left: auto;
  flex: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
}
.tg-note-close:hover { color: var(--ink); }
.tg-note-close:focus-visible, .tg-note a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- topic tree ---------- */

.topic-tree {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
}

.topic-tree-toggle {
  cursor: pointer;
  padding: 11px 16px;
  font-size: 0.8rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topic-tree-toggle::-webkit-details-marker { display: none; }
.topic-tree-toggle::before {
  content: "";
  width: 0; height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: rotate 0.18s ease;
}
.topic-tree[open] .topic-tree-toggle::before { rotate: 90deg; }
.topic-tree-toggle:hover { color: var(--ink); }
.topic-tree-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.topic-tree-body {
  padding: 4px 16px 14px;
  max-height: 46vh;
  overflow-y: auto;
}

.topic-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
/* Nested levels get a hairline spine so depth reads without heavy indentation. */
.topic-tree ul ul {
  margin-left: 9px;
  padding-left: 13px;
  border-left: 1px solid var(--line);
}

.tnode { display: flex; align-items: center; gap: 2px; }

.tcaret {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  width: 18px;
  height: 26px;
  padding: 0;
  font-size: 0.6rem;
  line-height: 1;
  flex: none;
  transition: rotate 0.18s ease;
}
.tcaret[aria-expanded="false"] { rotate: -90deg; }
.tcaret.is-leaf { visibility: hidden; }

.tname {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.tname:hover { background: var(--surface-2); }
.tname.is-active { background: var(--accent); color: var(--accent-ink); }
.tname:focus-visible, .tcaret:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.tname .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tname .count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.tname.is-active .count { color: var(--accent-ink); opacity: 0.75; }

.tree-empty { color: var(--ink-soft); font-size: 0.88rem; padding: 6px 0 2px; }

/* ---------- item sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 17, 13, 0.45);
  z-index: 20;
}

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  z-index: 21;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.25);
  animation: rise 0.22s ease;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
@media (min-width: 760px) {
  .sheet { left: 50%; right: auto; transform: translateX(-50%); width: 700px; }
}
@keyframes rise { from { translate: 0 24px; opacity: 0.6; } to { translate: 0 0; opacity: 1; } }

.sheet-close {
  position: sticky;
  top: 10px;
  margin-left: calc(100% - 46px);
  border: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.9rem;
  cursor: pointer;
  z-index: 2;
}

.sheet-content { padding: 0 20px 20px; margin-top: -24px; display: flex; flex-direction: column; gap: 14px; }

.sheet-media {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  aspect-ratio: 16 / 10;
}
.sheet-media.portrait { aspect-ratio: 9 / 12; max-width: 380px; align-self: center; width: 100%; }
.sheet-media iframe, .sheet-media img { width: 100%; height: 100%; border: 0; object-fit: cover; display: block; }

.sheet-title {
  margin: 0;
  font-family: "Zilla Slab", Georgia, serif;
  font-weight: 600;
  font-size: 1.45rem;
  line-height: 1.3;
  text-wrap: balance;
}

.sheet-author { margin: -8px 0 0; color: var(--ink-soft); font-size: 0.85rem; }

.sheet-summary { margin: 0; color: var(--ink-soft); max-width: 62ch; }

.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.action {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.88rem;
  padding: 8px 16px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
}
.action.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

details.more {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}
details.more summary { cursor: pointer; color: var(--ink); }
details.more p { max-width: 65ch; }

.section-label {
  margin: 8px 0 0;
  font-size: 0.75rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.related-grid .card-title { font-size: 0.9rem; }

/* ---------- desks ---------- */

.desks-bar { display: flex; justify-content: flex-end; margin-bottom: 16px; }

/* A desk tile carries a four-up mosaic, which needs more room than one thumb. */
.grid.is-desks { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.desk-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}

.desk-back {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.85rem;
  padding: 4px 0;
  cursor: pointer;
}
.desk-back:hover { color: var(--ink); }

.desk-title {
  margin: 0;
  font-family: "Zilla Slab", Georgia, serif;
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.25;
  text-wrap: balance;
}

.desk-desc { margin: 0; color: var(--ink-soft); max-width: 62ch; }

/* The share link is the whole point of a desk, so it reads as a finished
   artefact rather than an editable field. */
.share-row { display: flex; gap: 8px; }

.share-link {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.85rem;
  padding: 9px 16px;
  border-radius: 999px;
  text-overflow: ellipsis;
}

.desk-tools {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.desk-vis { display: flex; flex-direction: column; gap: 6px; }
.vis-pills { display: flex; gap: 6px; flex-wrap: wrap; }

.vis-pill {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.8rem;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.vis-pill.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.vis-hint { margin: 0; color: var(--ink-soft); font-size: 0.8rem; max-width: 62ch; }

.desk-delete {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.8rem;
  padding: 2px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.desk-delete:hover { color: var(--ink); }

/* A desk card shows what's on it — up to four covers in one tile. */
.desk-mosaic {
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.desk-mosaic[data-count] {
  display: grid;
  gap: 2px;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.desk-mosaic[data-count="1"] { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.desk-mosaic[data-count="2"] { grid-template-rows: 1fr; }
.desk-mosaic[data-count="3"] > :first-child { grid-row: span 2; }
.desk-mosaic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.desk-mosaic .mosaic-blank { background: var(--surface-2); display: block; }
.desk-mosaic .fallback {
  font-family: "Zilla Slab", Georgia, serif;
  font-size: 2rem;
  color: var(--ink-soft);
}

.card-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  border: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 72%, transparent);
  color: var(--bg);
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
}
.card-remove:hover { background: var(--ink); }
.card-remove:focus-visible,
.vis-pill:focus-visible,
.desk-back:focus-visible,
.desk-delete:focus-visible,
.desk-pick:focus-visible,
.share-link:focus-visible,
.dialog-input:focus-visible,
.action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- watch together (pick & send) ---------- */

.library-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 16px; }

/* ---------- my dashboard: category tiles ---------- */

/* The "+" tile starts a new desk. Dashed, like every drop-something-in spot. */
.tile-plus {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: transparent;
  box-shadow: none;
  color: var(--ink-soft);
  font: inherit;
  cursor: pointer;
  min-height: 180px;
}
.tile-plus:hover { color: var(--ink); border-color: var(--ink-soft); }
.tile-plus:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tile-plus-mark {
  font-family: "Zilla Slab", Georgia, serif;
  font-size: 2.2rem;
  line-height: 1;
}
.tile-plus-label { font-size: 0.85rem; }

/* ---------- how-to (steps & ingredients) ---------- */

.howto-list {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
  max-width: 62ch;
}
.howto-list li::marker { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.select-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.85rem;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.select-toggle:hover { color: var(--ink); }

/* The pick mark: an empty ring while choosing, moss-filled once picked. */
.card-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: color-mix(in srgb, var(--ink) 35%, transparent);
  color: transparent;
  font-size: 0.8rem;
  line-height: 22px;
  text-align: center;
  display: none;
}
.grid.is-selecting .card-check { display: block; }
.grid.is-selecting .card-remove { display: none; }
.card.is-selected .card-check { background: var(--accent); color: var(--accent-ink); }
.card.is-selected { outline: 2px solid var(--accent); outline-offset: -1px; }

.select-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.select-count { flex: 1; color: var(--ink-soft); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.select-bar .action.primary[disabled] { opacity: 0.5; cursor: default; }

/* Keep the last row of cards reachable above the fixed bar. */
body.is-selecting main { padding-bottom: 110px; }

.select-toggle:focus-visible,
.select-bar .action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- dialog ---------- */

.dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: min(440px, calc(100vw - 32px));
  max-height: 80vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 30;
  padding: 20px;
  animation: rise 0.22s ease;
}

.dialog-title {
  margin: 0 0 14px;
  font-family: "Zilla Slab", Georgia, serif;
  font-weight: 600;
  font-size: 1.2rem;
}

.dialog-body, .dialog-form { display: flex; flex-direction: column; gap: 10px; }

.dialog-input {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  padding: 10px 16px;
  border-radius: 999px;
}
.dialog-input::placeholder { color: var(--ink-soft); }

.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.dialog-note { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }
.dialog-error { margin: 0; color: var(--ink); font-size: 0.85rem; }

.desk-picker { display: flex; flex-direction: column; gap: 4px; max-height: 40vh; overflow-y: auto; }

.desk-pick {
  display: flex;
  align-items: baseline;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  padding: 9px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.desk-pick:hover { background: var(--surface-2); }
.desk-pick[disabled] { opacity: 0.5; cursor: default; }
.desk-pick-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desk-pick-count {
  margin-left: auto;
  flex: none;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- SEO pages (server-rendered) ---------- */

.seo-page { background: var(--bg); }
.seo-main { max-width: 65ch; margin: 0 auto; padding: 40px 20px; }
.seo-main h1 { font-family: "Zilla Slab", Georgia, serif; text-wrap: balance; }
.seo-main a { color: var(--accent); }

/* A shared desk lays out cards, so it needs the app's width, not prose width. */
.seo-wide { max-width: 1080px; }
.seo-wide .desk-note { color: var(--ink-soft); max-width: 62ch; }
.seo-wide .desk-meta { color: var(--ink-soft); font-size: 0.9rem; }
.seo-wide .grid { margin-top: 20px; }
.seo-wide .card { text-decoration: none; color: inherit; }
.seo-wide .card-thumb { display: flex; }
.seo-wide .card-body { display: flex; }
.seo-wide .card-title { display: block; }

@media (prefers-reduced-motion: reduce) {
  .card, .sheet, .dialog { transition: none; animation: none; }
}
