/* Tokens from DESIGN.md. Dark only. */
:root {
  --canvas: #11120F;
  --surface-1: #1B1D16;
  --surface-2: #2B2D1D;
  --surface-3: #3F4129;
  --border: #3F4129;
  --border-muted: #24261B;
  --ink: #EBE6D8;
  --ink-muted: #A9AB9F;
  --primary: #D2DDD3;
  --on-primary: #11120F;
  --approved: #7FB89A;
  --approved-border: #5A8F74;
  --approved-fill: #121E18;
  --waiting: #D9A441;
  --waiting-fill: #231C0C;
  --danger: #E06D53;
  --danger-fill: #22120F;
  --frozen: #8D928D;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Space Grotesk", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 14px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 12px 96px;
}

h1, h2, h3 {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 24px 0 8px;
}
h1 { font-size: 22px; line-height: 1.25; margin-top: 0; }
h1.title-row { display: flex; flex-wrap: nowrap; align-items: flex-start; gap: 8px; }
h1.title-row .title-main { flex: 1; min-width: 0; }
h1.title-row .title-main:has(.title-text) { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
h1.title-row .title-text { display: block; }
h1.title-row .title-sub { display: block; }
h1.title-row .title-sub .pill { margin: 0; }
h1.title-row .pill { flex: none; }
h1.title-row:has(.title-text) .title-actions {
  align-self: flex-start;
  align-items: center;
  gap: 0;
  height: 1.25em;
  line-height: 1.25;
}
h1.title-row .title-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0;
  margin-left: auto;
}
h1.title-row .title-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  font-size: inherit;
  min-width: 2em;
  width: 2em;
  min-height: 1.25em;
  height: 1.25em;
  padding: 0;
  color: var(--ink-muted);
  text-decoration: none;
}
h1.title-row:has(.title-text) .title-action {
  min-width: 1.35em;
  width: 1.35em;
}
h1.title-row .title-action:hover { color: var(--ink); }
h1.title-row .title-action svg { width: 1em; height: 1em; }
h1.title-row .title-main:not(:has(.title-text)) + .title-actions .title-action {
  min-width: 44px;
  width: 44px;
  min-height: 44px;
  height: 44px;
}
h1.title-row .title-main:not(:has(.title-text)) + .title-actions .title-action svg {
  width: 24px;
  height: 24px;
}
h2 { font-size: 17px; line-height: 1.3; }
h3 { font-size: 14px; }

h2.label, .label {
  font: 600 11px/1.3 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
h2.label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 24px 0 8px; }

.meta, time, code {
  font: 400 11px/1.3 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
}
code { font-size: 13px; color: var(--ink); }

