:root {
  --ink: #1f1e1c;
  --ink-deep: #1f1e1c;
  --ink-soft: #625d58;
  --teal: #b85c38;
  --teal-hover: #974526;
  --teal-pale: #f7e9e1;
  --copper: #b85c38;
  --copper-dark: #974526;
  --copper-pale: #f7e9e1;
  --paper: #f6f4f1;
  --surface: #ffffff;
  --surface-soft: #f0ece8;
  --line: #e5dfd9;
  --line-strong: #d2c8bf;
  --muted: #625d58;
  --danger: #aa433b;
  --danger-pale: #fbeceb;
  --warning: #8b641f;
  --warning-pale: #faf2df;
  --success: #28704d;
  --success-pale: #e6f3ea;
  --shadow: 0 16px 32px rgba(31, 30, 28, 0.08);
  --font-scale: 1;
  color-scheme: light;
  font-family: "Aptos", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: calc(16px * var(--font-scale));
  color: var(--ink-deep);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--paper); }
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button { touch-action: manipulation; }
button:disabled, input:disabled, textarea:disabled, select:disabled { cursor: not-allowed; opacity: 0.5; }
a { color: var(--teal); }
img, svg { display: block; }
svg.icon { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(184, 92, 56, 0.28); outline-offset: 3px; }
::selection { color: var(--ink-deep); background: #efd4c5; }
.skip-link { position: fixed; z-index: 1000; top: 0.5rem; left: 0.5rem; padding: 0.75rem 1rem; color: #fff; background: var(--ink); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(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; }
.muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.small { font-size: 0.875rem; }
.mono { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: grid; gap: 1rem; }
.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.65rem 1rem; border: 1px solid transparent; border-radius: 10px; font-weight: 650; line-height: 1.35; text-decoration: none; transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 100ms ease, box-shadow 160ms ease; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-primary { color: #fff; background: var(--teal); border-color: var(--teal); box-shadow: 0 5px 14px rgba(184, 92, 56, 0.16); }
.btn-primary:hover:not(:disabled) { background: var(--teal-hover); border-color: var(--teal-hover); box-shadow: 0 7px 18px rgba(184, 92, 56, 0.22); }
.btn-copper { color: #fff; background: var(--ink); border-color: var(--ink); }
.btn-copper:hover:not(:disabled) { background: var(--teal); border-color: var(--teal); }
.btn-secondary { color: var(--ink); background: var(--surface); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-soft); border-color: var(--line-strong); }
.btn-ghost { color: var(--ink-soft); background: transparent; border-color: transparent; }
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: var(--surface-soft); }
.btn-danger { color: var(--danger); background: var(--danger-pale); border-color: #efcfcc; }
.btn-small { min-height: 40px; padding: 0.45rem 0.75rem; font-size: 0.88rem; }
.btn-block { width: 100%; }
.btn .spin { width: 1rem; height: 1rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
.icon-btn { width: 44px; min-width: 44px; height: 44px; padding: 0; display: inline-grid; place-items: center; color: var(--ink-soft); background: transparent; border: 1px solid var(--line); border-radius: 10px; }
.icon-btn:hover { color: var(--ink); background: var(--surface-soft); }

.field { display: grid; gap: 0.45rem; }
.field label, .field-label { color: var(--ink); font-size: 0.92rem; font-weight: 650; }
.field input, .field textarea, .field select, .input { width: 100%; min-height: 50px; padding: 0.75rem 0.9rem; color: var(--ink-deep); background: #fff; border: 1px solid var(--line-strong); border-radius: 10px; transition: border-color 160ms ease, box-shadow 160ms ease; }
.field textarea { min-height: 112px; resize: vertical; line-height: 1.65; }
.field input:focus, .field textarea:focus, .field select:focus, .input:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(184, 92, 56, 0.1); outline: none; }
.field-help { margin: 0; color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.field-error { margin: 0; color: var(--danger); font-size: 0.9rem; }
.required { color: var(--danger); }
.checkbox-label { min-height: 48px; display: flex; align-items: center; gap: 0.65rem; font-weight: 650; }
.checkbox-label input { width: 22px; height: 22px; accent-color: var(--teal); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.25rem; }

.brand { display: inline-flex; align-items: center; gap: 0.7rem; color: var(--ink); }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: transparent; border-radius: 10px; }
.brand-mark::after { display: none; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-mark svg { width: 22px; height: 22px; }
.brand-name { display: block; font-size: 1.04rem; font-weight: 750; letter-spacing: -0.02em; }
.brand-sub { display: block; margin-top: 0.16rem; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.04em; }

.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(400px, 0.82fr); }
.auth-intro { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(2rem, 5vw, 5rem); color: #faf7f4; background: #292724; }
.auth-intro::before { content: ""; position: absolute; right: -180px; top: 16%; width: 480px; height: 480px; border: 1px solid rgba(240, 216, 202, 0.12); border-radius: 50%; box-shadow: 0 0 0 70px rgba(240, 216, 202, 0.035), 0 0 0 140px rgba(240, 216, 202, 0.025); }
.auth-intro .brand { position: relative; z-index: 1; color: #fff; }
.auth-intro .brand-mark { color: #292724; background: transparent; }
.auth-intro .brand-mark::after { border-color: #292724; }
.auth-intro .brand-sub { color: #bfb2a9; }
.auth-copy { position: relative; z-index: 1; max-width: 680px; padding: 3rem 0; }
.eyebrow { display: flex; align-items: center; gap: 0.65rem; margin: 0 0 1rem; color: #e3a181; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.1em; }
.eyebrow::before { content: ""; width: 24px; height: 2px; background: currentColor; }
.auth-copy h1 { max-width: 620px; margin: 0; font-size: clamp(2.25rem, 4.4vw, 4rem); line-height: 1.12; letter-spacing: -0.055em; font-weight: 700; }
.auth-copy > p:not(.eyebrow) { max-width: 570px; margin: 1.5rem 0 0; color: #d4c9c1; font-size: 1.04rem; line-height: 1.85; }
.auth-points { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; margin: 2.5rem 0 0; padding: 1.5rem 0 0; list-style: none; border-top: 1px solid rgba(240, 216, 202, 0.2); }
.auth-points strong { display: block; margin-bottom: 0.4rem; color: #faf7f4; font-size: 0.94rem; }
.auth-points span { color: #bfb2a9; font-size: 0.83rem; line-height: 1.65; }
.factory-lines { display: none; }
.auth-foot { position: relative; z-index: 1; margin: 0; color: #a99b91; font-size: 0.8rem; }
.auth-panel { display: grid; place-items: center; padding: clamp(1.5rem, 5vw, 4rem); background: #fcfbf9; }
.auth-box { width: min(100%, 440px); }
.auth-box .eyebrow { color: var(--teal); }
.auth-box h2 { margin: 0 0 0.65rem; font-size: 1.85rem; letter-spacing: -0.035em; }
.auth-box > p { margin: 0 0 2rem; color: var(--muted); line-height: 1.75; }
.auth-box form { display: grid; gap: 1.15rem; }
.auth-note { display: flex; gap: 0.7rem; margin-top: 1.5rem; padding: 1rem 0; color: var(--muted); border-top: 1px solid var(--line); font-size: 0.85rem; line-height: 1.7; }
.auth-note svg { margin-top: 0.2rem; color: var(--teal); }

.app-shell { min-height: 100vh; min-height: 100dvh; }
.topbar { position: sticky; z-index: 30; top: 0; min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.65rem clamp(1rem, 2.5vw, 2rem); background: rgba(255, 255, 255, 0.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.35rem; flex-wrap: wrap; }
.font-tools { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.font-tools .btn { min-height: 40px; border: 0; border-radius: 0; padding-inline: 0.7rem; font-size: 0.82rem; }
.font-tools .btn + .btn { border-left: 1px solid var(--line); }
.user-badge { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 42px; padding: 0.3rem 0.65rem 0.3rem 0.3rem; color: var(--ink); background: var(--surface-soft); border: 0; border-radius: 999px; font-family: inherit; font-weight: 650; cursor: pointer; }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; color: #fff; background: var(--teal); border-radius: 50%; font-size: 0.85rem; }

.consult-layout { height: calc(100vh - 71px); height: calc(100dvh - 71px); min-height: 620px; display: grid; grid-template-columns: 264px minmax(380px, 1fr) 296px; gap: 14px; max-width: 1900px; margin: 0 auto; padding: 14px; }
.project-sidebar, .insight-panel { min-height: 0; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.project-sidebar { padding: 1rem 0.8rem; }
.insight-panel { padding: 1.1rem; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.9rem; padding: 0 0.25rem; }
.panel-heading h2, .panel-heading h3 { margin: 0; font-size: 0.92rem; }
.project-list { display: grid; gap: 0.35rem; margin-top: 0.85rem; }
.project-item { position: relative; width: 100%; min-height: 90px; padding: 0.8rem 0.85rem; text-align: left; color: var(--ink-deep); background: transparent; border: 1px solid transparent; border-radius: 11px; transition: background-color 150ms ease, border-color 150ms ease; }
.project-item:hover { background: var(--surface-soft); }
.project-item.active { background: var(--teal-pale); border-color: #e6c5b4; }
.project-item.active::before { content: ""; position: absolute; left: -1px; top: 18px; bottom: 18px; width: 3px; background: var(--teal); border-radius: 3px; }
.project-item-title { display: block; margin-bottom: 0.35rem; font-weight: 700; line-height: 1.45; }
.project-item-summary { display: -webkit-box; overflow: hidden; color: var(--muted); font-size: 0.8rem; line-height: 1.5; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.project-item-meta { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; margin-top: 0.55rem; color: var(--muted); font-size: 0.72rem; }
.mobile-project-toggle { display: none; }

.chat-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.chat-header { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.9rem 1.2rem; background: rgba(255, 255, 255, 0.96); border-bottom: 1px solid var(--line); }
.chat-header h1, .chat-header h2 { margin: 0 0 0.2rem; font-size: 1.04rem; letter-spacing: -0.015em; }
.chat-header p { margin: 0; color: var(--muted); font-size: 0.8rem; }
.chat-header-actions { display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; justify-content: flex-end; }
.mode-switch { display: inline-flex; padding: 3px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; }
.mode-switch-btn { min-height: 36px; padding: 0.4rem 0.65rem; color: var(--muted); background: transparent; border: 0; border-radius: 7px; font-family: inherit; font-size: 0.78rem; cursor: pointer; transition: color 150ms ease, background-color 150ms ease; }
.mode-switch-btn.active { color: #fff; background: var(--ink); }
.mode-switch-btn:disabled { cursor: wait; opacity: 0.6; }
.message-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1.5rem clamp(1rem, 3vw, 2.5rem); scroll-behavior: smooth; background: #fcfbf9; }
.messages { max-width: 850px; display: grid; gap: 1.2rem; margin: 0 auto; }
.message { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 0.7rem; align-items: start; }
.message.user { grid-template-columns: minmax(0, 1fr) 34px; }
.message.user .message-avatar { grid-column: 2; color: var(--teal); background: var(--teal-pale); }
.message.user .message-body { grid-column: 1; grid-row: 1; justify-self: end; background: var(--teal-pale); border-color: transparent; }
.message-avatar { width: 34px; height: 34px; display: grid; place-items: center; color: #fff; background: var(--ink); border-radius: 10px; font-size: 0.78rem; font-weight: 750; }
.message-body { max-width: 760px; padding: 0.9rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; }
.message.user .message-body { border-radius: 14px 4px 14px 14px; }
.message-meta { display: flex; gap: 0.7rem; margin-bottom: 0.35rem; color: var(--muted); font-size: 0.74rem; }
.message-content { overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.8; }
.message-content p { margin: 0 0 0.75rem; }
.message-content p:last-child { margin-bottom: 0; }
.message-references { margin-top: 0.75rem; padding-top: 0.65rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.78rem; }
.message-plan-btn { margin-top: 0.7rem; }
.quick-area { max-width: 850px; margin: 0.2rem auto 0; }
.quick-label { margin: 0 0 0.55rem; color: var(--muted); font-size: 0.78rem; }
.quick-options { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.quick-option { min-height: 38px; padding: 0.45rem 0.75rem; color: var(--ink-soft); text-align: left; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px; font-size: 0.84rem; transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease; }
.quick-option:hover { color: var(--teal); background: var(--teal-pale); border-color: #dfbba6; }
.typing { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); }
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots i { width: 6px; height: 6px; background: var(--teal); border-radius: 50%; animation: blink 1.1s infinite alternate; }
.typing-dots i:nth-child(2) { animation-delay: 0.25s; }
.typing-dots i:nth-child(3) { animation-delay: 0.5s; }
.composer { padding: 0.85rem clamp(1rem, 3vw, 2.5rem) 0.9rem; background: var(--surface); border-top: 1px solid var(--line); }
.composer-inner { max-width: 850px; margin: 0 auto; }
.composer-box { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 0.55rem; padding: 5px; background: #fff; border: 1px solid var(--line-strong); border-radius: 14px; transition: border-color 150ms ease, box-shadow 150ms ease; }
.composer-box:focus-within { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(184, 92, 56, 0.08); }
.composer textarea { width: 100%; min-height: 52px; max-height: 160px; padding: 0.75rem; color: var(--ink-deep); background: transparent; border: 0; border-radius: 10px; resize: vertical; line-height: 1.55; outline: none; }
.composer .btn { min-height: 52px; border-radius: 10px; }
.composer-meta { display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.4rem; color: var(--muted); font-size: 0.72rem; }
.welcome { max-width: 700px; margin: 4vh auto 0; padding: 1rem 0; }
.welcome-tag { display: inline-block; margin-bottom: 1rem; padding: 0.35rem 0.6rem; color: var(--teal); background: var(--teal-pale); border-radius: 6px; font-size: 0.76rem; font-weight: 700; }
.welcome h2 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.35rem); line-height: 1.3; letter-spacing: -0.04em; }
.welcome > p { color: var(--muted); line-height: 1.8; }
.free-input-note { padding: 0.9rem 1rem; background: var(--teal-pale); border-radius: 10px; }
.welcome-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; margin-top: 1.5rem; }
.welcome-prompt { min-height: 78px; padding: 0.9rem; color: var(--ink); text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; line-height: 1.55; transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease; }
.welcome-prompt:hover { border-color: #dfbba6; background: var(--teal-pale); transform: translateY(-1px); }

.insight-section { padding: 0.1rem 0 1.2rem; margin-bottom: 1.2rem; border-bottom: 1px solid var(--line); }
.insight-section:last-child { border-bottom: 0; }
.insight-section h2, .insight-section h3 { margin: 0 0 0.9rem; font-size: 0.9rem; }
.progress-list { position: relative; display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.progress-step { position: relative; display: grid; grid-template-columns: 26px 1fr; gap: 0.6rem; min-height: 58px; color: var(--muted); }
.progress-step::before { content: ""; position: absolute; left: 12px; top: 26px; bottom: 0; width: 1px; background: var(--line-strong); }
.progress-step:last-child::before { display: none; }
.progress-dot { position: relative; z-index: 1; width: 26px; height: 26px; display: grid; place-items: center; color: var(--muted); background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 50%; font-size: 0.7rem; }
.progress-step.done, .progress-step.current { color: var(--ink); }
.progress-step.done .progress-dot { color: #fff; background: var(--teal); border-color: var(--teal); }
.progress-step.current .progress-dot { border-color: var(--teal); box-shadow: inset 0 0 0 5px var(--surface); background: var(--teal); }
.progress-step strong { display: block; padding-top: 0.15rem; font-size: 0.86rem; }
.progress-step small { display: block; margin-top: 0.2rem; line-height: 1.4; font-size: 0.75rem; }
.knowledge-list { display: grid; gap: 0.65rem; }
.knowledge-card { padding: 0.75rem 0.8rem; background: var(--paper); border: 1px solid transparent; border-radius: 10px; }
.knowledge-card strong { display: block; line-height: 1.5; font-size: 0.86rem; }
.knowledge-card p { display: -webkit-box; overflow: hidden; margin: 0.4rem 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.6; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.knowledge-source { display: block; margin-top: 0.45rem; color: var(--teal); font-size: 0.72rem; }
.knowledge-source a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.memory-list { margin: 0; padding: 0; list-style: none; }
.memory-list li { padding: 0.55rem 0; border-bottom: 1px dashed var(--line); line-height: 1.5; font-size: 0.84rem; }
.memory-list li:last-child { border-bottom: 0; }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0.15rem 0.5rem; color: var(--ink-soft); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 999px; font-size: 0.7rem; font-weight: 650; white-space: nowrap; }
.badge-success { color: var(--success); background: var(--success-pale); border-color: #c8e2d0; }
.badge-warning { color: var(--warning); background: var(--warning-pale); border-color: #ead9ae; }
.badge-danger { color: var(--danger); background: var(--danger-pale); border-color: #efcfcc; }
.badge-teal { color: var(--teal); background: var(--teal-pale); border-color: #e6c5b4; }
.state { min-height: 150px; display: grid; place-items: center; align-content: center; gap: 0.65rem; padding: 1.5rem; color: var(--muted); text-align: center; line-height: 1.65; }
.state svg { width: 30px; height: 30px; color: var(--line-strong); }
.state strong { color: var(--ink); }
.state p { max-width: 420px; margin: 0; }
.state-error { color: var(--danger); }
.state-error strong { color: var(--danger); }
.state-compact { min-height: 90px; padding: 1rem; }
.skeleton { position: relative; overflow: hidden; min-height: 76px; background: #edf0ee; border-radius: 10px; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, 0.5); transform: translateX(-100%); animation: skeleton 1.4s ease-in-out infinite; }
.skeleton-lines { width: 100%; display: grid; gap: 0.65rem; }
.skeleton-lines span { display: block; height: 13px; background: #e5e9e6; border-radius: 5px; }
.skeleton-lines span:nth-child(2) { width: 82%; }
.skeleton-lines span:nth-child(3) { width: 60%; }

dialog { width: min(680px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); padding: 0; color: var(--ink-deep); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 28px 90px rgba(20, 33, 29, 0.22); }
dialog.dialog-wide { width: min(900px, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(15, 30, 25, 0.48); backdrop-filter: blur(3px); }
.dialog-header { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.3rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 1.15rem; letter-spacing: -0.02em; }
.dialog-body { overflow-y: auto; max-height: calc(100dvh - 160px); padding: 1.3rem; line-height: 1.75; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 0.65rem; padding: 0.9rem 1.3rem; background: var(--surface); border-top: 1px solid var(--line); }
.plan-document { color: #2b3834; }
.plan-document .plan-kicker { color: var(--teal); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.08em; }
.plan-document h3 { margin: 0.35rem 0 1rem; color: var(--ink); font-size: 1.55rem; line-height: 1.35; letter-spacing: -0.035em; }
.plan-document h4 { margin: 1.4rem 0 0.6rem; color: var(--ink); font-size: 1rem; }
.plan-document p { margin: 0.5rem 0; white-space: pre-wrap; }
.plan-document ul, .plan-document ol { padding-left: 1.35rem; }
.plan-document li { margin: 0.4rem 0; white-space: pre-wrap; }
.plan-summary { padding: 1rem; background: var(--teal-pale); border-radius: 10px; }
.plan-section { padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.plan-pre { overflow-x: auto; padding: 1rem; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--paper); border-radius: 10px; font-family: inherit; }
.mode-dialog { max-width: 860px; }
.mode-heading { align-items: flex-start; }
.mode-heading h2 { margin: 0.25rem 0; }
.mode-heading p:last-child { margin: 0; color: var(--muted); }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.mode-card { display: flex; flex-direction: column; align-items: flex-start; gap: 0.85rem; min-height: 240px; padding: 1.5rem; color: var(--ink); text-align: left; background: #fcfbf9; border: 1px solid var(--line); border-radius: 14px; font-family: inherit; cursor: pointer; transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease; }
.mode-card-guided { background: #faf7f4; }
.mode-card:hover, .mode-card:focus-visible { transform: translateY(-2px); border-color: var(--teal); box-shadow: var(--shadow); outline: none; }
.mode-card strong { color: var(--ink-deep); font-size: 1.35rem; letter-spacing: -0.025em; }
.mode-card > span:not(.mode-number) { color: var(--ink-soft); line-height: 1.75; }
.mode-card b { margin-top: auto; color: var(--teal); font-size: 0.86rem; }
.mode-number { padding: 0.25rem 0.55rem; color: var(--teal); background: var(--teal-pale); border-radius: 6px; font-size: 0.76rem; font-weight: 700; }
.toast-region { position: fixed; z-index: 200; right: 1rem; bottom: 1rem; width: min(400px, calc(100vw - 2rem)); display: grid; gap: 0.65rem; pointer-events: none; }
.toast { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 0.9rem 1rem; color: #fff; background: var(--ink-deep); border: 1px solid rgba(255,255,255,0.08); border-radius: 11px; box-shadow: var(--shadow); pointer-events: auto; line-height: 1.55; animation: toast-in 180ms ease-out; }
.toast.error { background: #743c36; }
.toast button { min-width: 32px; min-height: 32px; padding: 0; color: inherit; background: transparent; border: 0; font-size: 1.2rem; }

.admin-shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.admin-sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: 1.25rem 0.8rem; color: #f1ece8; background: #292724; }
.admin-sidebar .brand { padding: 0 0.45rem 1.35rem; color: #fff; }
.admin-sidebar .brand-mark { color: #292724; background: transparent; }
.admin-sidebar .brand-sub { color: #b3a49a; }
.admin-sidebar .brand-mark::after { border-color: #292724; }
.admin-nav { display: grid; gap: 0.25rem; }
.admin-nav button { min-height: 46px; display: flex; align-items: center; gap: 0.7rem; padding: 0.65rem 0.85rem; color: #bfb2a9; text-align: left; background: transparent; border: 0; border-radius: 9px; font-weight: 600; }
.admin-nav button:hover { color: #fff; background: #3b3632; }
.admin-nav button.active { color: #fff; background: #55433a; }
.admin-sidebar-foot { margin-top: auto; padding-top: 0.8rem; border-top: 1px solid #49403a; }
.admin-sidebar-foot .btn { width: 100%; color: #d4c9c1; justify-content: flex-start; }
.admin-sidebar-foot .btn:hover { background: #3b3632; }
.admin-main { min-width: 0; }
.admin-topbar { position: static; min-height: 74px; padding-inline: clamp(1rem, 3vw, 2rem); }
.admin-topbar h1 { margin: 0; font-size: 1.15rem; }
.admin-topbar p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.8rem; }
.admin-content { max-width: 1600px; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }
.view-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.view-heading h2 { margin: 0; font-size: 1.25rem; letter-spacing: -0.025em; }
.view-heading p { margin: 0.3rem 0 0; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.85rem; }
.stat-card { min-height: 130px; padding: 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; }
.stat-card.copper { background: #faf7f4; }
.stat-card dt { color: var(--muted); font-size: 0.84rem; }
.stat-card dd { margin: 0.65rem 0 0; color: var(--ink); font-size: 1.9rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.stat-card small { display: block; margin-top: 0.25rem; color: var(--muted); }
.admin-note { margin-top: 1.25rem; padding: 1rem 1.1rem; background: var(--teal-pale); border-radius: 11px; line-height: 1.75; }
.admin-note h3 { margin: 0 0 0.35rem; }
.admin-note p { margin: 0; color: var(--ink-soft); }
.toolbar { display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; }
.toolbar .input { width: min(300px, 100%); }
.data-panel { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; line-height: 1.55; }
th { color: var(--muted); background: #f8f5f2; font-size: 0.78rem; font-weight: 650; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfbf9; }
td .btn { margin: 0.12rem; }
.table-title { font-weight: 700; color: var(--ink); }
.table-sub { display: block; margin-top: 0.18rem; color: var(--muted); font-size: 0.76rem; }
.empty-table { padding: 0; }
.filters { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.filter-btn { min-height: 40px; padding: 0.45rem 0.8rem; color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.filter-btn.active { color: #fff; background: var(--ink); border-color: var(--ink); }
.split-workspace { display: grid; grid-template-columns: minmax(280px, 350px) minmax(0, 1fr); gap: 0.85rem; align-items: start; }
.selection-list { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; }
.selection-item { width: 100%; display: block; min-height: 78px; padding: 0.9rem; color: var(--ink); text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); }
.selection-item:last-child { border-bottom: 0; }
.selection-item:hover { background: var(--surface-soft); }
.selection-item.active { background: var(--teal-pale); box-shadow: inset 3px 0 0 var(--teal); }
.selection-item strong { display: block; line-height: 1.5; }
.selection-item small { display: block; margin-top: 0.3rem; color: var(--muted); }
.detail-panel { min-width: 0; padding: 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; }
.detail-panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-bottom: 0.9rem; border-bottom: 1px solid var(--line); }
.detail-panel-header h3 { margin: 0; }
.detail-panel-header p { margin: 0.3rem 0 0; color: var(--muted); }
.conversation-view { display: grid; gap: 0.85rem; max-height: 650px; overflow-y: auto; padding: 1.1rem 0; }
.conversation-bubble { max-width: 88%; padding: 0.8rem 0.9rem; background: var(--paper); border-radius: 4px 11px 11px 11px; }
.conversation-bubble.user { justify-self: end; background: var(--teal-pale); border-radius: 11px 4px 11px 11px; }
.conversation-bubble small { display: block; margin-bottom: 0.3rem; color: var(--muted); }
.conversation-bubble div { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.editor-form { display: grid; gap: 1rem; padding-top: 1.1rem; }
.editor-form textarea { min-height: 96px; }
.editor-form textarea.tall { min-height: 150px; }
.editor-actions { position: sticky; bottom: -1.1rem; display: flex; justify-content: flex-end; gap: 0.6rem; flex-wrap: wrap; margin: 0 -1.1rem -1.1rem; padding: 0.9rem 1.1rem; background: var(--surface); border-top: 1px solid var(--line); }
.definition-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.65rem 1rem; margin: 0; }
.definition-list dt { color: var(--muted); }
.definition-list dd { margin: 0; overflow-wrap: anywhere; }
.tag-list { display: flex; gap: 0.35rem; flex-wrap: wrap; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { from { opacity: 0.25; transform: translateY(1px); } to { opacity: 1; transform: translateY(-1px); } }
@keyframes skeleton { to { transform: translateX(100%); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1280px) {
  .consult-layout { grid-template-columns: 250px minmax(360px, 1fr); height: auto; min-height: calc(100dvh - 71px); }
  .insight-panel { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; overflow: visible; }
  .insight-section { margin: 0; padding: 0; border-bottom: 0; }
  .chat-panel { height: calc(100dvh - 99px); min-height: 650px; }
  .project-sidebar { max-height: calc(100dvh - 99px); position: sticky; top: 85px; }
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1050px) {
  .auth-page { grid-template-columns: 1fr 410px; }
  .auth-points { grid-template-columns: 1fr; gap: 0.8rem; }
  .admin-shell { grid-template-columns: 196px minmax(0, 1fr); }
  .admin-sidebar { padding-inline: 0.65rem; }
  .admin-sidebar .brand-sub { display: none; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-workspace { grid-template-columns: 280px minmax(0, 1fr); }
}
@media (max-width: 800px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-intro { min-height: auto; padding: 1.5rem; }
  .auth-copy { padding: 3rem 0 1rem; }
  .auth-copy h1 { font-size: 2.25rem; }
  .auth-copy > p:not(.eyebrow) { font-size: 1rem; }
  .auth-points, .auth-foot { display: none; }
  .auth-panel { padding: 2rem 1.25rem; }
  .topbar { position: relative; align-items: flex-start; }
  .topbar-actions { gap: 0.3rem; }
  .topbar .brand-sub { display: none; }
  .user-badge { padding: 0.3rem; }
  .user-badge #current-user { display: none; }
  .consult-layout { display: block; min-height: 0; padding: 10px; }
  .project-sidebar { position: static; max-height: none; margin-bottom: 10px; }
  .project-sidebar.collapsed .project-list, .project-sidebar.collapsed .project-sidebar-state { display: none; }
  .project-sidebar.collapsed { padding-bottom: 0.5rem; }
  .mobile-project-toggle { display: inline-flex; }
  .project-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat-panel { height: auto; min-height: 680px; grid-template-rows: auto minmax(360px, 1fr) auto; }
  .chat-header { flex-wrap: wrap; }
  .chat-header-actions { width: 100%; justify-content: space-between; }
  .message-scroll { max-height: 65vh; min-height: 380px; }
  .insight-panel { grid-template-columns: 1fr; margin-top: 10px; }
  .insight-section { padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
  .admin-shell { display: block; }
  .admin-sidebar { position: static; width: 100%; height: auto; padding: 0.75rem 1rem; }
  .admin-sidebar .brand { padding: 0 0 0.75rem; }
  .admin-sidebar .brand-mark { width: 36px; height: 36px; }
  .admin-nav { display: flex; overflow-x: auto; gap: 0.35rem; padding-bottom: 0.25rem; }
  .admin-nav button { flex: 0 0 auto; min-height: 42px; padding: 0.55rem 0.75rem; }
  .admin-nav button.active { box-shadow: inset 0 -2px 0 #e3a181; }
  .admin-sidebar-foot { position: absolute; top: 0.75rem; right: 1rem; margin: 0; padding: 0; border: 0; }
  .admin-sidebar-foot .btn { width: auto; color: var(--ink); }
  .admin-sidebar-foot .btn span { display: none; }
  .admin-topbar { min-height: 68px; }
  .split-workspace { grid-template-columns: 1fr; }
  .selection-list { max-height: 340px; overflow-y: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
}
@media (max-width: 560px) {
  .topbar { padding: 0.6rem 0.7rem; }
  .topbar .brand-name { max-width: 140px; font-size: 0.86rem; line-height: 1.25; }
  .topbar .brand-mark { width: 36px; height: 36px; }
  .topbar-actions .continue-label { display: none; }
  .font-tools .btn { padding-inline: 0.5rem; }
  .topbar-actions .btn { min-height: 40px; padding-inline: 0.55rem; }
  .project-list { grid-template-columns: 1fr; }
  .chat-header { align-items: flex-start; padding: 0.85rem; }
  .chat-header .btn { padding-inline: 0.65rem; }
  .mode-switch { width: 100%; }
  .mode-switch-btn { flex: 1; padding-inline: 0.3rem; }
  .message-scroll { padding: 1rem 0.75rem; }
  .message { grid-template-columns: 30px minmax(0, 1fr); gap: 0.45rem; }
  .message.user { grid-template-columns: minmax(0, 1fr) 30px; }
  .message-avatar { width: 30px; height: 30px; }
  .message-body { padding: 0.75rem; }
  .composer { padding: 0.65rem; }
  .composer-box { grid-template-columns: 1fr; }
  .composer .btn { width: 100%; min-height: 46px; }
  .composer-meta { display: block; }
  .composer-meta span { display: block; margin-top: 0.2rem; }
  .welcome-grid, .mode-grid { grid-template-columns: 1fr; }
  .welcome { margin-top: 1rem; }
  .mode-card { min-height: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .stat-card { min-height: 115px; padding: 0.8rem; }
  .stat-card dd { font-size: 1.55rem; }
  .admin-content { padding: 0.75rem; }
  .view-heading { align-items: flex-start; }
  .view-heading .btn { width: 100%; }
  .detail-panel { padding: 0.85rem; }
  .editor-actions { bottom: -0.85rem; margin: 0 -0.85rem -0.85rem; padding: 0.85rem; }
  .dialog-header, .dialog-body, .dialog-footer { padding-inline: 1rem; }
  .dialog-footer { flex-wrap: wrap; }
  .dialog-footer .btn { flex: 1; }
  .definition-list { grid-template-columns: 1fr; gap: 0.2rem; }
  .definition-list dd { margin-bottom: 0.6rem; }
}
:focus-visible { outline: 4px solid rgba(184, 92, 56, 0.16); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.field input, .field textarea, .field select, .input { min-height: 52px; padding: 12px; }
.field input:disabled, .field textarea:disabled, .field select:disabled, .input:disabled { background: var(--surface-soft); }
.brand { gap: 12px; }
.brand-name { font-size: 18px; line-height: 1.3; }
.brand-sub { margin-top: 4px; font-size: 12px; line-height: 1.3; }
.admin-entry { margin-top: 24px; text-align: center; }
.admin-entry .btn { color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }
.auth-page { grid-template-columns: minmax(0, 1.12fr) minmax(400px, 0.88fr); }
.auth-intro { padding: 48px; }
.auth-copy { padding: 48px 0; }
.auth-copy h1 { font-size: 40px; line-height: 1.3; letter-spacing: -1px; }
.auth-copy > p:not(.eyebrow) { margin-top: 24px; font-size: 16px; line-height: 1.8; }
.auth-points { gap: 24px; margin-top: 32px; padding-top: 24px; }
.auth-points strong { margin-bottom: 8px; font-size: 14px; }
.auth-points span, .auth-foot { font-size: 12px; }
.auth-panel { padding: 48px; }
.auth-box h2 { margin-bottom: 16px; font-size: 28px; line-height: 1.3; }
.auth-box > p { margin-bottom: 32px; font-size: 15px; line-height: 1.8; }
.auth-box form { gap: 24px; }
.auth-note { gap: 12px; margin-top: 24px; padding: 24px 0 0; font-size: 12px; }
.topbar { min-height: 72px; gap: 16px; padding: 12px 24px; background: var(--surface); backdrop-filter: none; }
.topbar-actions { gap: 8px; }
.font-tools .btn { min-height: 40px; font-size: 12px; }
.user-badge { min-height: 44px; padding: 4px 12px 4px 4px; font-size: 14px; }
.avatar { width: 36px; height: 36px; font-size: 12px; }
.consult-layout { height: calc(100vh - 72px); height: calc(100dvh - 72px); grid-template-columns: 272px minmax(380px, 1fr) 304px; gap: 16px; padding: 16px; }
.project-sidebar { padding: 16px; }
.insight-panel { padding: 16px; }
.panel-heading { gap: 12px; margin-bottom: 16px; padding: 0; }
.panel-heading h2, .panel-heading h3 { font-size: 18px; }
.project-list { gap: 8px; margin-top: 16px; }
.project-item { min-height: 112px; padding: 12px; border-radius: 12px; }
.project-item-title { margin-bottom: 8px; font-size: 14px; }
.project-item-summary, .project-item-meta { font-size: 12px; }
.chat-header { min-height: 84px; gap: 16px; padding: 16px 24px; }
.chat-header h1, .chat-header h2 { font-size: 18px; line-height: 1.3; }
.chat-header p { font-size: 12px; }
.chat-header-actions { gap: 12px; }
.mode-switch-btn { min-height: 40px; padding: 8px 12px; border-radius: 8px; font-size: 12px; }
.message-scroll { padding: 24px 32px; }
.messages { gap: 24px; }
.message { grid-template-columns: 32px minmax(0, 1fr); gap: 12px; }
.message.user { grid-template-columns: minmax(0, 1fr) 32px; }
.message-avatar { width: 32px; height: 32px; font-size: 12px; }
.message-body { padding: 16px; border-radius: 4px 12px 12px 12px; }
.message.user .message-body { border-radius: 12px 4px 12px 12px; }
.message-meta, .message-references { font-size: 12px; }
.quick-label { font-size: 12px; }
.quick-options { gap: 8px; }
.quick-option { min-height: 40px; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.composer { padding: 16px 32px; }
.composer-box { gap: 8px; padding: 4px; border-radius: 16px; }
.composer textarea { padding: 12px; }
.composer-meta { margin-top: 8px; font-size: 12px; }
.welcome-prompt { padding: 16px; border-radius: 12px; }
.insight-section { padding-bottom: 24px; margin-bottom: 24px; }
.insight-section h2, .insight-section h3 { margin-bottom: 16px; font-size: 18px; }
.knowledge-list { gap: 12px; }
.knowledge-card { padding: 12px; }
.knowledge-card strong { font-size: 14px; }
.knowledge-card p, .knowledge-source { font-size: 12px; }
.memory-list li { font-size: 14px; }
.skeleton { background: var(--paper); }
.skeleton-lines span { background: #e4ded8; border-radius: 8px; }
dialog { overflow: hidden; border-radius: 18px; box-shadow: 0 32px 80px rgba(31, 30, 28, 0.24); }
dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
dialog > form { min-height: 0; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
.dialog-header { gap: 16px; padding: 24px; }
.dialog-header h2 { font-size: 22px; line-height: 1.3; }
.dialog-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.dialog-body { min-height: 0; max-height: none; padding: 24px; }
.dialog-footer { position: relative; z-index: 2; gap: 12px; padding: 16px 24px; }
.plan-document { color: var(--ink); }
.plan-document h3 { margin: 8px 0 16px; font-size: 28px; }
.plan-summary { margin-bottom: 16px; padding: 16px; border-radius: 12px; font-size: 14px; }
.plan-section { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 16px; padding: 12px 0; }
.plan-section h4 { grid-column: 1; margin: 0; font-size: 16px; }
.plan-section > :not(h4) { grid-column: 2; margin: 0; }
.mode-card { min-height: 256px; gap: 16px; padding: 24px; border-radius: 16px; }
.mode-card strong { font-size: 22px; }
.mode-card > span:not(.mode-number) { font-size: 15px; }
.mode-card b { font-size: 13px; }
.mode-number { padding: 4px 8px; border-radius: 8px; font-size: 12px; }
.admin-topbar { min-height: 80px; padding: 16px 24px; }
.admin-topbar h1 { font-size: 20px; }
.admin-topbar p { font-size: 12px; }
.admin-content { padding: 24px; }
.view-heading { gap: 16px; margin-bottom: 16px; }
.view-heading h2 { font-size: 22px; }
.view-heading p { margin-top: 4px; font-size: 13px; }
.admin-nav button { min-height: 48px; gap: 12px; padding: 12px; border-radius: 10px; font-size: 14px; }
.admin-nav button.active { box-shadow: inset 4px 0 0 var(--teal); }
.stats-grid { gap: 16px; margin-bottom: 24px; }
.stat-card { min-height: 112px; padding: 16px; border-radius: 12px; }
.stat-card dt { font-size: 13px; }
.stat-card dd { margin-top: 8px; font-size: 32px; }
.stat-card small { margin-top: 4px; font-size: 12px; }
.data-panel, .selection-list, .detail-panel { border-radius: 12px; }
th, td { padding: 12px 16px; }
th, .table-sub { font-size: 12px; }
.filter-btn { min-height: 40px; padding: 8px 12px; font-size: 14px; }
@media (max-width: 1280px) {
  .consult-layout { grid-template-columns: 250px minmax(360px, 1fr); height: auto; min-height: calc(100dvh - 72px); }
}
@media (max-width: 800px) {
  .auth-page { grid-template-columns: 1fr; }
  .consult-layout { display: block; grid-template-columns: 1fr; height: auto; min-height: 0; }
  .auth-intro { min-height: 312px; padding: 24px; }
  .auth-copy { padding: 32px 0 0; }
  .auth-copy h1 { font-size: 32px; }
  .auth-copy > p:not(.eyebrow) { font-size: 14px; }
  .auth-panel { padding: 24px; }
  button, .btn, .mode-switch-btn, .quick-option, .filter-btn, .admin-nav button { min-height: 44px; }
  .consult-layout { padding: 8px; }
  .project-sidebar { margin-bottom: 8px; }
  .insight-panel { margin-top: 8px; }
  .admin-sidebar-foot .btn { color: #d4c9c1; }
}
@media (max-width: 560px) {
  .app-shell > .topbar { flex-wrap: wrap; align-content: center; gap: 8px; padding: 12px; }
  .app-shell > .topbar .brand { width: 100%; }
  .app-shell > .topbar .brand-name { max-width: none; font-size: 18px; }
  .app-shell > .topbar .brand-sub { display: block; }
  .app-shell > .topbar .topbar-actions { width: 100%; flex-wrap: nowrap; justify-content: space-between; gap: 4px; }
  .app-shell > .topbar .btn { min-height: 44px; padding: 8px; font-size: 12px; }
  .app-shell > .topbar .font-tools .btn { min-height: 44px; }
  .chat-panel { height: 640px; min-height: 640px; grid-template-rows: auto minmax(0, 1fr) auto; }
  .chat-header { gap: 12px; padding: 12px; }
  .chat-header h1 { font-size: 16px; }
  .chat-header-actions { gap: 8px; }
  .mode-switch-btn { padding: 8px 4px; }
  .message-scroll { min-height: 0; max-height: none; padding: 16px 12px; }
  .messages { gap: 16px; }
  .message { grid-template-columns: 32px minmax(0, 1fr); gap: 8px; }
  .message.user { grid-template-columns: minmax(0, 1fr) 32px; }
  .message-avatar { width: 32px; height: 32px; }
  .message-body { padding: 12px; }
  .composer { padding: 12px; }
  .composer .btn { min-height: 44px; }
  .auth-copy h1 { font-size: 28px; }
  .auth-box h2 { font-size: 22px; }
  .auth-note { display: none; }
  .admin-entry { margin-top: 16px; }
  .admin-topbar { min-height: 72px; padding: 12px; }
  .admin-content { padding: 12px; }
  .stats-grid { gap: 12px; }
  .stat-card { min-height: 112px; padding: 12px; }
  .stat-card dd { font-size: 28px; }
  #knowledge-content .data-panel, #users-content .data-panel { overflow: visible; background: var(--paper); border: 0; }
  #knowledge-content .table-wrap, #users-content .table-wrap { overflow: visible; }
  #knowledge-content table, #knowledge-content tbody, #knowledge-content tr, #knowledge-content td,
  #users-content table, #users-content tbody, #users-content tr, #users-content td { display: block; width: 100%; }
  #knowledge-content thead, #users-content thead { display: none; }
  #knowledge-content tbody tr, #users-content tbody tr { margin-bottom: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
  #knowledge-content td, #users-content td { padding: 4px 0; border: 0; }
  #knowledge-content td::before, #users-content td::before { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 650; }
  #knowledge-content td:nth-child(1)::before, #users-content td:nth-child(1)::before { content: "知识标题"; }
  #knowledge-content td:nth-child(2)::before, #users-content td:nth-child(2)::before { content: "分类与行业"; }
  #knowledge-content td:nth-child(3)::before, #users-content td:nth-child(3)::before { content: "标签与来源"; }
  #knowledge-content td:nth-child(4)::before, #users-content td:nth-child(4)::before { content: "版本 / 状态"; }
  #knowledge-content td:nth-child(5)::before, #users-content td:nth-child(5)::before { content: "操作"; }
  #users-content td:nth-child(1)::before { content: "用户"; }
  #users-content td:nth-child(2)::before { content: "工厂与行业"; }
  #users-content td:nth-child(3)::before { content: "岗位角色"; }
  #users-content td:nth-child(4)::before { content: "状态"; }
  #knowledge-content td:last-child, #users-content td:last-child { padding-top: 12px; }
  #knowledge-content td .btn, #users-content td .btn { margin: 0 8px 0 0; }
  dialog { width: calc(100vw - 32px); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
  dialog.dialog-wide { width: calc(100vw - 32px); }
  .dialog-header, .dialog-body { padding: 16px; }
  .dialog-footer { flex-wrap: nowrap; padding: 16px; }
  .dialog-footer .btn { min-width: 0; padding-inline: 12px; }
  .plan-section { grid-template-columns: 1fr; gap: 8px; }
  .plan-section h4, .plan-section > :not(h4) { grid-column: 1; }
}
.agents-dialog { width: min(1100px, 94vw); }
.agents-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; color: var(--muted); font-size: 13px; }
.agents-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.agent-card { display: flex; flex-direction: column; min-height: 230px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.agent-card h3 { margin: 10px 0 8px; font-size: 17px; }
.agent-card p { margin: 0 0 12px; color: var(--muted); line-height: 1.65; font-size: 13px; }
.agent-card-top, .agent-meta, .agent-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.agent-kind, .agent-default, .agent-state { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.agent-kind { color: var(--teal); background: var(--teal-pale); }
.agent-default { color: var(--warning); background: var(--warning-pale); }
.agent-state { margin-left: auto; color: var(--muted); background: var(--surface-soft); }
.agent-state.enabled { color: var(--success); background: var(--success-pale); }
.agent-meta { margin-top: auto; color: var(--muted); font-size: 12px; }
.agent-actions { margin-top: 12px; }
.agent-detail-description { color: var(--muted); line-height: 1.8; }
.agent-list { display: grid; gap: 6px; padding-left: 20px; line-height: 1.7; }
.agent-doc-text { max-height: 360px; margin: 8px 0 0; padding: 16px; overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; font-family: inherit; font-size: 13px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }

.plan-ready-card { margin-top: 8px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: 12px; }
.plan-ready-kicker { color: var(--teal); font-size: 12px; font-weight: 700; }
.plan-ready-card h3 { margin: 6px 0 10px; font-size: 18px; }
.plan-ready-card p { margin: 0 0 14px; line-height: 1.75; }
.plan-ready-card .btn { min-width: 128px; }
.plan-ready-note { margin: 12px 0 0 !important; color: var(--muted); font-size: 12px; }

.message-brand-logo { display: block; width: 100%; height: 100%; object-fit: contain; }
.message-avatar:has(.message-brand-logo) { padding: 2px; background: var(--surface); border: 1px solid var(--line); }

.knowledge-link { padding: 0; color: var(--teal); background: transparent; border: 0; font: inherit; font-size: inherit; text-align: left; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.knowledge-link:hover { color: var(--teal-hover); }
.kb-flags { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.kb-flag { display: block; padding: 5px 8px; color: var(--muted); background: var(--surface-soft); border-radius: 6px; font-size: 12px; line-height: 1.5; }
.kb-flag-warning { color: var(--warning); background: var(--warning-pale); }
.kb-doc-text { margin: 0; color: var(--ink); background: transparent; border: 0; font-family: inherit; font-size: 14px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.kb-doc-sources { margin-top: 16px; padding-top: 12px; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media print {
  body { background: #fff; }
  .topbar, .project-sidebar, .chat-panel, .insight-panel, .dialog-header .icon-btn, .dialog-footer, .toast-region { display: none !important; }
  dialog[open] { position: static; display: block; width: 100%; max-height: none; border: 0; box-shadow: none; }
  dialog::backdrop { display: none; }
  .dialog-body { max-height: none; overflow: visible; }
}
