@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/BricolageGrotesque.ttf"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Caveat"; src: url("/fonts/Caveat.ttf"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/IBMPlexMono-Medium.ttf"); font-weight: 500; font-display: swap; }

:root {
  --bg: #0E0E0E;
  --fg: #F5F3EE;
  --green: #3DD68C;
  --red: #E5484D;
  --muted: #B8B5AE;
  --line: #5A5853;   /* dividers only: 2.7:1, never the only edge of a control */
  --edge: #8C8A84;   /* control edges: 5.6:1 on --bg */
  --well: #1A1A19;
  --tabs-h: 52px;
  --sans: "Bricolage Grotesque", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --hand: "Caveat", cursive;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.45 var(--sans);
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
img { display: block; max-width: 100%; }
p { margin: 0; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px));
}

.bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px 4px;
  font: 500 11px/1.4 var(--mono); color: var(--muted);
}
#crew.on { color: var(--green); }

.h, .dh {
  font-weight: 800; letter-spacing: -0.3px; line-height: 1.1;
  margin: 2px 16px 0;
}
.h { font-size: 22px; }
.note { font-family: var(--hand); font-size: 18px; color: var(--muted); line-height: 1.1; }
.state { padding: 24px 16px; color: var(--muted); }
.state.err-state { color: var(--fg); }
.err { color: var(--red); font-size: 13px; }
.meta, .counter, .queue, .when, .counts {
  font: 500 11px/1.4 var(--mono); color: var(--muted);
}

/* buttons: light fill for the action that sends something, outline for the rest */
button { cursor: pointer; min-height: 44px; border-radius: 0; }
button:disabled { cursor: default; opacity: .55; }
.primary { background: var(--fg); color: var(--bg); border: 0; font-weight: 600; padding: 0 16px; }
.ghost { background: transparent; border: 1.5px solid var(--edge); padding: 0 14px; font-weight: 500; }
.ghost:active, .primary:active { transform: translateY(1px); }

input[type=text], select {
  min-height: 44px; width: 100%; min-width: 0;
  background: var(--well); border: 1.5px solid var(--edge); border-radius: 0;
  padding: 10px 12px; font-size: 15px;
}
input::placeholder { color: var(--muted); opacity: 1; }
input:focus-visible, select:focus-visible { outline-offset: 0; border-color: var(--fg); }

/* --- Kantor --- */
.kantor { display: flex; flex-direction: column; min-height: calc(100dvh - var(--tabs-h) - 32px); }
.office { position: relative; width: 100%; aspect-ratio: 360 / 380; margin-top: 4px; overflow: hidden; background: #2C2420; }
.office svg { position: absolute; inset: 0; width: 100%; height: 100%; }
/* speech bubbles: newsprint cards anchored over a head by office.js (transform only), tail under the speaker */
.bub {
  position: absolute; left: 0; top: 0; width: 42%; max-width: 200px;
  background: #F5F3EE; color: #1B1612;
  font-size: 12.5px; line-height: 1.3; padding: 5px 8px;
  border: 2px solid #1B1612; border-radius: 8px;
  opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility 0s linear .25s;
}
.bub.show { opacity: 1; visibility: visible; transition: opacity .25s ease; }
.bub::after {
  content: ""; position: absolute; left: var(--tail, 50%); bottom: -7px; margin-left: -6px;
  width: 10px; height: 10px; background: #F5F3EE; transform: rotate(45deg);
  border: 2px solid #1B1612; border-top-color: transparent; border-left-color: transparent;
}
.bub > span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; position: relative; z-index: 1; }
.bub.on, .bub.on::after { border-color: var(--green); }
.bub.fail, .bub.fail::after { border-color: var(--red); }
.bub.on::after, .bub.fail::after { border-top-color: transparent; border-left-color: transparent; }
.queue { min-height: 20px; padding: 0 16px; }
.queue.err { color: var(--fg); font-family: var(--sans); font-size: 13px; }

/* --- newsroom people ---
   Poses are static rules; loops run only on someone doing something. Joints (.j) rotate around their own pivot.
   .rest = seated at the own desk and not in a hand-off; .away = standing up; JS moves people with transforms. */
.office .j, .office .carriage, .office .ticker { transform-box: view-box; transform-origin: 0 0; }
.office.paused * { animation-play-state: paused !important; }
.ticker { animation: tick 30s linear infinite; }
@keyframes tick { to { transform: translateX(var(--tick, -360px)); } }
.p .paper, .p .mug, .p .stamp, .p .news, .p .chat, .lamp .pool { display: none; }
.desk.busy .lamp .pool { display: inline; }

