:root {
  --bg: #f7f5f2; --card: #fff; --ink: #1c1917; --muted: #78716c; --line: #e7e2dc;
  --red: #990011; --red-soft: #f8eaec; --green: #1f7a4d; --green-soft: #e6f3ec;
  --radius: 14px; --shadow: 0 1px 2px rgba(28, 25, 23, .05), 0 6px 20px rgba(28, 25, 23, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --white: #fff; --btn: #efebe6; --btn-hover: #e5e0d9; --red-dark: #7d000e;
  /* size scale */
  --s-2: 2px; --s-3: 3px; --s-4: 4px; --s-6: 6px; --s-7: 7px; --s-8: 8px; --s-9_5: 9.5px; --s-10: 10px; --s-12: 12px; --s-13: 13px; --s-14: 14px; --s-15: 15px; --s-16: 16px; --s-18: 18px; --s-20: 20px; --s-22: 22px; --s-24: 24px; --s-26: 26px; --s-28: 28px; --s-30: 30px; --s-34: 34px; --s-36: 36px; --s-40: 40px; --s-42: 42px; --s-48: 48px; --s-64: 64px; --s-80: 80px; --s-200: 200px; --s-300: 300px; --s-560: 560px; --s-1240: 1240px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: var(--s-16)/1.5 var(--font); }
h1 { font-size: var(--s-28); line-height: 1.15; margin: 0; letter-spacing: -.02em; text-wrap: balance; }
h2 { font-size: var(--s-18); line-height: 1.25; margin: 0; text-wrap: balance; }
h3 { font-size: var(--s-14); margin: 0; }
p { margin: 0; }
a { color: var(--red); }
.muted { color: var(--muted); font-size: var(--s-14); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.label { display: block; font-size: var(--s-12); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: var(--s-4); }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-12); padding: var(--s-12) var(--s-20); background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: var(--s-10); text-decoration: none; color: var(--muted); font-size: var(--s-14); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.brand img { height: var(--s-26); width: auto; display: block; }
.top-nav { display: flex; align-items: center; gap: var(--s-18); font-size: var(--s-14); }
.top-nav a, .top-nav button { white-space: nowrap; }
.top-nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.top-nav a:hover { color: var(--red); }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
button.link:hover { color: var(--ink); }

main { margin: 0 auto; padding: var(--s-28) var(--s-16) var(--s-64); }
main.narrow { max-width: var(--s-560); }
main.wide { max-width: var(--s-1240); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--s-20); }
.flash { background: var(--ink); color: var(--white); border-radius: var(--s-10); padding: var(--s-12) var(--s-16); margin-bottom: var(--s-20); font-size: var(--s-15); overflow-wrap: anywhere; white-space: pre-wrap; }
.error { color: var(--red); font-size: var(--s-14); font-weight: 500; }
.empty { color: var(--muted); padding: var(--s-48) 0; text-align: center; }

/* buttons + fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-6); min-height: var(--s-42); padding: 0 var(--s-16); border: 0; border-radius: var(--s-10); background: var(--btn); color: var(--ink); font: inherit; font-weight: 600; font-size: var(--s-15); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--btn-hover); }
.btn.primary { background: var(--red); color: var(--white); }
.btn.primary:hover { background: var(--red-dark); }
.btn.small { min-height: var(--s-34); padding: 0 var(--s-12); font-size: var(--s-14); border-radius: var(--s-8); }
.btn.block { display: flex; width: 100%; }
.btn.danger-text { background: none; color: var(--red); padding-left: 0; }
.btn.danger-text:hover { text-decoration: underline; }
:focus-visible { outline: var(--s-2) solid var(--red); outline-offset: var(--s-2); }
label { display: block; font-size: var(--s-14); font-weight: 600; margin-top: var(--s-14); }
input:not([type=checkbox]):not([type=file]), select, textarea { display: block; width: 100%; margin-top: var(--s-6); padding: var(--s-10) var(--s-12); border: 1px solid var(--line); border-radius: var(--s-10); background: var(--white); color: var(--ink); font: inherit; font-weight: 400; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: var(--s-2) solid var(--red); outline-offset: 0; border-color: transparent; }
label.check { display: flex; align-items: center; gap: var(--s-8); font-weight: 400; margin-top: var(--s-8); }
.grid2, .grid3 { display: grid; gap: 0 var(--s-12); grid-template-columns: 1fr 1fr; }
.grid3 { grid-template-columns: 1.2fr 1fr .8fr; }

/* login */
.login { margin-top: 8vh; }
.login .btn { width: 100%; margin-top: var(--s-20); }

