:root {
  --bg: #f4f1ea;
  --bg-deep: #ebe5da;
  --surface: #fffdf9;
  --surface-2: #f0ebe2;
  --surface-3: #e7e0d3;
  --ink: #25231f;
  --ink-soft: #45413a;
  --muted: #777168;
  --muted-2: #9b9489;
  --line: #e2dbcf;
  --line-strong: #d3cabb;
  --accent: #2f5d50;
  --accent-2: #3f7566;
  --accent-soft: #e3efe9;
  --accent-ink: #1f453b;
  --gold: #b8893b;
  --gold-soft: #f6ecd8;
  --danger: #a33a32;
  --danger-soft: #f7e6e3;
  --warn: #95661d;
  --warn-soft: #fbf1dd;
  --shadow-sm: 0 2px 8px rgba(48, 42, 32, 0.05);
  --shadow: 0 14px 40px rgba(48, 42, 32, 0.09);
  --shadow-lg: 0 28px 80px rgba(48, 42, 32, 0.16);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --sidebar: 306px;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
}

::selection {
  background: var(--gold-soft);
}

.app-shell {
  min-height: 100dvh;
}

/* ---------- boot ---------- */
.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
}

.boot-mark {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--accent);
  color: #fffdf9;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 24px;
  box-shadow: var(--shadow);
  animation: breathe 1.8s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: translateY(0) scale(1); opacity: 1; }
  50% { transform: translateY(-3px) scale(1.02); opacity: 0.86; }
}

/* ---------- login ---------- */
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(900px 500px at 12% 8%, rgba(47, 93, 80, 0.12), transparent 62%),
    radial-gradient(700px 500px at 92% 92%, rgba(184, 137, 59, 0.12), transparent 62%),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  background: rgba(255, 253, 249, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 42px 38px 34px;
  backdrop-filter: blur(16px);
  animation: rise 0.5s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--accent);
  color: #fffdf9;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 24px;
  margin-bottom: 22px;
  box-shadow: 0 10px 24px rgba(47, 93, 80, 0.24);
}

.login-card h1 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.login-card .sub {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.login-card label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 8px;
  font-weight: 600;
}

.login-card input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.login-card input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-card .btn {
  width: 100%;
  height: 46px;
  margin-top: 16px;
}

.login-foot {
  margin-top: 22px;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.7;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.form-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

/* ---------- layout ---------- */
.layout {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 253, 249, 0.96), rgba(246, 242, 234, 0.96)),
    var(--surface);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  padding: 26px 22px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--accent);
  color: #fffdf9;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 19px;
  box-shadow: 0 8px 18px rgba(47, 93, 80, 0.22);
  flex: 0 0 auto;
}

.brand-text h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.sidebar-tools {
  padding: 0 18px 14px;
  display: grid;
  gap: 10px;
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 0 12px 0 34px;
  outline: none;
  font-size: 13px;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.search-box input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-box::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 12px;
  width: 12px;
  height: 12px;
  border: 1.6px solid var(--muted-2);
  border-radius: 50%;
}

.search-box::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 23px;
  width: 5px;
  height: 1.6px;
  background: var(--muted-2);
  transform: rotate(45deg);
  border-radius: 2px;
}

.case-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.case-list-label {
  padding: 10px 10px 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  text-transform: uppercase;
}

.case-item {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.16s, border-color 0.16s, transform 0.16s;
  background: transparent;
  text-align: left;
  width: 100%;
}

.case-item:hover {
  background: var(--surface-2);
}

.case-item.active {
  background: var(--accent-soft);
  border-color: rgba(47, 93, 80, 0.16);
}

.case-item .avatar {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--surface-3);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 15px;
  flex: 0 0 auto;
}

.case-item.active .avatar {
  background: var(--accent);
  color: #fffdf9;
}

.case-item .case-main {
  min-width: 0;
  flex: 1;
}

.case-item .case-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-item .case-meta {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.risk-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
  flex: 0 0 auto;
}