.p .ua { transform: rotate(-8deg); }
.p .fa { transform: rotate(-30deg); }
.p .ub { transform: rotate(8deg); }
.p .fb { transform: rotate(30deg); }

/* idle at the desk: Periset reads the paper, Penulis sips coffee, Desainer stretches, Redaktur leans back */
.p.rest[data-role=periset]:not(.busy) .news { display: inline; animation: peek 8s ease-in-out infinite; }
.p.rest[data-role=periset]:not(.busy) .ua { transform: rotate(-34deg); }
.p.rest[data-role=periset]:not(.busy) .fa { transform: rotate(-96deg); }
.p.rest[data-role=periset]:not(.busy) .ub { transform: rotate(34deg); }
.p.rest[data-role=periset]:not(.busy) .fb { transform: rotate(96deg); }
.p.rest[data-role=penulis]:not(.busy) .mug { display: inline; }
.p.rest[data-role=penulis]:not(.busy) .ub { animation: sip-u 7s ease-in-out infinite; }
.p.rest[data-role=penulis]:not(.busy) .fb { animation: sip-f 7s ease-in-out infinite; }
.p.rest[data-role=penulis]:not(.busy) .hd { animation: sip-h 7s ease-in-out infinite; }
.p.rest[data-role=desainer]:not(.busy) .ua { animation: up-ua 9s ease-in-out infinite; }
.p.rest[data-role=desainer]:not(.busy) .fa { animation: up-fa 9s ease-in-out infinite; }
.p.rest[data-role=desainer]:not(.busy) .ub { animation: up-ub 9s ease-in-out infinite; }
.p.rest[data-role=desainer]:not(.busy) .fb { animation: up-fb 9s ease-in-out infinite; }
.p.rest[data-role=redaktur]:not(.busy) .ua { transform: rotate(150deg); }
.p.rest[data-role=redaktur]:not(.busy) .fa { transform: rotate(104deg); }
.p.rest[data-role=redaktur]:not(.busy) .ub { transform: rotate(-150deg); }
.p.rest[data-role=redaktur]:not(.busy) .fb { transform: rotate(-104deg); }
.p.rest[data-role=redaktur]:not(.busy) .hand { display: none; }
.p.rest[data-role=redaktur]:not(.busy) .hd { animation: lean 8s ease-in-out infinite; }
@keyframes peek { 0%, 55%, 100% { transform: translateY(0); } 65%, 85% { transform: translateY(3px); } }
@keyframes sip-u { 0%, 58%, 96%, 100% { transform: rotate(8deg); } 68%, 86% { transform: rotate(-4deg); } }
@keyframes sip-f { 0%, 58%, 96%, 100% { transform: rotate(30deg); } 68%, 86% { transform: rotate(150deg); } }
@keyframes sip-h { 0%, 60%, 94%, 100% { transform: rotate(0); } 70%, 84% { transform: rotate(-8deg); } }
@keyframes up-ua { 0%, 66%, 94%, 100% { transform: rotate(-8deg); } 74%, 86% { transform: rotate(158deg); } }
@keyframes up-fa { 0%, 66%, 94%, 100% { transform: rotate(-30deg); } 74%, 86% { transform: rotate(-12deg); } }
@keyframes up-ub { 0%, 66%, 94%, 100% { transform: rotate(8deg); } 74%, 86% { transform: rotate(-158deg); } }
@keyframes up-fb { 0%, 66%, 94%, 100% { transform: rotate(30deg); } 74%, 86% { transform: rotate(12deg); } }
@keyframes lean { 0%, 100% { transform: rotate(0); } 40%, 60% { transform: rotate(-7deg); } }