a { color: var(--primary); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

ul { padding-left: 20px; }

/* Fields: 16px so an iPhone does not zoom. */
input, select, textarea {
  font: 400 16px/1.4 var(--sans);
  color: var(--ink);
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: 4px;
  min-height: 44px;
  padding: 10px 12px;
  max-width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; }
input[type=checkbox], input[type=radio] { min-height: 0; width: 20px; height: 20px; accent-color: var(--primary); vertical-align: middle; }
textarea { width: 100%; max-width: 100%; min-height: 88px; }
select[multiple] { width: 100%; }
label { display: inline-block; }
[hidden] { display: none !important; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 16px;
  font: 700 14px/1 var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
button:hover, .button:hover { background: var(--surface-2); }
button.primary, .button.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
button.danger, .button.danger, button[value=refuse], button[value=deny] {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
button.danger:hover, .button.danger:hover, button[value=refuse]:hover, button[value=deny]:hover { background: var(--danger-fill); }

/* Header and tabs */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 12px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.wordmark {
  font: 400 22px/1.2 "Black Ops One", var(--sans);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}
.top-right { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.top a.username {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font: 600 11px/1.3 var(--mono);
  color: var(--ink-muted);
  text-decoration: none;
}
.top a.username:hover { color: var(--ink); }
.top .signout { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 4px; color: var(--ink-muted); text-decoration: none; font: 600 11px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: space-around;
  min-height: 56px;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface-1);
  border-top: 1px solid var(--border);
}
.tabs a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 56px;
  color: var(--ink-muted);
  text-decoration: none;
  font: 600 11px/1.3 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-top: 2px solid transparent;
}
.tabs a[aria-current=page] { color: var(--primary); border-top-color: var(--primary); }
.tabs .icon { position: relative; display: inline-flex; }
.tabs .count {
  position: absolute;
  top: -6px;
  right: -12px;
  min-width: 18px;
  padding: 1px 4px;
  font: 700 11px/1.3 var(--mono);
  text-align: center;
  color: var(--on-primary);
  background: var(--waiting);
  border-radius: 9999px;
}
svg { fill: currentColor; width: 20px; height: 20px; flex: none; }

/* Cards, pills, lists */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  margin: 0 0 8px;
}
.card .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card p { margin: 0 0 8px; }
.card form { margin: 8px 0 0; }
.card form p { margin: 0 0 8px; }
.card .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.card .actions > *, .card .actions form button { flex: 1; }
.card .actions form { margin: 0; flex: 1; display: flex; }
.card label { display: block; }
.card label input:not([type=checkbox]):not([type=radio]) { display: block; width: 100%; margin-top: 4px; }

.pill {
  display: inline-block;
  padding: 2px 6px;
  font: 600 11px/1.3 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink-muted);
}
.pill.waiting { color: var(--waiting); background: var(--waiting-fill); border-color: var(--waiting); }
.pill.danger { color: var(--danger); background: var(--danger-fill); border-color: var(--danger); }
.pill.approved { color: var(--approved); background: var(--approved-fill); border-color: var(--approved-border); }
.pill.frozen { color: var(--frozen); }

.rows {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.rows li + li { border-top: 1px solid var(--surface-2); }
.rows a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 12px;
  color: var(--ink);
  text-decoration: none;
}
.rows a:hover { background: var(--surface-2); }
.rows button.file-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 44px;
  padding: 12px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0;
  text-transform: none;
  letter-spacing: normal;
  font: inherit;
}
.rows button.file-row:hover { background: var(--surface-2); }
.rows button.file-row .meta { display: block; font: 400 11px/1.3 var(--mono); color: var(--ink-muted); }
.library-full form.stack { margin-top: 16px; }
.quicklook {
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-1);
  color: var(--ink);
}
.quicklook::backdrop { background: rgba(0, 0, 0, 0.72); }
.quicklook form { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); }
.quicklook-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.quicklook-head .title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quicklook-head .title-action { margin-left: auto; min-width: 44px; min-height: 44px; font-size: 28px; line-height: 1; }
.quicklook-body {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  padding: 12px;
}
.quicklook-body img,
.quicklook-body iframe { display: block; width: 100%; max-height: 70dvh; margin: 0 auto; border: 0; }
.quicklook-body pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 400 12px/1.4 var(--mono); }
.rows .title { font-weight: 600; }
.rows svg { color: var(--ink-muted); }

.empty { color: var(--ink-muted); margin: 0 0 8px; }

/* Forms with labels above fields */
form.stack label { display: block; margin: 0 0 12px; }
form.stack label input:not([type=checkbox]):not([type=radio]), form.stack select, form.stack textarea { display: block; width: 100%; margin-top: 4px; }
form.stack h3 { font: 600 11px/1.3 var(--mono); letter-spacing: 0.08em; color: var(--ink-muted); margin: 16px 0 8px; }
form.stack p { margin: 0; }
form.stack button { width: 100%; }

.rows li.other { padding: 12px; }
.rows li.other .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rows li.other p { margin: 4px 0 8px; color: var(--ink-muted); }
.rows li.other summary { list-style: none; cursor: pointer; }
.rows li.other summary::-webkit-details-marker { display: none; }
.rows li.other summary .head { justify-content: flex-start; }
.rows li.other summary .head .pill { margin-left: auto; }
.rows li.other summary .head::after { content: "+"; font: 600 17px/1 var(--mono); color: var(--ink-muted); }
.rows li.other details[open] summary .head::after { content: "\2212"; }
.rows li.other details[open] form { margin-top: 4px; }
.rows .pill { margin-left: 4px; vertical-align: 1px; }
.rows a .meta { display: block; margin-top: 2px; }

