:root {
  --bg: #f6f7f9; --panel: #fff; --line: #e3e6ea; --text: #1d2025; --muted: #6b7280;
  --accent: #0b72e7; --accent-d: #075bbd; --ok: #2f9e44; --warn: #d9480f; --bad: #e5484d;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text); background: var(--bg); font-size: 14px; letter-spacing: 0;
}
* { box-sizing: border-box; }
body { margin: 0; }
h2 { font-size: 20px; margin: 0 0 16px; }
h3 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.ic { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { background: #eef1f4; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
input, textarea, select { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: #fff; width: 100%; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--text); font: inherit; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: #c5cad1; background: #f9fafb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-d); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.small { height: 28px; padding: 0 8px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: #eef1f4; color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: #fff; height: 30px; min-width: 34px; padding: 0 10px; cursor: pointer; font: inherit; color: var(--muted); display: grid; place-items: center; }
.seg button.on { background: #e8f1fd; color: var(--accent); }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #eef1f4; color: var(--muted); white-space: nowrap; }
.pill.clarifying { background: #fff1e6; color: var(--warn); }
.pill.ready { background: #e6f6ea; color: var(--ok); }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); white-space: nowrap; }
.badge { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700; flex: none; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-box h1 { margin: 0; font-size: 22px; }
.login-box p { margin: 0 0 6px; }

/* layout */
.layout { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; padding: 14px; height: 100vh; position: sticky; top: 0; }
.brand { font-weight: 700; font-size: 16px; padding: 0 0 4px 2px; display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 32px; }
.nav .lbl { overflow: hidden; text-overflow: ellipsis; }
/* collapsed sidebar: icon rail */
.layout { transition: grid-template-columns .15s; }
.layout.collapsed { grid-template-columns: 60px minmax(0, 1fr); }
.collapsed .side { padding: 14px 8px; align-items: center; }
.collapsed .side .lbl, .collapsed .search, .collapsed .tasks { display: none; }
.collapsed .brand { justify-content: center; padding: 0 0 4px; }
.collapsed .btn.block { width: 36px; padding: 0; }
.collapsed .side-nav { margin-top: auto; width: 100%; align-items: center; }
.collapsed .nav { justify-content: center; width: 40px; }
.search { flex-direction: row; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; color: var(--muted); }
.search input { border: 0; padding: 7px 0; outline: none; }
.tasks { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.tasks a { display: flex; flex-direction: column; gap: 4px; padding: 8px; border-radius: 6px; color: inherit; text-decoration: none; }
.tasks a:hover { background: #f3f5f7; }
.tasks a.on { background: #e8f1fd; }
.t-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-meta { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.t-meta span { display: inline-flex; align-items: center; gap: 2px; }
.owner { margin-left: auto; }
.pad { padding: 8px; }
.side-nav { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.nav { display: flex; align-items: center; gap: 8px; border: 0; background: none; text-align: left; padding: 8px; border-radius: 6px; cursor: pointer; font: inherit; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav:hover, .nav.on { background: #f3f5f7; }
.main { min-width: 0; }
.main-inner { padding: 20px 24px 40px; max-width: 1440px; }
.main-inner.narrow { max-width: 820px; }
.empty { display: grid; place-items: center; gap: 12px; min-height: 60vh; text-align: center; }

/* task */
.task-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.title-input { font-size: 18px; font-weight: 600; border-color: transparent; background: transparent; padding: 6px 8px; }
.title-input:hover { border-color: var(--line); }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.panel.stack, .stack { display: flex; flex-direction: column; gap: 12px; }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.shot { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.shot-img { border: 0; padding: 0; background: #f3f5f7; cursor: zoom-in; aspect-ratio: 16 / 10; display: block; width: 100%; }
.shot-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.shot figcaption { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; font-size: 13px; }
.shot figcaption .muted { flex: 1; font-size: 12px; }
.shot.add { align-items: center; justify-content: center; gap: 6px; min-height: 150px; border-style: dashed; color: var(--muted); cursor: pointer; text-align: center; padding: 10px; }
.shot.add:hover { border-color: var(--accent); color: var(--accent); }
.mark-list { list-style: none; margin: 0; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.mark-list li { display: flex; gap: 6px; align-items: flex-start; overflow-wrap: anywhere; }

.understand { margin: 0 0 14px; line-height: 1.6; background: #f6f9fe; border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 4px; }
.q { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; }
.q legend { padding: 0 4px; font-weight: 600; }
.opt { flex-direction: row; align-items: flex-start; gap: 8px; color: var(--text); font-size: 14px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.opt:hover { background: #f6f7f9; }
.opt input { width: auto; margin-top: 3px; }
.rec { font-style: normal; font-size: 11px; color: var(--ok); background: #e6f6ea; padding: 0 6px; border-radius: 8px; margin-left: 6px; }
.qx { font-size: 13px; padding: 6px 8px; }

/* Brief column matches the left column height; long content scrolls inside the card. */
.col-brief { align-self: stretch; min-height: 560px; }
.brief { position: sticky; top: 16px; height: min(100%, calc(100vh - 32px)); min-height: 560px; display: flex; flex-direction: column; }
.empty-brief .muted { margin: auto 0; text-align: center; padding: 0 24px; line-height: 1.7; }
.brief-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brief-head h3 { margin: 0; }
.brief-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.brief-actions .btn.ghost { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.md { flex: 1; min-height: 0; overflow: auto; line-height: 1.65; border-top: 1px solid var(--line); padding-top: 4px; overflow-wrap: anywhere; }
.md h2 { font-size: 18px; margin: 14px 0 8px; }
.md h3 { font-size: 15px; margin: 16px 0 6px; display: block; }
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md ul.checks { list-style: none; padding-left: 4px; }
.md .box { display: inline-block; width: 13px; height: 13px; border: 1.5px solid #9aa1ab; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.md .box.on { background: var(--ok); border-color: var(--ok); }
.brief-edit { flex: 1; min-height: 200px; resize: none; font-family: ui-monospace, Menlo, monospace; font-size: 13px; margin-bottom: 10px; }

/* admin */
.form-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 10px; align-items: end; margin-bottom: 16px; }
.form-row h3 { grid-column: 1 / -1; margin: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
.table th { font-weight: 500; color: var(--muted); font-size: 12px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.code-block { background: #1d2025; color: #e8eaed; padding: 12px; border-radius: 6px; font-size: 12px; overflow: auto; white-space: pre; margin: 0; }

/* annotator */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 18, 22, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 8px; width: min(1400px, 100%); height: min(900px, 100%); display: flex; flex-direction: column; overflow: hidden; }
.annot-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.annot-title { margin-right: 6px; }
.spacer { flex: 1; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: var(--c); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--c); }
.annot-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: 0; }
.annot-stage { background: #eceff2; display: grid; place-items: center; overflow: auto; min-height: 0; }
.annot-stage canvas { cursor: crosshair; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.15); touch-action: none; }
.annot-notes { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.notes-head { padding: 10px 12px; font-weight: 600; border-bottom: 1px solid var(--line); }
.notes { list-style: none; margin: 0; padding: 10px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.notes li { display: flex; gap: 6px; align-items: flex-start; }
.notes textarea { font-size: 13px; padding: 6px 8px; }
.notes .badge { margin-top: 6px; }
.notes-empty { color: var(--muted); line-height: 1.6; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #1d2025; color: #fff; padding: 9px 16px; border-radius: 6px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: min(560px, 90vw); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--bad); }

@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr; }
  .col-brief { min-height: 0; }
  .brief { position: static; max-height: 80vh; }
  .brief-edit { min-height: 420px; }
}
@media (max-width: 760px) {
  .layout, .layout.collapsed { grid-template-columns: 1fr; }
  .collapsed .side { flex-direction: row; align-items: center; justify-content: space-between; }
  .collapsed .side-nav { flex-direction: row; margin-top: 0; width: auto; border-top: 0; padding-top: 0; }
  .side { position: static; height: auto; max-height: 50vh; }
  .main-inner { padding: 14px; }
  .form-row { grid-template-columns: 1fr; }
  .annot-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 40%; }
  .annot-notes { border-left: 0; border-top: 1px solid var(--line); }
}