/* busy: Penulis types, Periset flips clippings, Desainer moves pages, Redaktur reads and stamps */
.p.rest[data-role=penulis].busy .fa { animation: type-a .34s ease-in-out infinite alternate; }
.p.rest[data-role=penulis].busy .fb { animation: type-b .34s ease-in-out -.17s infinite alternate; }
.p.rest[data-role=penulis].busy .hd { animation: nod 2.4s ease-in-out infinite; }
.desk.busy .carriage { animation: carriage 3.2s steps(8, end) infinite; }
.p.rest[data-role=periset].busy .ub { animation: clip-u 1.6s ease-in-out infinite; }
.p.rest[data-role=periset].busy .fb { animation: clip-f 1.6s ease-in-out infinite; }
.p.rest[data-role=periset].busy .hd { transform: rotate(6deg); }
.desk.busy .flipcard { animation: flip 1.6s ease-in-out infinite; }
.p.rest[data-role=desainer].busy .ua { animation: arr-a 2.2s ease-in-out infinite; }
.p.rest[data-role=desainer].busy .ub { animation: arr-b 2.2s ease-in-out -1.1s infinite; }
.p.rest[data-role=desainer].busy .hd { animation: look 4.4s ease-in-out infinite; }
.desk.busy .page1 { animation: slide1 2.2s ease-in-out infinite; }
.desk.busy .page2 { animation: slide2 2.2s ease-in-out -1.1s infinite; }
.p.rest[data-role=redaktur].busy .stamp { display: inline; }
.p.rest[data-role=redaktur].busy .ub { animation: stamp-u 1.5s ease-in infinite; }
.p.rest[data-role=redaktur].busy .fb { animation: stamp-f 1.5s ease-in infinite; }
.p.rest[data-role=redaktur].busy .hd { transform: rotate(5deg); }
.desk.busy .mark { animation: mark 1.5s steps(1, end) infinite; }
@keyframes type-a { to { transform: rotate(-18deg); } }
@keyframes type-b { to { transform: rotate(18deg); } }
@keyframes nod { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(4deg); } }
@keyframes carriage { to { transform: translateX(-8px); } }
@keyframes clip-u { 0%, 100% { transform: rotate(8deg); } 45%, 60% { transform: rotate(-24deg); } }
@keyframes clip-f { 0%, 100% { transform: rotate(30deg); } 45%, 60% { transform: rotate(84deg); } }
@keyframes flip { 0%, 40% { transform: scaleX(1); } 55%, 90% { transform: scaleX(-1); } 100% { transform: scaleX(1); } }
@keyframes arr-a { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(22deg); } }
@keyframes arr-b { 0%, 100% { transform: rotate(8deg); } 50% { transform: rotate(-22deg); } }
@keyframes look { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
@keyframes slide1 { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-6px); } }
@keyframes slide2 { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(6px); } }
@keyframes stamp-u { 0%, 100% { transform: rotate(8deg); } 40% { transform: rotate(-26deg); } 70% { transform: rotate(10deg); } }
@keyframes stamp-f { 0%, 100% { transform: rotate(30deg); } 40% { transform: rotate(130deg); } 70% { transform: rotate(60deg); } }
@keyframes mark { 0%, 69% { opacity: 0; } 70% { opacity: 1; } }

/* up and about: standing, walking, handing over a sheet, talking */
.p.away .ua { transform: rotate(6deg); }
.p.away .fa { transform: rotate(-8deg); }
.p.away .ub { transform: rotate(-6deg); }
.p.away .fb { transform: rotate(8deg); }
.p.walking .la { animation: stride .56s ease-in-out infinite alternate; }
.p.walking .lb { animation: stride .56s ease-in-out -.56s infinite alternate; }
.p.walking .ua { animation: swing .56s ease-in-out -.56s infinite alternate; }
.p.walking:not(.carry) .ub { animation: swing .56s ease-in-out infinite alternate; }
.p.carry .ub { transform: rotate(-12deg); }
.p.carry .fb { transform: rotate(-48deg); }
.p.carry .paper { display: inline; }
.p.give .ub, .p.take .ub { transform: rotate(-76deg); }
.p.give .fb, .p.take .fb { transform: rotate(-10deg); }
.p.side .eyes { transform: translateX(1.7px); }
.p.talk .chat { display: inline; animation: chat .45s ease-in-out infinite alternate; }
@keyframes stride { from { transform: rotate(20deg); } to { transform: rotate(-20deg); } }
@keyframes swing { from { transform: rotate(-16deg); } to { transform: rotate(16deg); } }
@keyframes chat { to { transform: translateY(-1.5px); } }

.sheet {
  margin-top: auto;
  border-top: 1.5px solid var(--line);
  padding: 12px 16px 14px;
  display: grid; gap: 8px;
}
.row { display: flex; gap: 8px; }
.row > input { flex: 1; }
.row-meta { display: flex; justify-content: space-between; gap: 12px; min-height: 16px; }