.risk-dot.high { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.risk-dot.medium { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.risk-dot.low { background: var(--gold); }
.risk-dot.none { background: var(--accent-2); }

.sidebar-foot {
  padding: 14px 20px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-foot .privacy {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-foot .privacy::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow-y: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 34px;
  border-bottom: 1px solid rgba(226, 219, 207, 0.72);
  background: rgba(244, 241, 234, 0.82);
  backdrop-filter: blur(14px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-title {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title strong {
  color: var(--ink);
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-btn {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  place-items: center;
}

.menu-btn span,
.menu-btn::before,
.menu-btn::after {
  content: "";
  display: block;
  width: 15px;
  height: 1.6px;
  background: var(--ink-soft);
  border-radius: 2px;
}

.menu-btn span { margin: 3px 0; }

.content {
  padding: 32px 34px 64px;
  width: min(1180px, 100%);
  margin: 0 auto;
  animation: fade 0.35s ease both;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.14s, background 0.16s, border-color 0.16s, box-shadow 0.16s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fffdf9;
  box-shadow: 0 8px 20px rgba(47, 93, 80, 0.2);
}

.btn.primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn.danger {
  color: var(--danger);
  border-color: rgba(163, 58, 50, 0.22);
  background: var(--danger-soft);
}

.btn.small {
  height: 32px;
  padding: 0 11px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn.block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.btn-icon:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* ---------- empty state ---------- */
.empty-hero {
  min-height: calc(100dvh - 160px);
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  padding: 30px 16px;
}

.empty-mark {
  width: 76px;
  height: 76px;
  border-radius: 24px;
  background: linear-gradient(145deg, var(--accent), #244c41);
  color: #fffdf9;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 34px;
  box-shadow: 0 18px 40px rgba(47, 93, 80, 0.24);
  margin-bottom: 26px;
}

.empty-hero h1 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.empty-hero p {
  margin: 0 0 26px;
  max-width: 520px;
  color: var(--muted);
  line-height: 1.8;
}

.output-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 620px;
  margin-bottom: 28px;
}

.output-chips span {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12.5px;
  box-shadow: var(--shadow-sm);
}

/* ---------- case header ---------- */
.case-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 22px;
}

.case-head h1 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.case-head .case-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 13px;
}

.case-head .case-sub .divider {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--muted-2);
}

.risk-banner {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 0 0 22px;
  border: 1px solid rgba(163, 58, 50, 0.18);
  background: var(--danger-soft);
  color: #78251f;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 13.5px;
  line-height: 1.7;
}

.risk-banner.warn {
  border-color: rgba(149, 102, 29, 0.2);
  background: var(--warn-soft);
  color: #6f4a12;
}

.risk-banner.neutral {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink-soft);
}

.risk-banner .risk-icon {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: rgba(163, 58, 50, 0.12);
  display: grid;
  place-items: center;
  font-weight: 700;
  flex: 0 0 auto;
}

.risk-banner strong {
  display: block;
  margin-bottom: 2px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}

.stat-card .stat-value {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.stat-card .stat-value.small {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 11px 15px 12px;
  font-size: 13.5px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.16s, border-color 0.16s;
}

.tab:hover { color: var(--ink); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------- panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
}

.panel-head .muted {
  color: var(--muted);
  font-size: 12.5px;
}

.panel-sub {
  color: var(--muted);
  font-size: 13px;
  margin: -8px 0 16px;
}

.latest-card {
  background:
    radial-gradient(600px 240px at 100% 0%, rgba(184, 137, 59, 0.09), transparent 70%),
    var(--surface);
}

.latest-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.chip.accent {
  background: var(--accent-soft);
  border-color: rgba(47, 93, 80, 0.14);
  color: var(--accent-ink);
}

.chip.gold {
  background: var(--gold-soft);
  border-color: rgba(184, 137, 59, 0.18);
  color: #7a561a;
}

.chip.danger {
  background: var(--danger-soft);
  border-color: rgba(163, 58, 50, 0.18);
  color: var(--danger);
}

.chip.muted {
  background: transparent;
  color: var(--muted);
}

.latest-summary {
  margin: 0 0 16px;
  color: var(--ink-soft);
  line-height: 1.85;
  font-size: 14.5px;
}

.quote-list {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
}

.quote {
  border-left: 3px solid var(--gold);
  background: var(--gold-soft);
  color: #604716;
  padding: 9px 13px;
  border-radius: 0 10px 10px 0;
  font-size: 13.5px;
  line-height: 1.7;
}

.quote .speaker {
  font-weight: 700;
  margin-right: 4px;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.memory-block h3 {
  margin: 0 0 7px;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

.memory-block p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.75;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 12px;
  border: 1px solid var(--line);
}

/* ---------- timeline ---------- */
.timeline {
  display: grid;
  gap: 0;
}

.timeline-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 18px;
  position: relative;
  padding-bottom: 26px;
}

.timeline-item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 105px;
  top: 30px;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.timeline-date {
  text-align: right;
  padding-top: 2px;
}

.timeline-date .day {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}

.timeline-date .year {
  color: var(--muted-2);
  font-size: 11px;
}

.timeline-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.timeline-body::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
}

.timeline-body h3 {
  margin: 0 0 5px;
  font-size: 15px;
  font-weight: 600;
}

.timeline-body .timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 9px;
}

.timeline-body p {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.75;
}

/* ---------- docs ---------- */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.doc-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.16s, transform 0.16s, box-shadow 0.16s;
  cursor: pointer;
  text-align: left;
}

.doc-card:hover {
  border-color: var(--accent-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.doc-card .doc-type {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

.doc-card .doc-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.5;
}

.doc-card .doc-date {
  color: var(--muted-2);
  font-size: 11.5px;
}

.doc-card .doc-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 6px;
  color: var(--muted-2);
  font-size: 11px;
}

/* ---------- markdown ---------- */
.markdown {
  color: var(--ink-soft);
  font-size: 15.5px;
  line-height: 1.92;
  word-break: break-word;
}

.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  font-family: var(--serif);
  color: var(--ink);
  line-height: 1.4;
  margin: 1.7em 0 0.65em;
  font-weight: 600;
}

.markdown h1 {
  font-size: 27px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--line);
  margin-top: 0;
}

.markdown h2 {
  font-size: 21px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.markdown h3 { font-size: 17.5px; }
.markdown h4 { font-size: 15.5px; }

.markdown p {
  margin: 0.7em 0;
}

.markdown ul,
.markdown ol {
  margin: 0.6em 0;
  padding-left: 1.5em;
}

.markdown li {
  margin: 0.28em 0;
}

.markdown li > ul,
.markdown li > ol {
  margin: 0.2em 0;
}

.markdown blockquote {
  margin: 1em 0;
  padding: 10px 16px;
  border-left: 3px solid var(--gold);
  background: var(--gold-soft);
  color: #604716;
  border-radius: 0 10px 10px 0;
}

.markdown blockquote p { margin: 0.25em 0; }

.markdown hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1.8em 0;
}

.markdown code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

.markdown pre {
  background: #2b2a26;
  color: #f4f1ea;
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
}

.markdown pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
}

