:root {
  --bg: #f4f7fb;
  --card: #fff;
  --line: #e2eaf3;
  --line-strong: #d7e2ee;
  --text: #253c56;
  --heading: #173858;
  --muted: #74869a;
  --primary: #1677dc;
  --primary-dark: #0964c4;
  --primary-soft: #edf6ff;
  --ok: #218354;
  --warn: #a36a14;
  --err: #be4147;
  --navy: var(--heading);
  --navy-2: var(--primary-dark);
  --user: var(--primary-soft);
  --radius: 12px;
  --shadow: 0 4px 18px #17385f08;
  --font:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Microsoft YaHei",
    "PingFang SC",
    sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #65aceb;
  outline-offset: 2px;
}
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }

.top {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 56px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}
.brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  line-height: 1.15;
  min-width: 160px;
  text-decoration: none;
}
.brand-mark { width: 36px; height: 36px; flex-shrink: 0; display: block; object-fit: contain; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-sub { font-size: 11px; color: #8697a9; letter-spacing: 0.2px; }
.brand strong { font-size: 15px; color: var(--heading); font-weight: 650; letter-spacing: 0.2px; }
.nav { display: flex; gap: 4px; flex: 1; align-self: stretch; align-items: stretch; }
.nav a {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 0;
  border-bottom: 3px solid transparent;
  font-size: 14px;
  color: #6b8199;
}
.nav a:hover { color: var(--primary); background: transparent; }
.nav a.active {
  background: transparent;
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 650;
}
.top-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid #d4e1ee;
  border-radius: 8px;
  background: #fff;
  color: #42617e;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover:not(:disabled) { background: #f3f8fd; border-color: #a8c4df; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 3px 8px #1677dc22;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { color: #42617e; }
.btn-danger { color: var(--err); border-color: #f2d4d6; background: #fff; }
.btn-danger:hover:not(:disabled) { background: #fff0f0; border-color: #e8b4b8; }
.btn:disabled { opacity: 0.45; }

body.page-app {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
body.page-app #app {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
body.page-app .foot { display: none; }
body.page-app .workbench,
body.page-app .storage {
  height: 100%;
  min-height: 0;
}

.features {
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.features li {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 12px #20395e06;
  font-size: 14px;
  line-height: 1.7;
}
.features strong { display: block; margin-bottom: 4px; font-size: 14px; color: var(--heading); font-weight: 650; }
.features span { color: var(--muted); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 20px 48px; }
.page-title { margin: 0 0 8px; font-size: 24px; font-weight: 650; color: var(--heading); letter-spacing: 0.2px; }
.lead { margin: 0 0 20px; color: #66809a; font-size: 14px; line-height: 1.8; }

.hero {
  padding: 28px 28px 22px;
  border: 1px solid #d9e8f6;
  border-radius: 20px;
  background: linear-gradient(112deg, #f1f8ff, #eaf5ff 72%, #e1f0fd);
}
.hero h1 {
  margin: 0 0 10px;
  font-size: 28px;
  font-weight: 650;
  color: var(--heading);
  letter-spacing: 0.3px;
  line-height: 1.4;
}
.hero p { margin: 0 0 18px; max-width: 680px; color: #66809a; line-height: 1.8; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid-2, .grid-3 { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 6px; font-size: 15px; color: var(--heading); }
.card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; line-height: 1.9; }

.workbench {
  --left-w: 360px;
  --right-w: 240px;
  display: flex;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}
.panel {
  background: var(--card);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.workbench > .panel-left {
  flex: 0 0 var(--left-w);
  width: var(--left-w);
}
.workbench > .panel-right {
  flex: 0 0 var(--right-w);
  width: var(--right-w);
}
.splitter {
  flex: 0 0 6px;
  width: 6px;
  margin: 0 -3px;
  position: relative;
  z-index: 8;
  cursor: col-resize;
  background: transparent;
}
.splitter::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 1px;
  background: var(--line);
}
.splitter:hover::after,
.splitter.dragging::after {
  left: 1px;
  width: 3px;
  background: var(--primary);
}
.panel-head {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  height: 44px;
  background: #fff;
}
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 650; color: var(--heading); }
.panel-body { flex: 1; min-height: 0; overflow: auto; padding: 8px; scrollbar-width: thin; }
.search {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  margin-bottom: 8px;
  color: var(--text);
}
.search::placeholder { color: #98a8b9; }
.search:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px #1677dc1f; outline: none; }

.session-list { display: flex; flex-direction: column; }
.session-item {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 2px;
  cursor: pointer;
  color: var(--text);
}
.session-item:hover { background: #f3f8fd; }
.session-item.active { background: #edf6ff; }
.session-item:focus { outline: 2px solid #65aceb; outline-offset: -2px; }
.session-item .session-main { flex: 1; min-width: 0; }
.session-item .t { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--heading); }
.session-item .s { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.session-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-top: -2px;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #8eabc5;
}
.icon-btn:hover { background: #e8f2fb; color: var(--primary); }
.icon-btn.danger:hover { background: #fff0f0; color: var(--err); }
.icon-btn.starred { color: var(--warn); }

.chat {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}
.chat-meta {
  padding: 0 16px;
  height: 44px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  flex-shrink: 0;
  overflow: hidden;
}
.chat-meta span { white-space: nowrap; }
.chat-meta .meta-actions { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }
.chat-log { flex: 1; min-height: 0; overflow: auto; padding: 16px 20px 8px; scrollbar-width: thin; }
.msg { max-width: 72%; margin: 0 0 12px; }
.msg.user { margin-left: auto; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.bubble {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}
.msg.user .bubble { background: #edf6ff; border: 1px solid #d4e7f8; }
.msg.assistant .bubble {
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 3px 12px #20395e06;
}
.answer { white-space: pre-wrap; }
.thinking {
  margin: 0 0 8px;
  color: var(--muted);
}
.thinking-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #6b8199;
  font-size: 12px;
  line-height: 1.4;
}
.thinking-toggle::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid #8eabc5;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}
.thinking.open .thinking-toggle::before {
  transform: rotate(90deg);
}
.thinking-toggle:hover { color: var(--primary); }
.progress { margin: 6px 0 0; padding: 0 0 0 14px; font-size: 12px; color: var(--muted); }
.progress[hidden] { display: none; }
.progress li { list-style: none; margin: 2px 0; }
.progress li.current { color: var(--primary); font-weight: 650; }
.options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  border: 1px solid var(--line);
  background: #f6f9fc;
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
}
.chip:hover { background: #f3f8fd; border-color: #a8c4df; color: var(--primary); }

.composer {
  padding: 12px 16px 16px;
  background: #fff;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.composer textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
  background: #fff;
  color: var(--text);
}
.composer textarea::placeholder { color: #98a8b9; }
.composer textarea:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px #1677dc1f; }
.composer-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.composer-row input[type="text"] {
  height: 32px;
  width: 88px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 8px;
  background: #fff;
}
.composer-row input[type="text"]:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px #1677dc1f; outline: none; }
.hint { font-size: 12px; color: var(--muted); }
.customs-field {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}
.customs-combo {
  position: relative;
  width: min(240px, 100%);
  min-width: 0;
}
.customs-combo input[type="text"] {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 28px 0 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.customs-combo input[type="text"]::placeholder { color: #98a8b9; }
.customs-combo input[type="text"]:hover { border-color: #b7cbe0; }
.customs-combo input[type="text"]:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px #1677dc1f; outline: none; }
.customs-clear {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.customs-clear:hover { background: var(--primary-soft); color: var(--primary); }
.customs-list {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: calc(100% + 4px);
  max-height: 240px;
  margin: 0;
  padding: 4px;
  list-style: none;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.customs-list li {
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.customs-list li.is-active,
.customs-list li:hover { background: var(--primary-soft); }
.customs-list li.is-selected { color: var(--primary-dark); font-weight: 650; }
.customs-empty { padding: 8px; color: var(--muted); font-size: 12px; }

.aside-section { margin-bottom: 16px; }
.aside-section h3 { margin: 0 0 8px; font-size: 13px; color: var(--heading); font-weight: 650; }
.aside-section h3 .muted-count {
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
}
.aside-section h3.history-heading { margin-top: 16px; }
.result-current-meta {
  margin: -4px 0 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.result-history {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  background: #fff;
  overflow: hidden;
}
.result-history-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  background: #fbfdff;
  color: #5c7793;
  font-size: 12px;
  line-height: 1.45;
  cursor: pointer;
}
.result-history-toggle > span { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.result-history-toggle::before {
  content: "";
  flex: none;
  margin-top: 5px;
  width: 0;
  height: 0;
  border-left: 5px solid #8eabc5;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}
.result-history.open .result-history-toggle::before { transform: rotate(90deg); }
.result-history-toggle:hover { color: var(--primary); background: #f3f8fd; }
.result-history-title { font-weight: 650; color: var(--heading); }
.result-history-meta { color: var(--muted); font-size: 11px; word-break: break-word; }
.result-history-body { padding: 0 8px 8px; }
.result-history-body[hidden] { display: none; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

.kv {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  line-height: 1.7;
}
.kv th, .kv td {
  border: 0;
  border-bottom: 1px solid #e8eef5;
  padding: 8px 10px;
  vertical-align: top;
  text-align: left;
}
.kv th {
  width: 120px;
  background: #eff5fb;
  font-weight: 600;
  color: #5c7793;
  white-space: nowrap;
}
.kv tr:last-child th,
.kv tr:last-child td { border-bottom: 0; }
.result-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  line-height: 1.6;
}
.result-table th, .result-table td {
  border: 0;
  border-bottom: 1px solid #e8eef5;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.result-table th {
  background: #eff5fb;
  color: #5c7793;
  font-weight: 600;
  white-space: nowrap;
}
.result-table tbody tr:last-child td { border-bottom: 0; }
.result-table tbody tr:hover td { background: #f3f8fd; }
.status-ok { color: var(--ok); }
.status-ask { color: var(--warn); }
.status-err { color: var(--err); }

.storage {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}
.storage > .panel + .panel { border-left: 1px solid var(--line); }
.folder-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  color: var(--text);
}
.folder-item.active, .folder-item:hover { background: #edf6ff; color: var(--heading); }
.folder-item.active { color: var(--primary); font-weight: 650; }
.record {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: #fff;
  box-shadow: 0 3px 12px #20395e06;
}
.record h3 { margin: 0 0 4px; font-size: 15px; color: var(--heading); font-weight: 650; }
.record .meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.record-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.record-actions select {
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 8px;
  background: #fff;
  color: var(--text);
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px 18px;
  border-top: 0;
  background: transparent;
  color: #8b9db0;
  font-size: 12px;
}
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  background: #24415e;
  color: #fff;
  padding: 13px 18px;
  border-radius: 10px;
  font-size: 13px;
  max-width: min(420px, calc(100vw - 40px));
  box-shadow: 0 8px 30px #17385f26;
}

@media (max-width: 960px) {
  .splitter-right { display: none; }
  .workbench > .panel-right { display: none; }
  .workbench > .panel-right.open {
    display: flex;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(360px, 100%);
    z-index: 15;
    border-left: 1px solid var(--line);
    box-shadow: -12px 0 40px #17385f1a;
  }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .splitter { display: none; }
  .workbench { flex-direction: column; }
  .workbench > .panel-left,
  .workbench > .panel-right { flex: none; width: 100%; height: 180px; }
  .storage { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; height: auto; padding: 8px 12px; }
  .nav { align-self: auto; flex-wrap: wrap; }
  .nav a { height: 36px; border-bottom-width: 2px; }
  .hero { padding: 20px 16px; border-radius: 14px; }
  .hero h1 { font-size: 24px; }
  .msg { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
