:root {
  color-scheme: light dark;
  --page: #f4f5f7;
  --surface: #ffffff;
  --sunken: #eef0f3;
  --line: #d9dde3;
  --text: #1c2128;
  --muted: #647081;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --new: #c2410c;
  --wait: #a16207;
  --go: #1d6fb8;
  --good: #1a7f4b;
  --off: #6b7280;
  --bad: #b42318;
  --note: #fff7d6;
  --theirs: #e8f0fe;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #14171c;
    --surface: #1d2127;
    --sunken: #262b33;
    --line: #353b45;
    --text: #e6e9ee;
    --muted: #98a2b1;
    --accent: #6ea0f5;
    --accent-text: #10151d;
    --new: #fb923c;
    --wait: #facc15;
    --go: #7cc0f5;
    --good: #5fd08f;
    --off: #9aa3b0;
    --bad: #f97066;
    --note: #3a3418;
    --theirs: #1f2c44;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--page); color: var(--text); }
#root { height: 100%; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--bad); }
button.plain { border-color: transparent; background: none; color: var(--muted); }
button:disabled { opacity: 0.5; cursor: default; }
input, select, textarea {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 7px;
  padding: 6px 9px;
  min-width: 0;
}
textarea { width: 100%; resize: vertical; min-height: 70px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Sign in */
.signin { margin: auto; width: min(360px, calc(100% - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: grid; gap: 12px; }
.signin h1 { font-size: 20px; }
.signin p { color: var(--muted); }
.error { color: var(--bad); }

/* Top bar */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.bar h1 { font-size: 17px; margin-right: 4px; }
.bar .search { flex: 1 1 160px; max-width: 320px; }
.bar .spacer { flex: 1; }
.views { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.views button { border: 0; border-radius: 0; background: none; padding: 6px 11px; color: var(--muted); white-space: nowrap; }
.views button + button { border-left: 1px solid var(--line); }
.views button[aria-pressed="true"] { background: var(--sunken); color: var(--text); font-weight: 600; }
.count { display: inline-block; min-width: 1.5em; margin-left: 5px; padding: 0 5px; border-radius: 9px; background: var(--new); color: #fff; font-size: 12px; font-weight: 600; text-align: center; }
.count.quiet { background: var(--line); color: var(--text); }

/* The two panes */
main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 400px) 1fr; }
.list { overflow-y: auto; border-right: 1px solid var(--line); background: var(--surface); }
.detail { overflow-y: auto; padding: 20px 24px 60px; }
.empty { color: var(--muted); padding: 40px 20px; text-align: center; }

.row { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 10px 14px 10px 18px; background: none; position: relative; }
.row:hover { background: var(--sunken); }
.row[aria-current="true"] { background: var(--sunken); box-shadow: inset 3px 0 0 var(--accent); }
.row.unread::before { content: ""; position: absolute; left: 6px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--new); }
.row .top { display: flex; gap: 8px; align-items: baseline; }
.row .summary { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.fresh .summary { font-weight: 600; }
.row .age { color: var(--muted); font-size: 12px; white-space: nowrap; }
.row .under { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; color: var(--muted); font-size: 12px; }
.more { display: block; margin: 12px auto; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.pill.s-new, .pill.s-reopened { color: var(--new); }
.pill.s-reviewed, .pill.s-needs_info { color: var(--wait); }
.pill.s-planned, .pill.s-in_progress { color: var(--go); }
.pill.s-done { color: var(--good); }
.pill.s-closed { color: var(--off); }
.pill.decision { color: var(--text); border-color: var(--line); background: var(--sunken); }
.chip { display: inline-block; padding: 0 7px; border-radius: 5px; background: var(--sunken); color: var(--text); font-size: 12px; }

/* One report */
.detail > * + * { margin-top: 18px; }
.head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.head h2 { font-size: 18px; margin-right: auto; }
.back { display: none; }
.said { font-size: 17px; white-space: pre-wrap; overflow-wrap: anywhere; }
.said.none { color: var(--muted); font-size: 15px; }
.alert { padding: 8px 12px; border-radius: 8px; background: var(--theirs); display: flex; gap: 10px; align-items: center; }
.alert span { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.card > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 10px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.linkish { border: 0; padding: 0; background: none; color: var(--accent); text-align: left; }
pre.data { margin: 0; overflow-x: auto; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.files { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.files img { display: block; max-width: 220px; max-height: 220px; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; }
.files audio { max-width: 100%; }
.files figure { margin: 0; }
.files figcaption { color: var(--muted); font-size: 12px; margin-top: 3px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.events li { display: grid; gap: 4px; }
.events .what { color: var(--muted); font-size: 13px; }
.events .what b { color: var(--text); font-weight: 600; }
.bubble { padding: 8px 12px; border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 640px; }
.bubble.team { background: var(--sunken); }
.bubble.reporter { background: var(--theirs); }
.bubble.note { background: var(--note); border: 1px dashed var(--line); }

.answer { display: grid; gap: 12px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
label.field { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
label.field > * { color: var(--text); font-size: 15px; }
label.check { display: flex; gap: 8px; align-items: center; }
.hint { color: var(--muted); font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions .spacer { flex: 1; }

/* Apps */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); padding: 20px; width: min(640px, calc(100% - 24px)); }
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h2 { font-size: 18px; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 600; }
td.num, th.num { text-align: right; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.addapp { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.addapp input { flex: 1 1 140px; }
.addtoken { display: grid; gap: 8px; margin-top: 14px; }
.addtoken .addapp { margin-top: 0; }
dialog .alert { margin-bottom: 12px; }
dialog .alert code { overflow-wrap: anywhere; }

.lightbox { position: fixed; inset: 0; background: rgb(0 0 0 / 0.85); display: grid; place-items: center; cursor: zoom-out; z-index: 10; }
.lightbox img { max-width: 96vw; max-height: 96vh; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--page); padding: 8px 16px; border-radius: 8px; z-index: 20; max-width: calc(100% - 32px); }

@media (max-width: 820px) {
  main { grid-template-columns: 1fr; }
  .list { border-right: 0; }
  .detail { display: none; padding: 16px 16px 60px; }
  body.reading .list { display: none; }
  body.reading .detail { display: block; }
  .back { display: inline-block; }
  .bar { padding: 8px 16px; }
  .bar .search { max-width: none; flex-basis: 100%; }
}

[hidden] { display: none !important; }

dialog table { display: block; overflow-x: auto; }