.markdown a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.table-wrap {
  overflow-x: auto;
  margin: 1.1em 0;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 520px;
}

.markdown th,
.markdown td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  line-height: 1.65;
}

.markdown th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.markdown tr:last-child td { border-bottom: none; }

.markdown strong { color: var(--ink); font-weight: 700; }

/* ---------- modal ---------- */
.modal-backdrop,
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(32, 29, 24, 0.38);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade 0.2s ease both;
}

.modal {
  width: min(780px, 100%);
  max-height: min(90dvh, 900px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.6);
  animation: rise 0.28s ease both;
}

.modal.wide { width: min(980px, 100%); }

.modal-head {
  padding: 24px 28px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(255, 253, 249, 0.95);
  backdrop-filter: blur(10px);
  z-index: 2;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
}

.modal-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-body {
  padding: 22px 28px 26px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 28px 24px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: rgba(255, 253, 249, 0.96);
  backdrop-filter: blur(10px);
}

.close-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  flex: 0 0 auto;
}

.close-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- form ---------- */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 7px;
}

.field .hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="date"],
.field input[type="number"],
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 11px;
  padding: 10px 13px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.75;
}

.field textarea.material {
  min-height: 260px;
  font-size: 14px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 7px 15px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.audio-drop {
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.audio-drop strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

.audio-drop input[type="file"] {
  margin: 12px auto 0;
  max-width: 100%;
}

.hidden { display: none !important; }

/* ---------- progress ---------- */
.progress-card {
  text-align: center;
  padding: 10px 6px 4px;
}

.progress-orb {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-card h2 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
}

.progress-card .progress-message {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13.5px;
  min-height: 22px;
}

.steps {
  list-style: none;
  padding: 0;
  margin: 0 auto 22px;
  max-width: 460px;
  text-align: left;
  display: grid;
  gap: 8px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  transition: all 0.25s;
}

.step .step-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  display: grid;
  place-items: center;
  font-size: 11px;
  flex: 0 0 auto;
  color: var(--muted-2);
  background: var(--surface);
}

.step.running {
  background: var(--accent-soft);
  border-color: rgba(47, 93, 80, 0.18);
  color: var(--accent-ink);
}

.step.running .step-dot {
  border-color: var(--accent);
  border-top-color: transparent;
  animation: spin 0.9s linear infinite;
}

.step.done {
  background: var(--surface);
  color: var(--ink-soft);
  border-color: var(--line);
}

.step.done .step-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fffdf9;
}