/* user page */
.task { margin-top: var(--s-16); display: grid; gap: var(--s-14); }
.task-head { display: flex; align-items: center; justify-content: space-between; }
.kind { font-size: var(--s-12); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kind.post { color: var(--red); }
.when { font-size: var(--s-14); color: var(--muted); font-variant-numeric: tabular-nums; }
.task .info { background: var(--bg); border-radius: var(--s-10); padding: var(--s-12) var(--s-14); }
.task .copy .btn { margin-top: var(--s-10); }
.task-img { display: block; text-decoration: none; font-size: var(--s-14); font-weight: 600; }
.task-img img { display: block; width: 100%; border-radius: var(--s-10); margin-bottom: var(--s-6); }
.url { font-size: var(--s-13); color: var(--muted); overflow-wrap: anywhere; margin-top: calc(-1 * var(--s-6)); }
.section { margin: var(--s-36) 0 0; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: var(--s-12); }
.dim { opacity: .6; }

/* admin */
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-16); flex-wrap: wrap; margin-bottom: var(--s-24); }
.summary { color: var(--muted); margin-top: var(--s-6); font-variant-numeric: tabular-nums; }
.summary b { color: var(--ink); }
.summary b.warn { color: var(--red); }
.head-actions { display: flex; gap: var(--s-8); }
.board { display: grid; gap: var(--s-20); grid-template-columns: repeat(auto-fill, minmax(var(--s-300), 1fr)); align-items: start; }
.instr-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-12); }
.status { font-size: var(--s-12); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding-top: var(--s-3); }
.status.live { color: var(--green); }
.status.live::before { content: ""; display: inline-block; width: var(--s-7); height: var(--s-7); border-radius: 50%; background: var(--green); margin-right: var(--s-6); vertical-align: 1px; }
.info-line { color: var(--muted); font-size: var(--s-14); margin-top: var(--s-6); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* the chain: post on top, comments below, one connected line */
.chain { list-style: none; margin: var(--s-18) 0 var(--s-16); padding: 0; }
.chain li { position: relative; padding: 0 0 var(--s-10) var(--s-30); }
.chain li:last-child { padding-bottom: 0; }
.chain li::before { content: ""; position: absolute; left: var(--s-4); top: var(--s-16); width: var(--s-13); height: var(--s-13); border-radius: 50%; background: var(--card); border: var(--s-2) solid var(--ink); z-index: 1; }
.chain li.post::before { background: var(--red); border-color: var(--red); }
.chain li.open::before { border-style: dashed; border-color: var(--red); background: var(--card); }
.chain li::after { content: ""; position: absolute; left: var(--s-9_5); top: var(--s-22); bottom: calc(-1 * var(--s-22)); width: var(--s-2); background: var(--line); }
.chain li:last-child::after { display: none; }
.node { display: grid; gap: var(--s-2); width: 100%; text-align: left; padding: var(--s-10) var(--s-12); border: 0; border-radius: var(--s-10); background: var(--bg); color: var(--ink); font: inherit; cursor: pointer; }
.node:hover { background: var(--btn); }
.node-top { display: flex; justify-content: space-between; gap: var(--s-8); font-size: var(--s-14); }
.who { font-size: var(--s-15); font-weight: 600; }
.open .who { color: var(--red); }
.snip { font-size: var(--s-13); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marks { display: flex; gap: var(--s-10); }
.marks i { font-style: normal; font-size: var(--s-12); color: var(--muted); }
.actions { display: flex; align-items: center; gap: var(--s-8); flex-wrap: wrap; }
.actions .spacer { flex: 1; }

/* modals */
dialog.modal { border: 0; border-radius: var(--s-16); padding: 0; width: min(var(--s-560), calc(100vw - var(--s-24))); max-height: calc(100dvh - var(--s-24)); box-shadow: 0 var(--s-24) var(--s-80) rgba(0, 0, 0, .3); color: var(--ink); }
dialog.modal::backdrop { background: rgba(28, 25, 23, .5); }
dialog.modal > form, dialog.modal > .modal-body { padding: var(--s-22); }
dialog header { position: relative; padding-right: var(--s-40); }
.x { position: absolute; top: calc(-1 * var(--s-6)); right: calc(-1 * var(--s-6)); width: var(--s-40); height: var(--s-40); border: 0; border-radius: 50%; background: none; font-size: var(--s-26); line-height: 1; color: var(--muted); cursor: pointer; }
.x:hover { background: var(--bg); color: var(--ink); }
dialog footer { display: flex; align-items: center; justify-content: space-between; gap: var(--s-12); margin-top: var(--s-22); }
.imgfield { margin-top: var(--s-14); }
.imgfield .preview { display: block; max-width: 100%; max-height: var(--s-200); border-radius: var(--s-10); margin-bottom: var(--s-8); }
.team { list-style: none; margin: var(--s-16) 0 0; padding: 0; }
.team li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: var(--s-8); padding: var(--s-10) 0; border-bottom: 1px solid var(--line); }
.team li div { display: grid; }
.add-user { margin-top: var(--s-22); }

@media (max-width: 560px) { /* ds-allow-hardcode: media queries cannot read variables */
  h1 { font-size: var(--s-24); }
  .top { padding: var(--s-10) var(--s-16); }
  .top-nav { gap: var(--s-12); font-size: var(--s-13); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .top-nav .name { display: none; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; }
  .team li { grid-template-columns: 1fr auto; }
  .team li div { grid-column: 1 / -1; }
}

/* done state */
.btn.dark { background: var(--ink); color: var(--white); }
.btn.dark:hover { background: var(--ink); opacity: .85; }
.when.late { color: var(--red); font-weight: 600; }
.when.ok, .marks i.ok { color: var(--green); font-weight: 600; }
.done-form { border-top: 1px solid var(--line); }
.done-form .muted { margin-top: var(--s-6); }
.done-form .btn { margin-top: var(--s-14); }
.done-box { display: flex; align-items: center; justify-content: space-between; gap: var(--s-12); border-top: 1px solid var(--line); padding-top: var(--s-14); }
.live-link { font-size: var(--s-13); overflow-wrap: anywhere; min-width: 0; }
.chain li.done::before { background: var(--green); border-color: var(--green); }
.status { white-space: nowrap; }
.grid2 .check { align-self: end; min-height: var(--s-42); margin: 0; }
.locked { background: var(--bg); border-radius: var(--s-10); padding: var(--s-12) var(--s-14); color: var(--muted); font-size: var(--s-14); }
.email-form { grid-column: 1 / -1; display: flex; gap: var(--s-8); }
.email-form input:not([type=checkbox]):not([type=file]) { margin-top: 0; }
.mail-state { margin-top: var(--s-16); }
.notes { list-style: none; margin: var(--s-8) 0 0; padding: 0; font-size: var(--s-13); color: var(--muted); }
.notes li { display: flex; justify-content: space-between; gap: var(--s-12); padding: var(--s-4) 0; }
.notes .ok { color: var(--green); font-weight: 600; }
/* applications */
.apply h3 { margin-top: var(--s-20); }
.apply .btn { width: 100%; margin-top: var(--s-20); }
.apply p { margin-top: var(--s-8); }
.hp { display: none; }
.apply-link { display: flex; align-items: center; justify-content: space-between; gap: var(--s-12); background: var(--bg); border-radius: var(--s-10); padding: var(--s-8) var(--s-8) var(--s-8) var(--s-14); margin-top: var(--s-6); font-size: var(--s-14); overflow-wrap: anywhere; }
.app-item { border-top: 1px solid var(--line); margin-top: var(--s-16); padding-top: var(--s-16); }
.app-item h3 { font-size: var(--s-16); display: inline; margin-right: var(--s-8); }
.app-item form { display: flex; justify-content: flex-end; gap: var(--s-12); margin-top: var(--s-12); }
dl.app { display: grid; grid-template-columns: auto 1fr; gap: var(--s-4) var(--s-12); margin: var(--s-8) 0 0; font-size: var(--s-14); }
dl.app dt { color: var(--muted); }
dl.app dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.profile { grid-column: 1 / -1; font-size: var(--s-14); }
.profile summary { cursor: pointer; color: var(--muted); }
.head-actions .warn { color: var(--red); }