.note { padding: 8px; border: 1px solid; border-radius: 4px; font: 400 11px/1.3 var(--mono); }
.rows li.other p.note.waiting { color: var(--waiting); background: var(--waiting-fill); border-color: var(--waiting); }
.rows li.other p.note.danger { color: var(--danger); background: var(--danger-fill); border-color: var(--danger); }
.error { color: var(--danger); background: var(--danger-fill); border: 1px solid var(--danger); border-radius: 4px; padding: 8px 12px; }

/* Effort screen and room */
.button.wide { display: flex; width: 100%; }

/* Public front page and sign-in: no app header or tabs */
main.gate { max-width: 420px; padding: 48px 16px 48px; }
.gate-head { margin: 0 0 32px; text-align: center; }
.gate-head .wordmark { display: block; font-size: 34px; margin: 0 0 12px; }
.gate-head .lede { margin: 0; color: var(--ink-muted); }
.gate h1 { margin: 0 0 16px; }
.gate h2 { margin: 32px 0 12px; }
.gate .error { margin: 0 0 12px; }
.gate .aside { margin: 16px 0 0; color: var(--ink-muted); }
.gate details.compose { margin: 24px 0 0; }
/* Request to join folds the sign-in block away; the same summary reads Sign in to fold it back. */
main.gate:has(details.compose[open]) .signin { display: none; }
.gate details.compose[open] { margin-top: 0; }
.gate details.compose[open] > summary { margin-bottom: 16px; }
.gate details.compose:not([open]) .when-open, .gate details.compose[open] .when-closed { display: none; }
.overview > .title {
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 16px;
}
.overview h3 { font: 600 11px/1.3 var(--mono); letter-spacing: 0.08em; color: var(--ink-muted); margin: 0 0 4px; }
.privacy { margin: 0 0 12px; border: 0; padding: 0; }
.privacy .label { margin: 0 0 8px; }
.privacy .toggle { display: flex; gap: 8px; }
.privacy .toggle .button { flex: 1; }
.privacy .toggle .button.selected {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}
.privacy .toggle .button:not(.selected):hover { background: var(--surface-2); }
.overview p { margin: 0 0 12px; white-space: pre-wrap; }
.overview form { margin: 0 0 12px; }
details.edit > summary { list-style: none; width: 100%; }
details.edit > summary::-webkit-details-marker { display: none; }
details.edit[open] > summary { margin-bottom: 12px; }
.effort-edit button[type=submit] { width: 100%; }
.effort-edit .spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-left: 8px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -0.15em;
}
.effort-edit .spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.rows li.person { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; }
.rows li.person > span:first-child, .rows li.person > .title { flex: 1; min-width: 0; }
.rows li.person .meta { display: block; }
.rows li.person form { margin: 0; }
.rows li.person select { min-width: 0; width: 9.5em; }
.rows li.empty { padding: 12px; }
label.find { display: block; margin: 0 0 8px; }
label.find input { display: block; width: 100%; margin-top: 4px; }
form.leave { margin: 32px 0 0; }
form.leave button { width: 100%; }
#messages { list-style: none; margin: 0 0 16px; padding: 0; }
#messages li.message {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  margin: 0 0 8px;
}
#messages li.message:has(.message-marking.sensitive) { border-color: var(--waiting); }
#messages li .message-head { margin: 0; }
#messages li .message-head > p { margin: 0; font-size: 10px; line-height: 1.3; }
#messages li .message-head strong { font: 400 10px/1.3 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; }
#messages li .message-head strong > span { white-space: nowrap; }
#messages li.message:has(.msg-menu) .message-head > p { padding-right: 24px; }
#messages li .who-raf { color: #8CC4F0; }
#messages li .who-rn { color: #6F8FD8; }
#messages li .who-army { color: #8FBF6A; }
#messages li .who-industry { color: var(--ink-muted); }
#messages li .message-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
#messages li .message-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  font: 400 9px/1.3 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
}
#messages li .message-when { flex: 1; min-width: 0; font: inherit; }#messages li .message-marking {
  flex: none;
  text-align: right;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
