:root {
  --bg: #faf6ef;
  --panel: #ffffff;
  --ink: #23201c;
  --muted: #776f64;
  --line: #e6ddcf;
  --accent: #c8402c;
  --accent-ink: #ffffff;
  --keep: #2f7d4a;
  --keep-soft: #dcefe2;
  --delete: #b23a2a;
  --delete-soft: #f6dcd7;
  --undecided: #d8d0c3;
  --hover: #f3ece0;
  --selected: #fde9b8;
  --bar: #e8b84a;
  --shadow: 0 1px 3px rgba(40, 30, 10, .12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1916; --panel: #24211d; --ink: #efe9df; --muted: #a39a8c; --line: #3a352e;
    --keep: #5cbf7c; --keep-soft: #1f3a28; --delete: #e2705e; --delete-soft: #43231e;
    --undecided: #4a443b; --hover: #2e2a24; --selected: #4a3c17; --bar: #c99a2e; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
}
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 16px; background: #2b211a; color: #fff4dc; flex: none;
}
.brand { white-space: nowrap; display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none;
  font-weight: 800; font-size: 20px; letter-spacing: .5px; text-transform: uppercase; }
.brand img { border-radius: 50%; border: 2px solid #f2c94c; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.topbar-right form { margin: 0; }
.topbar-right button { background: transparent; color: inherit; border: 1px solid #806a52;
  border-radius: 6px; padding: 3px 10px; }

/* landing */
.landing { flex: 1; display: flex; align-items: center; justify-content: center; gap: 40px;
  padding: 24px 16px; flex-wrap: wrap; }
.landing-logo { width: min(420px, 90vw); height: auto; border-radius: 16px; box-shadow: var(--shadow); }
.landing-text { max-width: 460px; }
.landing-text h1 { font-size: 30px; margin: 0 0 8px; }
.landing-text li { margin: 6px 0; }
.orcid-button { display: inline-flex; align-items: center; gap: 10px; background: #a6ce39; color: #1d2a05;
  font-weight: 700; padding: 12px 20px; border-radius: 8px; text-decoration: none; font-size: 17px; border: 0; }
.orcid-button:hover { filter: brightness(1.05); }
.orcid-mark { background: #fff; color: #a6ce39; border-radius: 50%; width: 24px; height: 24px;
  display: inline-grid; place-items: center; font-size: 12px; font-weight: 900; }

/* app layout */
.app { flex: 1; display: grid; grid-template-columns: 300px 1fr; min-height: 0; }
.sidebar { border-right: 1px solid var(--line); background: var(--panel); overflow: auto; }
.sidebar-head { padding: 14px 14px 6px; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.sidebar h2 { margin: 0 0 8px; font-size: 16px; }
.filters { display: flex; gap: 4px; }
.filters button { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 999px;
  padding: 2px 10px; font-size: 13px; }
.filters button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.project-list { list-style: none; margin: 0; padding: 6px 8px 16px; }
.project-card { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--bg);
  color: inherit; border-radius: 10px; padding: 10px 12px; margin: 6px 0; text-decoration: none; }
.project-card:hover { border-color: var(--muted); }
.project-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.project-card .title { font-weight: 700; display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.project-card .title span:first-child { overflow-wrap: anywhere; }
.project-card .meta { font-size: 12px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.archive-group { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
  margin: 14px 4px 2px; overflow-wrap: anywhere; }
.pill { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.pill.todo { background: var(--delete-soft); color: var(--delete); }
.pill.in-progress { background: #fdf0c8; color: #8a6100; }
.pill.ready { background: var(--keep-soft); color: var(--keep); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.in-progress { background: #46391a; color: #f2c94c; } }

.workspace { overflow: auto; min-width: 0; }
.welcome { text-align: center; padding: 60px 16px; }
.welcome img { border-radius: 12px; }
#project { padding: 16px 20px 40px; }
.project-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: start; }
.project-head h1 { margin: 0; font-size: 24px; overflow-wrap: anywhere; }
.reviewers { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.reviewer { font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; background: var(--panel); }
.reviewer.done { border-color: var(--keep); color: var(--keep); }
.ready-box { text-align: right; }
.ready-box .ready-done { color: var(--keep); font-weight: 700; }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 9px 18px; font-weight: 700; }
.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; }
.linkish { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; font-size: 13px; }

/* summary */
.summary { margin: 14px 0 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.summary-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--undecided); }
.summary-bar div { height: 100%; }
.summary-bar .keep { background: var(--keep); }
.summary-bar .delete { background: var(--delete); }
.summary-text { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 6px; font-size: 14px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.dot.keep { background: var(--keep); } .dot.delete { background: var(--delete); } .dot.undecided { background: var(--undecided); }

/* tabs */
.tabs { display: flex; gap: 6px; align-items: center; border-bottom: 1px solid var(--line); margin-bottom: 10px; flex-wrap: wrap; }
.tab { border: 0; background: none; color: var(--muted); padding: 8px 12px; border-bottom: 3px solid transparent; font-weight: 600; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.count { background: var(--line); color: var(--ink); border-radius: 999px; padding: 0 7px; font-size: 12px; }
.search { margin-left: auto; padding: 4px 0; }
.search input { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px;
  padding: 6px 10px; width: 240px; max-width: 60vw; }

/* panes */
.panes { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.tree-pane, .detail-pane, .discussion { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.tree-pane { padding: 6px 0; min-width: 0; }
.tree-help { font-size: 12.5px; padding: 4px 12px 8px; border-bottom: 1px solid var(--line); }
.detail-pane { padding: 14px 16px; position: sticky; top: 0; max-height: calc(100vh - 80px); overflow: auto; min-width: 0; }

/* tree rows */
.row { display: grid; grid-template-columns: minmax(0, 1fr) 96px 168px 52px; align-items: center; gap: 8px;
  padding: 3px 10px; border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); cursor: pointer; }
.row:hover { background: var(--hover); }
.row.selected { background: var(--selected); }
.row.decided-delete .name-text { text-decoration: line-through; text-decoration-color: var(--delete); color: var(--muted); }
.name-cell { display: flex; align-items: center; gap: 4px; min-width: 0; }
.caret { width: 18px; flex: none; border: 0; background: none; color: var(--muted); padding: 0; font-size: 12px; }
.icon { flex: none; width: 18px; text-align: center; }
.name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warn { color: var(--delete); font-size: 12px; flex: none; }
.size-cell { font-size: 12px; color: var(--muted); text-align: right; position: relative; }
.size-bar { position: absolute; left: 0; bottom: -2px; height: 3px; background: var(--bar); border-radius: 2px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 2px 8px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on.keep { background: var(--keep); color: #fff; }
.seg button.on.delete { background: var(--delete); color: #fff; }
.seg button.inherited.keep { background: var(--keep-soft); color: var(--keep); }
.seg button.inherited.delete { background: var(--delete-soft); color: var(--delete); }
.mixed { font-size: 10px; color: #8a6100; margin-left: 4px; }
.badges { font-size: 12px; color: var(--muted); display: flex; gap: 6px; justify-content: flex-end; }
.badge-comments { color: var(--accent); font-weight: 700; }
.others { font-size: 11px; color: var(--muted); }
.more { padding: 6px 12px; font-size: 13px; }

/* detail */
.detail-pane h2 { margin: 0 0 2px; font-size: 18px; overflow-wrap: anywhere; }
.detail-path { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; margin-bottom: 8px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13px; margin: 8px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.detail-pane h3 { font-size: 14px; margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.sensitive { background: var(--delete-soft); color: var(--delete); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.decision-big { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.decision-big .seg button { font-size: 14px; padding: 5px 14px; }
.annotation { font-size: 13px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.annotation .key { font-weight: 700; }
.annotation .by { color: var(--muted); font-size: 12px; }
.annotation-form { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.annotation-form select, .annotation-form input { border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 6px; padding: 4px 6px; font-size: 13px; }
.annotation-form input { flex: 1; min-width: 120px; }

.comment { border-left: 3px solid var(--line); padding: 4px 10px; margin: 8px 0; }
.comment.mine { border-left-color: var(--accent); }
.comment .head { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.comment .author { font-weight: 700; color: var(--ink); }
.comment .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.comment .where { font-size: 12px; }
.composer textarea, dialog textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px;
  background: var(--bg); color: var(--ink); font: inherit; resize: vertical; }
.composer .composer-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; gap: 8px; }
.composer .hint { font-size: 12px; color: var(--muted); }

.preview { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-height: 420px; overflow: auto; font-size: 13px; background: var(--bg); }
.preview pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 8px; font-size: 12px; }
.preview img { max-width: 100%; height: auto; }
.preview .nb-in { background: var(--hover); padding: 6px; border-radius: 4px; }
.preview .md h1, .preview .md h2, .preview .md h3 { font-size: 15px; }
.preview table { border-collapse: collapse; } .preview td, .preview th { border: 1px solid var(--line); padding: 2px 6px; }

/* discussion */
.discussion { padding: 10px 16px; }
.discussion .comment { cursor: pointer; }
.discussion .comment:hover { background: var(--hover); }

.search-results { border-bottom: 1px solid var(--line); padding: 6px 0; }
.search-results .row { grid-template-columns: minmax(0, 1fr) 96px; }

/* dialog, toast */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); max-width: 480px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog label { display: block; font-size: 14px; margin-top: 8px; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 8px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; font-size: 14px; }
.toast.show { opacity: .95; }
.chip { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 1px 7px; color: #fff; }
.chip.keep { background: var(--keep); } .chip.delete { background: var(--delete); }

/* message page */
.message-page { align-items: center; justify-content: center; }
.message { max-width: 520px; text-align: center; padding: 24px 16px; }
.message-logo { width: 180px; border-radius: 12px; }

/* narrow screens */
@media (max-width: 900px) {
  #whoami > span:first-child { display: none; }
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .panes { grid-template-columns: 1fr; }
  .detail-pane { position: static; max-height: none; }
  .row { grid-template-columns: minmax(0, 1fr) 64px 120px; }
  .badges { display: none; }
  #project { padding: 12px 16px 32px; }
  .search { margin-left: 0; width: 100%; } .search input { width: 100%; max-width: none; }
}