/* --- tabs --- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  max-width: 480px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--bg); border-top: 1.5px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs button {
  min-height: var(--tabs-h); background: var(--bg); border: 0;
  color: var(--muted); font-weight: 500; font-size: 14px;
}
.tabs button[aria-selected=true] { color: var(--fg); box-shadow: inset 0 3px 0 var(--green); }
.tabs button:focus-visible { outline-offset: -4px; }

/* --- Draf list --- */
.seg { display: grid; grid-template-columns: 1fr 1fr; margin: 12px 16px 0; border: 1.5px solid var(--edge); }
.seg button { background: transparent; border: 0; color: var(--muted); font-weight: 500; }
.seg button[aria-pressed=true] { background: var(--fg); color: var(--bg); }
.counts { padding: 10px 16px 4px; }
.list { display: grid; gap: 10px; padding: 6px 16px 20px; }
.dcard {
  display: grid; gap: 8px; width: 100%; text-align: left;
  background: transparent; border: 1.5px solid var(--line); padding: 12px;
}
.dcard:hover { border-color: var(--edge); }
.dcard > span { display: block; }
.dcard .t { font-weight: 800; font-size: 17px; line-height: 1.15; letter-spacing: -0.2px; }
.thumbs { display: flex !important; gap: 4px; }
.thumbs img { width: 44px; height: 55px; object-fit: cover; background: var(--well); border: 1px solid var(--line); }
.chips { display: flex !important; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font: 500 11px/1 var(--mono); padding: 5px 7px;
  border: 1px solid var(--edge); color: var(--muted); border-radius: 2px;
}
.chip.on { background: var(--green); border-color: var(--green); color: var(--bg); }
.chip svg { width: 10px; height: 10px; }

/* --- Draf detail --- */
.detail { padding: 8px 0 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.detail > .meta, .detail > .back-row { padding: 0 16px; }
.back { background: transparent; border: 0; padding: 0 12px 0 0; color: var(--muted); font-weight: 500; }
.dh { font-size: 21px; }
.share-block, .marks { padding: 0 16px; display: grid; gap: 6px; }
/* three across on a phone; they stack when text is zoomed and a column gets narrower than its label */
.share, .marks .toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 6px; }
.share button { background: transparent; border: 1.5px solid var(--fg); font-weight: 600; padding: 0 4px; }
.marks button { background: transparent; border: 1.5px solid var(--edge); font: 500 12px var(--mono); }
.marks button[aria-pressed=true] { background: var(--green); border-color: var(--green); color: var(--bg); }
.label { font: 500 11px/1.4 var(--mono); color: var(--muted); }

.carousel { display: grid; gap: 6px; }
.carousel-head { display: flex; justify-content: space-between; padding: 0 16px; }
.counter-n { font: 500 12px/1.4 var(--mono); color: var(--fg); }
.track {
  display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 0 16px; scroll-padding: 0 16px; scrollbar-width: none;
}
.track::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; align-content: start; }
.slide img { width: 100%; height: auto; aspect-ratio: 1080 / 1350; background: var(--well); }

.part { padding: 0 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.part-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.part-head h3 { margin: 0; }
.copy { background: transparent; border: 1.5px solid var(--edge); padding: 0 14px; min-width: 88px; font: 500 12px var(--mono); }
.carousel-act { padding: 0 16px; display: grid; }
.carousel-act button { border-color: var(--fg); font-weight: 600; }
.part h3 { margin: 6px 0 0; font-size: 15px; font-weight: 800; }
.text-block { white-space: pre-wrap; overflow-wrap: anywhere; border-left: 0; background: var(--well); padding: 12px; font-size: 14px; }
.rev { display: grid; gap: 4px; }
.pending { font-size: 13px; color: var(--green); }
.vrow { display: flex; flex-wrap: wrap; gap: 8px; }
.vrow select { flex: 1 1 160px; }
.vrow button { flex: 1 0 auto; }
.archived-note { padding: 0 16px; display: grid; gap: 8px; }

/* --- Ide --- */
.ideas { list-style: none; margin: 0; padding: 8px 16px 20px; display: grid; gap: 0; }
.idea-item { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.idea-item .txt { overflow-wrap: anywhere; }
.idea-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.status { font: 500 11px/1.3 var(--mono); }
.status.queued { color: var(--muted); }
.status.running, .status.done { color: var(--green); }
.status.failed { color: var(--red); }
.status.cancelled { color: var(--muted); text-decoration: line-through; }
.status-wrap { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }

/* --- overlays --- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs-h) + 12px + env(safe-area-inset-bottom, 0px));
  max-width: 448px; margin: 0 auto; z-index: 20;
  background: var(--fg); color: var(--bg); padding: 10px 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .16s ease;
}
.toast.show { opacity: 1; }
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(14, 14, 14, .72); display: flex; align-items: flex-end; justify-content: center; }
.dialog {
  width: 100%; max-width: 480px; background: var(--bg); border-top: 1.5px solid var(--fg);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 12px;
}
.dialog p { font-weight: 800; font-size: 18px; line-height: 1.2; }
.dialog .row > button { flex: 1; }

.gate { min-height: 100dvh; display: grid; place-content: center; gap: 8px; padding: 24px; text-align: center; }
.gate-title { font-weight: 800; font-size: 22px; line-height: 1.15; }

@media (prefers-reduced-motion: reduce) {
  .office *, .office *::after { animation: none !important; transition: none !important; }
  .toast { transition: none; }
}
.h.pad { margin-top: 12px; }