#messages li .message-marking.sensitive { font-weight: 600; color: var(--waiting); }
#messages li.message .msg-menu {
  position: absolute;
  top: 2px;
  right: 4px;
  margin: 0;
}
#messages .msg-menu > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: 4px;
}
#messages .msg-menu > summary::-webkit-details-marker { display: none; }
#messages .msg-menu > summary:hover { color: var(--ink); background: var(--surface-2); }
#messages .msg-menu > summary svg { width: 14px; height: 14px; }
#messages .msg-menu-panel {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 5;
  min-width: 9.5em;
  margin-top: 2px;
  padding: 4px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
#messages .msg-menu-panel button {
  display: flex;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 12px;
  justify-content: flex-start;
  background: transparent;
  border: 0;
}
#messages .msg-menu-panel button:hover { background: var(--surface-2); }
#messages .msg-menu-panel button.danger { color: var(--danger); }

/* Chatroom: title fixed in main column; messages scroll; composer above tab bar */
body.chat {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
body.chat main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: 16px;
  padding-bottom: calc(56px + env(safe-area-inset-bottom));
}
body.chat h1.title-row { flex: none; margin-bottom: 8px; }
body.chat .chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
body.chat #room {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
body.chat #room-note { flex: none; margin: 0 0 8px; }
body.chat .chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
body.chat .chat-messages #messages { margin: 0; padding-bottom: 8px; }
body.chat .chat-composer {
  flex: none;
  margin: 0 -12px;
  padding: 12px 12px 8px;
  background: var(--canvas);
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.45);
}
body.chat #composer label { display: block; width: 100%; }
body.chat #composer textarea {
  resize: none;
  width: 100% !important;
  max-width: 100%;
  min-height: 88px;
  height: auto !important;
  box-sizing: border-box;
}
body.chat #composer.sensitive { border-top-color: var(--waiting); }
body.chat #composer.sensitive textarea { border-color: var(--waiting); }
#composer button { width: auto; }
#composer .composer-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
#composer .marking { display: contents; }
#composer .lifespan {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin-top: 4px;
  width: 100%;
}
#composer .lifespan[hidden] { display: none; }
#composer .lifespan .chip {
  flex: 1 1 0;
  min-width: 0;
  min-height: 34px;
  height: 34px;
  max-height: 34px;
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  font: 600 9px/1 var(--mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: var(--canvas);
}
#composer .lifespan .chip[data-life=indefinite] {
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
  overflow: visible;
}
#composer .composer-row .chip,
#composer .composer-row > button[type=submit] {
  min-height: 34px;
  height: 34px;
  max-height: 34px;
  white-space: nowrap;
  overflow: hidden;
  font: 600 9px/1 var(--mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
#composer .composer-row .chip {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 6px;
  color: var(--ink-muted);
  background: var(--canvas);
}
#composer .composer-row > button[type=submit].primary {
  flex: 0 0 auto;
  min-width: 3.75em;
  padding: 0 12px;
  font-weight: 700;
  color: var(--on-primary);
  background: var(--primary);
  border-color: var(--primary);
}
#composer .composer-row button[type=submit].primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
#composer .chip.selected { color: var(--ink); background: var(--surface-3); border-color: var(--ink-muted); }
#composer .chip[data-marking=OFFICIAL-SENSITIVE].selected,
#composer .lifespan .chip.selected { color: var(--waiting); background: var(--waiting-fill); border-color: var(--waiting); }
#composer .chip:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-locked .note.waiting { margin: 0 0 8px; color: var(--waiting); background: var(--waiting-fill); border-color: var(--waiting); }
.chat-locked form.decide p { margin: 0 0 8px; }
.chat-locked form.decide label { display: block; }
.chat-locked form.decide input { display: block; width: 100%; margin-top: 4px; }
.chat-locked form.decide button[value=approve] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
#messages li.gone, #messages li.history-start {
  margin: 0 0 8px;
  padding: 4px 0;
  font: 400 11px/1.3 var(--mono);
  color: var(--frozen);
  text-align: center;
}
#messages li.history-start { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
details.compose { margin: 16px 0; }
details.compose > summary { list-style: none; width: 100%; }
details.compose > summary::-webkit-details-marker { display: none; }
details.compose[open] > summary { margin-bottom: 12px; background: var(--surface-3); color: var(--ink); border-color: var(--border); }
