:root {
  font-family: "Segoe UI Variable", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  color: #172537;
  background: #f4f7f6;
  font-synthesis: none;
  --ink: #172537;
  --sub: #526575;
  --quiet: #607383;
  --line: #dbe4e6;
  --surface: #fff;
  --wash: #f1f5f4;
  --nav: #111c2b;
  --nav-panel: #1a2b3b;
  --nav-ink: #e4edf2;
  --nav-sub: #a7b9c5;
  --teal: #0a6556;
  --teal-dark: #064e43;
  --mint: #8be1c8;
  --error: #9c3021;
  --shadow: 0 18px 60px #172c3d15;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, input, textarea { font: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .56; }
a { color: var(--teal); text-underline-offset: .26em; }
:focus-visible { outline: 3px solid #37b19c; outline-offset: 3px; }
[hidden] { display: none !important; }
.startup { min-height: 100dvh; display: flex; gap: 12px; align-items: center; justify-content: center; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: var(--mint); color: #102b30; font: 800 1.3rem/1 system-ui; flex: none; }
.brand-type { font-size: .9rem; letter-spacing: .1em; font-weight: 700; }
.brand small { display: block; font-size: .78rem; letter-spacing: .08em; margin-top: 4px; font-weight: 500; }
.icon { width: 20px; height: 20px; display: inline-block; vertical-align: middle; flex: none; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border-radius: 11px; padding: 0 15px; border: 1px solid transparent; color: var(--ink); background: transparent; font-weight: 650; line-height: 1.3; white-space: nowrap; text-decoration: none; }
.primary { background: var(--teal); color: #fff; }
.primary:hover { background: var(--teal-dark); }
.outline { background: #fff; border-color: var(--line); }
.outline:hover, .ghost:hover { background: var(--wash); border-color: var(--line); }
.icon-button { min-width: 42px; padding: 0 9px; }
.text-button { padding: 0; border: 0; background: none; color: var(--teal); font-weight: 650; min-height: 42px; text-decoration: none; }
.text-button:hover { text-decoration: underline; }
.field { display: grid; gap: 7px; font-size: .9rem; font-weight: 650; min-width: 0; }
.field small { color: var(--quiet); font-weight: 500; font-size: .8rem; }
.input { width: 100%; height: 47px; border-radius: 10px; border: 1px solid #cbd7db; background: #fff; color: var(--ink); padding: 0 12px; font-size: 1rem; }
.input::placeholder, textarea::placeholder { color: #667887; opacity: 1; }
.input:focus { border-color: var(--teal); outline-offset: 1px; }
.notice { color: var(--error); font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; }
.notice:empty { display: none; }
.muted { color: var(--quiet); }
.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; }

.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(360px, .95fr) minmax(430px, 1.05fr); }
.auth-brand { position: relative; overflow: hidden; isolation: isolate; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(30px, 5vw, 78px); color: var(--nav-ink); background: #101c2b; }
.auth-brand::before { content: ""; position: absolute; z-index: -2; inset: 0; background: radial-gradient(ellipse at 30% 53%, #193d45 0, transparent 62%), linear-gradient(150deg,#111b2b 15%,#0b2530 100%); }
.auth-brand::after { content: ""; position: absolute; z-index: -1; inset: 0; opacity: .35; background: repeating-linear-gradient(0deg,transparent 0 47px,#a9e2d515 47px 48px),repeating-linear-gradient(90deg,transparent 0 47px,#a9e2d515 47px 48px); mask-image: linear-gradient(130deg,transparent 2%,#000 45%,#000 80%); }
.auth-brand .brand { position: relative; }
.auth-brand small { color: var(--nav-sub); }
.auth-display { position: relative; padding: 30px 0 64px; isolation: isolate; }
.auth-display::before { content: ""; position: absolute; width: clamp(250px,34vw,540px); aspect-ratio: 1; border-radius: 50%; right: -37%; top: -100%; z-index: -1; border: 1px solid #a6e9dc36; box-shadow: 0 0 0 34px #59c5b00b,0 0 0 66px #59c5b00b,0 0 0 98px #59c5b00b; }
.auth-display h1 { font-size: clamp(2.7rem, 5vw, 5.25rem); line-height: 1.03; letter-spacing: -.07em; margin: 0 0 16px; font-weight: 760; }
.auth-display p { margin: 0; color: #b8d5d2; letter-spacing: .12em; font-size: 1.02rem; }
.auth-panel { display: grid; align-items: center; justify-items: center; padding: 40px 30px; background: #f5f8f7; }
.auth-card { width: min(100%, 420px); background: #fff; border: 1px solid #e1e8ea; border-radius: 22px; box-shadow: var(--shadow); padding: 34px; }
.auth-card h2 { margin: 0 0 24px; font-size: 1.65rem; letter-spacing: -.045em; }
.auth-mode { display: flex; gap: 16px; margin-top: 20px; justify-content: space-between; flex-wrap: wrap; }
.auth-card form, .compact-form { display: grid; gap: 16px; }
.row { display: flex; gap: 8px; align-items: end; min-width: 0; }
.row > .input { flex: 1; min-width: 0; }
.row > .button { min-height: 47px; }

.shell { height: 100dvh; display: grid; grid-template-columns: 270px minmax(0, 1fr); overflow: hidden; }
.rail { color: var(--nav-ink); background: var(--nav); min-width: 0; overflow: hidden; display: flex; flex-direction: column; padding: 23px 15px 14px; gap: 15px; }
.rail .brand { margin: 1px 6px 9px; }
.rail small { color: var(--nav-sub); }
.rail .new { background: #202f41; color: var(--nav-ink); border-color: #405260; justify-content: flex-start; }
.rail .new:hover { background: #273a4d; }
.rail-search { display: flex; align-items: center; gap: 7px; color: var(--nav-sub); border: 1px solid #3b4d5c; border-radius: 10px; padding: 0 9px; min-width: 0; min-height: 39px; }
.rail-search input { color: #f0f5f7; border: 0; background: transparent; width: 100%; min-width: 0; outline: 0; font-size: .84rem; }
.rail-search input::placeholder { color: var(--nav-sub); }
.rail-search:focus-within { outline: 2px solid var(--mint); }
.rail-search .icon { width: 15px; height: 15px; }
.history { flex: 1; overflow-y: auto; scrollbar-color: #586b77 transparent; display: flex; flex-direction: column; gap: 3px; }
.history-item { text-align: left; color: var(--nav-ink); background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 10px 9px; width: 100%; display: grid; gap: 5px; min-height: 52px; }
.history-item:hover { background: #203141; }
.history-item.active { background: #203b43; border-color: #41645f; }
.history-item strong { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item span { font-size: .72rem; color: var(--nav-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-footer { border-top: 1px solid #364756; padding: 10px 4px 0; color: var(--nav-sub); display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .85rem; }
.rail-footer button { color: inherit; padding: 0 7px; min-height: 36px; }
.rail-footer button:hover { background: var(--nav-panel); }
.rail-empty { margin: 10px; color: var(--nav-sub); font-size: .87rem; line-height: 1.6; }
.rail .notice { color: #ffc5b9; }
.mobile-menu, .drawer-shade { display: none; }

.workspace { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #f8faf9; }
.workspace-bar { height: 66px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 26px; border-bottom: 1px solid var(--line); background: #fff; }
.workspace-bar h1 { font-size: 1.08rem; line-height: 1.3; margin: 0; }
.heading-group { display: flex; gap: 9px; align-items: center; min-width: 0; }
.title { min-width: 0; }
.title h1 { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.sku-label { color: var(--quiet); font-size: .78rem; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; gap: 10px; align-items: center; }
.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--sub); font-size: .83rem; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #7e8d96; }
.status.online::before { background: #0d8069; }
.toolbar-label { margin-left: 2px; }
.empty { flex: 1; display: grid; place-items: center; overflow: auto; padding: 25px; }
.empty-card { max-width: 570px; width: 100%; align-self: center; padding: clamp(21px,4vw,42px); border: 1px solid #dce6e5; background: #fff; border-radius: 22px; box-shadow: var(--shadow); }
.empty-card h2 { margin: 0 0 23px; font-size: 1.7rem; line-height: 1.2; letter-spacing: -.045em; }
.empty-card:focus { outline: 0; }
.sku-form { display: grid; grid-template-columns: minmax(0,1.32fr) minmax(0,1fr); gap: 16px; }
.sku-form .notice, .sku-form .button { grid-column: 1/-1; }
.sku-form .button { justify-self: start; min-width: 96px; }
.transcript { flex: 1; overflow-y: auto; overscroll-behavior: contain; min-height: 0; padding: 26px max(22px, calc((100% - 760px)/2)); scrollbar-color: #bccace transparent; }
.transcript .turn { margin-bottom: 28px; }
.transcript .line { display: flex; gap: 11px; align-items: flex-start; min-width: 0; }
.transcript .line + .line { margin-top: 15px; }
.transcript .user-line { justify-content: end; }
.bubble { color: var(--ink); background: #fff; max-width: min(100%, 720px); min-width: 0; border: 1px solid var(--line); border-radius: 15px; padding: 13px 16px; font-size: 1rem; line-height: 1.65; overflow-wrap: anywhere; }
.bubble p { margin: 0 0 10px; }
.bubble > :last-child { margin-bottom: 0; }
.user-line .bubble { background: #e6f4ef; border-color: #c9e3d9; white-space: pre-wrap; max-width: 85%; }
.bubble h3, .bubble h4 { margin: .4em 0; line-height: 1.3; }
.bubble ul, .bubble ol { margin: 5px 0 12px; padding-left: 1.5em; }
.bubble pre { overflow: auto; background: #f0f5f5; border: 1px solid #e1e7e8; border-radius: 8px; padding: 10px; font-size: .84rem; }
.bubble code { background: #eff3f5; border-radius: 4px; padding: 0 3px; }
.bubble pre code { padding: 0; background: none; }
.assistant-avatar { border-radius: 11px; width: 32px; height: 32px; display: grid; place-items: center; flex: none; color: #073d34; background: #b9e6d8; font-weight: 800; font-size: .9rem; }
.file-tag { display: inline-flex; align-items: center; gap: 5px; color: #344e5c; background: #eaf1f2; border: 1px solid #d5dfe2; border-radius: 8px; padding: 3px 7px; font-size: .8rem; overflow-wrap: anywhere; max-width: 100%; white-space: normal; }
.file-tag .icon { width: 15px; height: 15px; }
.turn .files { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.pending::after { content: ""; width: 12px; height: 12px; margin-left: 10px; border: 2px solid #c2d4d4; border-top-color: var(--teal); border-radius: 100%; display: inline-block; animation: roll .9s linear infinite; }
@keyframes roll { to { transform: rotate(360deg); } }
.composer { flex: none; padding: 10px max(22px, calc((100% - 760px)/2)) max(16px, env(safe-area-inset-bottom)); background: #f8faf9; }
.compose-box { background: #fff; border: 1px solid #cddbdc; box-shadow: 0 6px 20px #18313b0b; border-radius: 17px; padding: 10px 11px; }
.compose-box:focus-within { border-color: #72a69a; }
.compose-box textarea { border: none; resize: none; width: 100%; min-height: 47px; max-height: 130px; line-height: 1.5; padding: 6px 5px; color: var(--ink); background: transparent; outline: 0; font-size: 1rem; display: block; }
.compose-actions { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.compose-actions .button { min-height: 39px; }
.composer .notice { margin: 0 0 6px; }
.compose-files { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 0 0 5px; min-width: 0; }
.compose-files:empty { display: none; }
.compose-file-remove { background: none; border: 0; padding: 0 3px; font-weight: 800; color: var(--sub); cursor: pointer; min-height: 24px; }
.blank-chat { color: var(--quiet); font-size: .92rem; padding: 15px 0; }

.admin-nav { display: grid; gap: 5px; }
.admin-nav button { justify-content: flex-start; color: var(--nav-ink); }
.admin-nav button.active, .admin-nav button:hover { background: #233848; border-color: #405862; }
.admin-scroll { flex: 1; min-height: 0; overflow: auto; padding: 23px 25px; }
.admin-panel { max-width: 1040px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px 19px; }
.admin-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 9px; margin-bottom: 13px; }
.admin-filters .input { height: 42px; width: min(100%, 223px); }
.record { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(0,1fr) auto; gap: 12px; align-items: center; min-height: 57px; border-top: 1px solid var(--line); padding: 9px 0; font-size: .91rem; overflow-wrap: anywhere; }
.record:first-of-type { border-top: 0; }
.record small { display: block; color: var(--quiet); margin-top: 4px; }
.record .button { min-height: 36px; }
.record .directory { font-size: .81rem; color: var(--quiet); }
.admin-panel h2 { margin: 0 0 15px; font-size: 1.2rem; }
.audit-list { margin-top: 20px; }
.audit-row { padding: 9px 0; border-top: 1px solid var(--line); font-size: .85rem; overflow-wrap: anywhere; }
.pagination { display: flex; gap: 8px; margin: 12px 0 0; }
.long { overflow-wrap: anywhere; }
.version-dialog { width: min(calc(100% - 28px), 420px); max-width: none; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); padding: 24px; box-shadow: var(--shadow); }
.version-dialog h2 { margin: 0; font-size: 1.3rem; }
.version-dialog::backdrop { background: #15263688; }
.admin-panel .transcript { padding: 12px 0; overflow: visible; min-height: 0; }

@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-brand { padding: 20px 22px; }
  .auth-display { padding: 23px 0 3px; }
  .auth-display::before { width: 330px; right: -27%; top: -155%; }
  .auth-display h1 { font-size: 2.18rem; margin-bottom: 6px; }
  .auth-display p { font-size: .85rem; }
  .auth-panel { padding: 23px 17px 30px; align-items: start; }
  .auth-card { padding: 22px; border-radius: 17px; }
  .auth-card h2 { margin-bottom: 17px; font-size: 1.42rem; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { visibility: hidden; position: fixed; z-index: 12; top: 0; bottom: 0; left: 0; width: min(83vw, 315px); height: 100dvh; transform: translateX(-100%); }
  .shell.drawer .rail { visibility: visible; transform: none; }
  .shell.drawer .drawer-shade { display: block; position: fixed; z-index: 11; inset: 0; border: 0; background: #132c46a3; }
  .mobile-menu { display: inline-flex; padding: 0 7px; flex: none; }
  .mobile-menu .icon { width: 17px; height: 17px; }
  .workspace-bar { height: 59px; padding: 0 9px; }
  .workspace-bar h1 { font-size: .99rem; }
  .bar-actions { gap: 5px; }
  .bar-actions .button { padding: 0 8px; }
  .bar-actions .status { font-size: .75rem; gap: 4px; }
  .status::before { width: 6px; height: 6px; }
  .transcript { padding: 17px 11px 8px; }
  .assistant-avatar { width: 26px; height: 26px; border-radius: 8px; }
  .transcript .line { gap: 6px; }
  .bubble { padding: 9px 11px; }
  .composer { padding: 6px 9px max(7px, env(safe-area-inset-bottom)); }
  .compose-box { border-radius: 12px; padding: 6px 7px; }
  .empty { padding: 15px; }
  .sku-form { grid-template-columns: 1fr; gap: 12px; }
  .sku-form .button { justify-self: stretch; }
  .admin-scroll { padding: 13px 9px; }
  .admin-panel { padding: 13px; }
  .record { grid-template-columns: minmax(0,1fr) auto; gap: 7px; }
  .record .directory { grid-row: 2; grid-column: 1/-1; }
  .record .button:last-child { grid-column: 2; grid-row: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; scroll-behavior: auto !important; }
}