.step.error {
  background: var(--danger-soft);
  border-color: rgba(163, 58, 50, 0.18);
  color: var(--danger);
}

.step.error .step-dot {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.progress-bar {
  height: 6px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
  max-width: 460px;
  margin: 0 auto 12px;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
  transition: width 0.5s ease;
}

.progress-hint {
  color: var(--muted-2);
  font-size: 12px;
  margin: 0;
}

/* ---------- result ---------- */
.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.result-docs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.evidence-box {
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.evidence-box summary {
  cursor: pointer;
  color: var(--ink-soft);
  line-height: 1.7;
}

.evidence-box ul {
  margin: 8px 0 2px;
  padding-left: 18px;
  line-height: 1.75;
}

.evidence-box li {
  margin: 4px 0;
}

.result-doc {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.16s, background 0.16s;
}

.result-doc:hover {
  border-color: var(--accent-2);
  background: var(--accent-soft);
}

.result-doc .name {
  font-weight: 600;
  font-size: 13px;
}

.result-doc .arrow {
  color: var(--muted);
  font-size: 16px;
}

/* ---------- drawer ---------- */
.drawer-backdrop {
  place-items: stretch;
  justify-items: end;
  padding: 0;
  background: rgba(32, 29, 24, 0.34);
}

.drawer {
  width: min(920px, 100%);
  height: 100dvh;
  background: var(--surface);
  box-shadow: -20px 0 60px rgba(32, 29, 24, 0.18);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}

.drawer-head {
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 253, 249, 0.96);
  backdrop-filter: blur(10px);
}

.drawer-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.4;
}

.drawer-head .drawer-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 26px 34px 60px;
}

.drawer-body .markdown {
  max-width: 820px;
  margin: 0 auto;
}

/* ---------- toast ---------- */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #2b2a26;
  color: #f6f3ee;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toastIn 0.22s ease both;
  max-width: min(520px, 90vw);
}

.toast.error {
  background: var(--danger);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.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;
}

.loading-line {
  color: var(--muted);
  font-size: 13px;
  padding: 26px 0;
  text-align: center;
}

.section-title {
  margin: 34px 0 14px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
}

.danger-zone {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  display: flex;
  justify-content: flex-end;
}

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  :root { --sidebar: 272px; }
  .content { padding: 26px 24px 56px; }
  .topbar { padding: 14px 24px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: var(--shadow-lg);
    width: min(320px, 86vw);
    flex-basis: auto;
  }

  body.sidebar-open .sidebar { transform: translateX(0); }

  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(32, 29, 24, 0.32);
    z-index: 15;
  }

  .menu-btn { display: grid; }
  .main { height: auto; min-height: 100dvh; }
  .case-head { flex-direction: column; }
  .case-head .btn { align-self: flex-start; }
  .memory-grid { grid-template-columns: 1fr; }
  .timeline-item { grid-template-columns: 74px minmax(0, 1fr); gap: 12px; }
  .timeline-item:not(:last-child)::before { left: 86px; }
  .timeline-body::before { left: -19px; }
}

@media (max-width: 640px) {
  .content { padding: 20px 16px 48px; }
  .topbar { padding: 12px 16px; }
  .topbar-title { display: none; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal {
    width: 100%;
    max-height: 94dvh;
    border-radius: 20px 20px 0 0;
  }
  .modal-head, .modal-body, .modal-actions { padding-left: 18px; padding-right: 18px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 13px 14px; }
  .stat-card .stat-value { font-size: 18px; }
  .panel { padding: 18px; }
  .drawer-head { padding: 16px 18px; }
  .drawer-body { padding: 20px 18px 50px; }
  .result-docs { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px 26px; }
}
