/* The desk's own ink and paper, so the move reads as the same place. Tokens first, dark mode beside them. */
:root {
  --paper: #f2f4f7; --sheet: #ffffff; --sunk: #e8ecf1; --ink: #16202e; --muted: #5a6575; --faint: #76808f; --rule: #d6dce5;
  --accent: #2147a8; --accent-bg: #e7edfb; --hard: #b42318; --hard-bg: #fde7e4; --soft: #8a5300; --soft-bg: #fff1d6; --clean: #1b7543; --clean-bg: #e3f3e9;
  --die: #23288a; --die-ink: #f3f4ff;
  --ui: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --text: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e131a; --sheet: #161d27; --sunk: #111720; --ink: #e5eaf1; --muted: #98a3b3; --faint: #7f8a9b; --rule: #2a3442;
    --accent: #93b2ff; --accent-bg: #1a2540; --hard: #ff8f84; --hard-bg: #3b1714; --soft: #f0b75c; --soft-bg: #352611; --clean: #74d3a0; --clean-bg: #12301f;
    --die: #353bc4; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--ui); }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1 { font: 800 clamp(1.7rem, 4vw, 2.2rem)/1.1 var(--ui); letter-spacing: -0.02em; text-wrap: balance; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 30; background: var(--sheet); padding: 8px 12px; border-radius: 6px; }

/* the frame: a rail from 1024 up, a tab bar below */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100dvh; }
.rail { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 22px; padding: 22px 14px 18px; border-right: 1px solid var(--rule); background: var(--sheet); }
.brand { display: grid; gap: 2px; align-content: center; min-height: 44px; padding: 0 10px; color: var(--ink); text-decoration: none; }
.brand-mark { font: 800 1.45rem/1 var(--ui); letter-spacing: -0.02em; }
.brand-sub { font: 500 0.72rem/1.2 var(--mono); color: var(--muted); }
.nav { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px; border-radius: 8px; color: var(--muted); font-weight: 600; text-decoration: none; }
.nav-item:hover { background: var(--sunk); color: var(--ink); }
.nav-item[aria-current] { background: var(--ink); color: var(--paper); }
.ic { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.count { margin-left: auto; font: 600 0.72rem/1 var(--mono); padding: 4px 7px; border-radius: 999px; background: var(--accent); color: var(--sheet); }
.me { margin-top: auto; display: grid; gap: 1px; padding: 12px 10px 0; border-top: 1px solid var(--rule); }
.me-name { font-weight: 600; overflow-wrap: anywhere; }
.me-role { font: 500 0.74rem/1.4 var(--mono); color: var(--muted); }
.main { padding: 30px 36px 72px; min-width: 0; max-width: 1120px; width: 100%; }
.main.flush { padding-bottom: 0; max-width: none; display: flex; flex-direction: column; min-height: 100dvh; }

/* shared */
.page-head { display: grid; gap: 12px; margin-bottom: 14px; }
.lede { color: var(--muted); max-width: 62ch; }
.eyebrow { font: 600 0.72rem/1.2 var(--ui); letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.fine { font-size: 0.82rem; color: var(--muted); }
.lbl { display: block; font: 600 0.74rem/1.2 var(--ui); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin: 8px 0 5px; }
.chip { font: 500 0.72rem/1 var(--mono); color: var(--muted); background: var(--sunk); border-radius: 4px; padding: 4px 6px; white-space: nowrap; }
.chip.sample { background: var(--soft-bg); color: var(--soft); }
.chip.draft { background: var(--accent-bg); color: var(--accent); }
.chip.held { background: var(--hard-bg); color: var(--hard); }
.proto { font-size: 0.86rem; color: var(--muted); border: 1px dashed var(--rule); border-radius: 8px; padding: 7px 12px; margin: 0 0 16px; }
.proto b { color: var(--ink); }
.flash { background: var(--clean-bg); border-radius: 8px; padding: 9px 12px; margin: 0 0 14px; font-size: 0.92rem; }
.flash.bad { background: var(--hard-bg); }
.empty { color: var(--muted); padding: 28px; text-align: center; border: 1px dashed var(--rule); border-radius: 10px; }
.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; padding: 16px 18px; }
.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.more { display: inline-flex; align-items: center; min-height: 44px; margin-top: 2px; font-weight: 600; font-size: 0.9rem; }

input[type="text"], input[type="email"], input[type="url"], input[type="search"], input[type="file"], select, textarea {
  width: 100%; min-height: 44px; background: var(--sheet); color: var(--ink); border: 1px solid var(--rule); border-radius: 8px; padding: 10px 12px; font: 400 1rem/1.4 var(--ui);
}
textarea { font-family: var(--text); line-height: 1.55; resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border: 1px solid var(--rule); border-radius: 8px; background: var(--sheet); color: var(--ink); font: 600 0.92rem/1 var(--ui); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.use { background: var(--clean); border-color: var(--clean); color: var(--sheet); }
.btn.kill { color: var(--hard); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.link-btn { display: inline-flex; align-items: center; min-height: 44px; border: 0; background: none; padding: 0 2px; color: var(--accent); font: 500 0.86rem/1.2 var(--ui); text-decoration: underline; cursor: pointer; }
.search { display: flex; gap: 8px; max-width: 640px; }
.composer { display: grid; gap: 4px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; max-width: 860px; }
.composer .btn { justify-self: start; margin-top: 8px; }
.fold { border-top: 1px solid var(--rule); padding-top: 6px; }
.fold summary { cursor: pointer; font-weight: 600; font-size: 0.92rem; line-height: 20px; padding: 12px 0; min-height: 44px; box-sizing: border-box; }
.fold form { display: grid; gap: 4px; padding-bottom: 8px; }
.fold .btn { justify-self: start; margin-top: 6px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 2px; scrollbar-width: none; }
.tab { display: inline-flex; gap: 6px; align-items: center; min-height: 44px; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--rule); background: var(--sheet); color: var(--muted); font-weight: 600; font-size: 0.9rem; text-decoration: none; white-space: nowrap; }
.tab[aria-current] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.tab span { font: 500 0.75rem/1 var(--mono); }

/* home */
.home-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px; }
.todo { display: flex; align-items: baseline; gap: 12px; padding: 10px 0; color: var(--ink); text-decoration: none; border-top: 1px solid var(--rule); }
.todo:first-of-type { border-top: 0; }
.todo b { font: 800 2rem/1 var(--ui); letter-spacing: -0.02em; min-width: 1.6ch; }
.todo span { color: var(--muted); }
.todo:hover span { color: var(--ink); text-decoration: underline; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin-bottom: 10px; }
.tile { display: grid; gap: 2px; align-content: start; }
.tile-v { font: 800 1.5rem/1.1 var(--ui); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile-l { font-size: 0.84rem; color: var(--muted); line-height: 1.3; }
.doc-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.doc-mini li { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.doc-mini a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }

/* the ball */
.ball-card { background: #15172e; color: #eef0fb; border-radius: 14px; padding: 18px 20px; }
.ball-card .eyebrow { color: #a9aed0; }
.ball-card a { color: #b9c4ff; }
.ball-card .fine { color: #a9aed0; margin-top: 12px; }
.ball-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: center; }
.ball { width: 164px; height: 164px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; display: grid; place-items: center;
  background: radial-gradient(circle at 34% 28%, #6b6e86 0%, #2a2c3d 18%, #0c0d16 55%, #050509 100%);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45), inset -10px -14px 30px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08); }
.ball-window { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #10133f 0%, #070820 70%); box-shadow: inset 0 5px 14px rgba(0, 0, 0, 0.9), 0 0 0 4px #1b1d2b; }
.die { width: 86px; height: 74px; background: var(--die); clip-path: polygon(50% 100%, 0 0, 100% 0); display: grid; justify-items: center; align-content: start; padding: 10px 17px 0; transition: opacity 0.35s ease, transform 0.35s ease; }
.die-text { font: 800 7.5px/1.2 var(--ui); color: var(--die-ink); text-align: center; letter-spacing: 0.03em; text-transform: uppercase; max-width: 52px; }
.ball.fading .die { opacity: 0; transform: translateY(8px) scale(0.9); }
.ball.shake { animation: shake 0.55s ease; }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translate(-7px, 2px) rotate(-6deg); } 40% { transform: translate(6px, -3px) rotate(5deg); } 60% { transform: translate(-4px, 1px) rotate(-3deg); } 80% { transform: translate(3px, 0) rotate(2deg); } }
@media (prefers-reduced-motion: reduce) { .ball.shake { animation: none; } .die { transition: none; } }
.ball-q { font: 600 1.12rem/1.3 var(--ui); min-height: 2.6em; }
.ball-why { font: 400 0.92rem/1.45 var(--text); color: #cfd3ec; margin-top: 6px; min-height: 4.3em; }
.ball-foot { margin-top: 4px; font-size: 0.86rem; color: #a9aed0; }
.ball-foot a { display: inline-flex; align-items: center; min-height: 44px; }

/* this week and tell us */
.cards, .tickets { display: grid; gap: 12px; max-width: 860px; }
.card, .ticket { background: var(--sheet); border: 1px solid var(--rule); border-left: 4px solid var(--accent); border-radius: 10px; padding: 14px 16px; display: grid; gap: 9px; min-width: 0; }
.card-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: start; }
.seat { font: 600 0.72rem/1.2 var(--ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); grid-column: 1; }
.card-head h3 { font: 700 1.02rem/1.3 var(--ui); grid-column: 1; }
.card-side { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.galley { font: 400 1.02rem/1.6 var(--text); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--paper); border-radius: 8px; padding: 12px 14px; }
.ref { font: 600 0.72rem/1 var(--mono); border-radius: 4px; padding: 4px 6px; white-space: nowrap; background: var(--soft-bg); color: var(--soft); }
.ref.clean { background: var(--clean-bg); color: var(--clean); }
.ref.hard, .ref.refused { background: var(--hard-bg); color: var(--hard); }
.acts { display: flex; gap: 8px; flex-wrap: wrap; }
.blocked { color: var(--hard); font-size: 0.86rem; }
.chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips legend { padding: 0; }
.pick input { position: absolute; opacity: 0; }
.pick span { display: inline-flex; min-height: 44px; align-items: center; border: 1px solid var(--rule); border-radius: 999px; padding: 6px 12px; font-size: 0.86rem; cursor: pointer; }
.pick input:checked + span { background: var(--hard); border-color: var(--hard); color: var(--sheet); }
.pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ticket[data-kind="problem"] { border-left-color: var(--hard); }
.ticket[data-kind="question"] { border-left-color: var(--soft); }
.ticket[data-kind="loom"] { border-left-color: #6a4fc0; }
.ticket[data-withdrawn] { opacity: 0.6; border-left-style: dashed; }
.tk-top { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.tk-kind { font: 700 0.7rem/1 var(--ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tk-text { font: 400 1.02rem/1.6 var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.tk-status { border-left: 3px solid var(--rule); padding-left: 12px; font-weight: 600; font-size: 0.92rem; }
.tk-status[data-state="build"], .tk-status[data-state="desk"], .tk-status[data-state="loom"] { border-left-color: var(--accent); }
.tk-status[data-state="asked"] { border-left-color: var(--soft); }
.tk-status[data-state="done"] { border-left-color: var(--clean); }
.tk-status ul { margin: 4px 0 0; padding-left: 1.1em; font-weight: 400; color: var(--muted); }
.reply, .comment { border-radius: 8px; padding: 8px 12px; font-size: 0.93rem; background: var(--paper); }
.reply { background: var(--accent-bg); }
.reply p, .comment p { white-space: pre-wrap; overflow-wrap: anywhere; }

/* the library */
.doc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.doc-card { display: grid; gap: 6px; align-content: start; background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; padding: 14px 16px; color: var(--ink); text-decoration: none; min-width: 0; }
.doc-card:hover { border-color: var(--ink); }
.doc-card h3 { font: 700 1.08rem/1.25 var(--ui); }
.doc-card p { font-size: 0.92rem; color: var(--muted); line-height: 1.4; }
.doc-top { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.hits { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; max-width: 820px; }
.hits a { display: grid; gap: 2px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 11px 14px; color: var(--ink); text-decoration: none; }
.hits a:hover { border-color: var(--ink); }
.hit-doc { font: 700 1rem/1.3 var(--ui); }
.hit-head { font-size: 0.86rem; color: var(--muted); }
.hit-snip { font: 400 0.95rem/1.5 var(--text); margin-top: 3px; overflow-wrap: anywhere; }
mark { background: var(--soft-bg); color: inherit; border-radius: 2px; padding: 0 1px; }
.upload { margin-top: 8px; max-width: 720px; }
.doc-head { display: grid; gap: 8px; margin-bottom: 14px; }
.crumb { font-size: 0.86rem; color: var(--muted); }
.doc-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.doc-actions:empty { display: none; }
.doc-frame { flex: 1; width: calc(100% + 72px); margin: 0 -36px; min-height: 70dvh; border: 0; border-top: 1px solid var(--rule); background: var(--sheet); }
.prose { font: 400 1.05rem/1.65 var(--text); max-width: 70ch; display: grid; gap: 12px; overflow-wrap: anywhere; }
.prose h2, .prose h3, .prose h4 { font-family: var(--ui); line-height: 1.25; margin-top: 12px; scroll-margin-top: 12px; }
.prose h2 { font-weight: 800; font-size: 1.35rem; }
.prose h3 { font-weight: 700; font-size: 1.1rem; }
.prose p, .prose ul, .prose ol, .prose pre, .prose blockquote { margin: 0; }
.prose ul, .prose ol { padding-left: 1.3em; display: grid; gap: 5px; }
.prose code { font: 400 0.84em var(--mono); background: var(--sunk); border-radius: 3px; padding: 1px 4px; }
.prose pre { font: 400 0.82rem/1.5 var(--mono); background: var(--sunk); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { border-left: 3px solid var(--rule); padding-left: 12px; color: var(--muted); }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; font: 400 0.9rem/1.4 var(--ui); }
.prose th, .prose td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.extract { margin-top: 6px; }
.panel .btn { margin-top: 8px; margin-bottom: 12px; }

/* looms */
.looms { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-width: 860px; }
.loom { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 8px 14px; align-items: center; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 10px 14px; }
.loom a { display: grid; align-content: center; min-height: 44px; text-decoration: none; }
.loom-id { font: 600 0.95rem/1.3 var(--mono); }
.stages { list-style: none; display: flex; flex-wrap: wrap; gap: 5px; margin: 0; padding: 0; }
.stages li { font: 600 0.74rem/1 var(--ui); padding: 6px 9px; border-radius: 999px; border: 1px solid var(--rule); color: var(--muted); }
.stages li[data-at="done"] { color: var(--clean); border-color: var(--clean); background: var(--clean-bg); }
.stages li[data-at="now"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }

/* sign-in */
.bare { max-width: 440px; margin: 0 auto; padding: 12vh 20px 40px; display: grid; gap: 14px; }
.bare-title { font: 800 2.1rem/1 var(--ui); letter-spacing: -0.02em; }
.outbox { padding: 0; list-style: none; display: grid; gap: 10px; }
.outbox li { overflow-wrap: anywhere; }

@media (max-width: 1023px) {
  .app { display: block; padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; justify-content: space-between; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .brand { padding: 0; }
  .brand-mark { font-size: 1.2rem; }
  .me { margin: 0; padding: 0; border: 0; justify-items: end; }
  .me-role { display: none; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; background: var(--sheet); border-top: 1px solid var(--rule); padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); }
  .nav-item { position: relative; flex-direction: column; gap: 3px; padding: 6px 2px; font-size: 0.68rem; border-radius: 8px; text-align: center; }
  .count { position: absolute; top: 1px; right: calc(50% - 22px); margin: 0; padding: 3px 5px; font-size: 0.62rem; }
  .main { padding: 18px 16px 32px; }
  .home-grid, .doc-grid { grid-template-columns: minmax(0, 1fr); }
  .main.flush { min-height: 0; }
  .doc-frame { width: calc(100% + 32px); margin: 0 -16px; min-height: calc(100dvh - 240px); }
}
@media (max-width: 640px) {
  .two { grid-template-columns: minmax(0, 1fr); }
  .ball-row { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; gap: 14px; }
  .ball-why { min-height: 5.8em; }
  .card-head { grid-template-columns: minmax(0, 1fr); }
  .card-side { grid-column: 1; grid-row: auto; justify-content: flex-start; margin-top: 4px; }
  .loom { grid-template-columns: minmax(0, 1fr); }
}
