:root {
  color-scheme: light dark;
  --bg: #f6f6f3;
  --panel: #fff;
  --panel-2: #fbfbf9;
  --ink: #1d1d1b;
  --muted: #74746e;
  --line: #e5e4df;
  --accent: #2f6fed;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --warn: #c47a12;
  --warn-soft: #fdf1dd;
  --work: #2f6fed;
  --work-soft: #e8f0ff;
  --review: #7a4bd6;
  --review-soft: #f1ebff;
  --ok: #267a4b;
  --ok-soft: #e5f5ec;
  --bad: #b23b3b;
  --shadow: 0 10px 30px rgb(0 0 0 / 8%);
  --r: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --panel: #1d1d1b;
    --panel-2: #232321;
    --ink: #eeece7;
    --muted: #9b9a93;
    --line: #34342f;
    --accent: #6f9bff;
    --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
    --warn: #e5a84e;
    --warn-soft: #3b2f1c;
    --work: #6f9bff;
    --work-soft: #1e2b45;
    --review: #b99bff;
    --review-soft: #2d2440;
    --ok: #74c99a;
    --ok-soft: #1c3326;
    --bad: #f08a8a;
    --shadow: 0 10px 30px rgb(0 0 0 / 35%);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hide { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
:where(button, input, textarea, select, a, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 22px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .mark {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 9px;
  background: var(--ink); color: var(--panel); font-size: 17px;
}
.brand strong { font-size: 15px; letter-spacing: .2px; white-space: nowrap; }
.brand .sub { color: var(--muted); font-size: 12px; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.conn { color: var(--ok); font-size: 12px; }
.conn.off { color: var(--bad); }

.primary, .ghost, .icon, .chip {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 9px;
  padding: 7px 12px;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .06s;
}
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { filter: brightness(1.05); }
.ghost:hover, .icon:hover, .chip:hover { background: var(--panel-2); }
.icon { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px; line-height: 1; }
button:active { transform: translateY(1px); }
button:disabled { cursor: default; opacity: .45; }
.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }

.shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  gap: 18px;
  max-width: 1460px;
  margin: 0 auto;
  padding: 18px 22px 60px;
  align-items: start;
}
.rail {
  position: sticky; top: 72px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - 92px);
  overflow: auto;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 1px 0 rgb(0 0 0 / 2%);
}
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 1px 2px; }
.rail-title { color: var(--muted); font-size: 11.5px; font-weight: 650; letter-spacing: .09em; }
.rail-tools { display: flex; align-items: center; gap: 6px; }
.rail-count {
  min-width: 20px; padding: 1px 6px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--muted); font-size: 10.5px; text-align: center;
}
.rail-count:empty { display: none; }
.rail-search input { padding: 7px 10px; font-size: 12.5px; }
.projects { display: grid; gap: 3px; }
.project-row {
  display: flex; align-items: stretch; gap: 1px;
  min-width: 0; padding: 2px;
  border-radius: 10px;
  transition: background .15s, box-shadow .15s;
}
.project-row:hover {
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--panel), 0 0 0 3px color-mix(in srgb, var(--ink) 12%, transparent);
}
.project-row.on {
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--panel), 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent);
}
.project {
  flex: 1; min-width: 0;
  display: grid; gap: 1px;
  padding: 7px 8px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--ink);
  text-align: left;
}
.project-name { font-size: 13px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.project-id { color: var(--muted); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.project-del {
  flex: none; width: 28px;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--muted);
  opacity: .38; line-height: 1;
}
.project-row:hover .project-del, .project-row:focus-within .project-del { opacity: 1; }
.project-del:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad); }
.rail-empty { margin: 0; padding: 8px 6px 10px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.mobile-picker { display: none; }

.workspace { min-width: 0; }
.workspace-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 10px;
}
.current { min-width: 0; }
.current h1 {
  margin: 0; font-size: 22px; line-height: 1.28; letter-spacing: -.3px;
  overflow-wrap: anywhere;
}
.current p { margin: 4px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { border-radius: 999px; padding: 5px 11px; color: var(--muted); }
.chip.on {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  color: var(--accent);
}
.release { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.release .count { color: var(--muted); font-size: 12px; }
.release .primary { padding: 6px 11px; }

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.list { display: grid; gap: 8px; min-width: 0; align-content: start; }
.card {
  display: block; width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--panel);
  border-radius: var(--r); padding: 12px 14px;
  border-left: 4px solid var(--line);
  color: var(--ink);
  transition: box-shadow .15s, border-color .15s;
}
.card:hover {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px color-mix(in srgb, var(--ink) 14%, transparent), var(--shadow);
}
.card.on {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px color-mix(in srgb, var(--accent) 50%, transparent), var(--shadow);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
.card.open { border-left-color: var(--warn); }
.card.working { border-left-color: var(--work); }
.card.awaiting_review { border-left-color: var(--review); }
.card.accepted { border-left-color: var(--ok); }
.card h3 { margin: 0 0 5px; font-size: 14px; font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; }
.card p {
  margin: 0; color: var(--muted); font-size: 12.5px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.card .meta {
  display: flex; gap: 7px 9px; align-items: center; flex-wrap: wrap;
  margin-top: 9px; color: var(--muted); font-size: 11.5px;
}
.state { padding: 2px 7px; border-radius: 999px; font-size: 11px; white-space: nowrap; }
.state.open { background: var(--warn-soft); color: var(--warn); }
.state.working { background: var(--work-soft); color: var(--work); }
.state.awaiting_review { background: var(--review-soft); color: var(--review); }
.state.accepted { background: var(--ok-soft); color: var(--ok); }
.badge { color: var(--muted); }

.empty {
  display: grid; place-items: center; gap: 2px;
  min-height: 220px; padding: 24px; color: var(--muted); text-align: center;
}
.empty p { margin: 0; }
.empty-mark { font-size: 36px; opacity: .35; }

.detail {
  position: sticky; top: 72px;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 92px); min-height: 260px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r);
}
.detail-head {
  flex: none;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 18px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.detail-title-wrap { min-width: 0; }
.detail-head h2 { margin: 0; font-size: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.detail-meta { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.detail-meta code { font: 11.5px/1.5 ui-monospace, Menlo, monospace; }
.detail-content { min-height: 0; overflow: auto; padding: 2px 18px 18px; overscroll-behavior: contain; }
.detail-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.section-title {
  margin: 18px 0 8px;
  color: var(--muted); font-size: 11.5px; font-weight: 650;
  letter-spacing: .08em;
}
.detail-content > .section-title:first-child { margin-top: 16px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; }
.file-card {
  display: block; min-width: 0;
  border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; background: var(--panel-2); color: var(--ink); text-decoration: none;
}
.file-card:hover { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px color-mix(in srgb, var(--ink) 12%, transparent); }
.file-card img { width: 100%; height: 92px; object-fit: cover; display: block; background: var(--bg); }
.file-card span {
  display: block; padding: 6px 8px; font-size: 11px;
  white-space: normal; overflow-wrap: anywhere;
}
.file-card.doc { padding: 12px; font-size: 12px; }
.note {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px;
}
.md { white-space: normal; overflow-wrap: anywhere; }
.md p { margin: 6px 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 12px 0 6px; line-height: 1.35; }
.md h1 { font-size: 17px; } .md h2 { font-size: 15px; } .md h3 { font-size: 14px; } .md h4 { font-size: 13px; }
.md ul, .md ol { margin: 6px 0; padding-left: 20px; }
.md li { margin: 2px 0; }
.md code { background: var(--bg); border-radius: 4px; padding: 1px 4px; font: 12px/1.5 ui-monospace, Menlo, monospace; }
.md-pre { position: relative; margin: 8px 0; }
.md-pre pre { margin: 0; padding: 9px 11px; padding-inline-end: 58px; border-radius: 8px; background: var(--bg); overflow: auto; }
.md-pre pre code { background: none; padding: 0; }
.md-copy-wrap { position: absolute; top: 6px; right: 6px; display: flex; align-items: center; gap: 4px; }
.md-copy {
  font-size: 11px; border: 1px solid var(--line); background: var(--panel);
  border-radius: 6px; padding: 2px 8px; min-height: 24px; opacity: .78;
}
.md-pre:hover .md-copy, .md-pre:focus-within .md-copy, .md-copy[data-copied], .md-copy[data-failed] { opacity: 1; }
.md-copy-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.md table { border-collapse: collapse; margin: 8px 0; font-size: 12px; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 9px; text-align: left; }
.md th { background: var(--bg); font-weight: 600; }
.md blockquote { margin: 8px 0; padding: 2px 0 2px 10px; border-left: 3px solid var(--line); color: var(--muted); }
.md a { color: var(--accent, #2f6fed); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.ctx-list, .pasted-list { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.ctx-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; padding: 2px 8px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--muted);
  overflow-wrap: anywhere;
}
.ctx-tag button { border: 0; background: none; padding: 0; font-size: 11px; color: var(--muted); }
.err-tag { color: var(--bad); }
.err-note { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); color: var(--bad); }
.release-guide { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; margin-bottom: 14px; }
.release-guide summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.actions .primary, .actions .ghost { padding: 8px 14px; }
.history { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.history time { color: var(--muted); opacity: .8; margin-right: 6px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(360px, 92vw); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 26px; box-shadow: var(--shadow); display: grid; gap: 12px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; color: var(--muted); }
.error { color: var(--bad); min-height: 1em; }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 9px; padding: 9px 11px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.dialog {
  width: min(620px, 94vw); max-height: 90vh; overflow: auto;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel); color: var(--ink); padding: 0; box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgb(0 0 0 / 35%); backdrop-filter: blur(2px); }
.dialog form { display: grid; gap: 12px; padding: 18px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.dialog input, .dialog textarea { color: var(--ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.file { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; }
.hint { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--panel); padding: 9px 16px; border-radius: 999px;
  font-size: 12.5px; opacity: 0; pointer-events: none; transition: .2s; z-index: 20;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1080px) {
  .shell { grid-template-columns: 228px minmax(0, 1fr); }
  .layout { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .detail { position: static; max-height: none; }
  .detail-content { overflow: visible; }
}
@media (max-width: 760px) {
  .top { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .brand .sub { display: none; }
  .top-actions { gap: 5px; }
  .top-actions .ghost, .top-actions .primary { padding: 6px 9px; font-size: 12.5px; }
  .shell { grid-template-columns: 1fr; gap: 12px; padding: 12px 12px 48px; }
  .rail { position: static; display: block; max-height: none; padding: 9px; border-radius: 13px; }
  .rail-head { padding: 0 2px 8px; }
  .rail-search, .projects { display: none; }
  .rail-empty { display: none; }
  .mobile-picker { display: flex; gap: 6px; align-items: stretch; }
  .mobile-picker select { flex: 1; min-width: 0; padding: 7px 10px; font-size: 13px; }
  .mobile-picker .icon { flex: none; height: auto; min-height: 34px; }
  .workspace-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .current h1 { font-size: 19px; }
  .release { justify-content: flex-start; }
  .toolbar { margin-bottom: 10px; }
  .layout { gap: 10px; }
  .detail-head { padding: 14px 14px 11px; }
  .detail-content { padding: 2px 14px 14px; }
  .files { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .dialog form { padding: 14px; }
}
