/* Prism Translate — workstation / options styles. Premium dark theme. */
:root {
  --bg: #0c0a16;
  --bg-2: #0f0d1a;
  --panel: #16132a;
  --panel-2: #1d1938;
  --panel-3: #251f44;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #ece9f8;
  --muted: #9a95b8;
  --faint: #8782a6;
  --accent: #6366f1;
  --accent-2: #ec4899;
  --grad: linear-gradient(135deg, #6366f1, #ec4899);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}
[data-theme="light"] {
  --bg: #f4f3fb;
  --bg-2: #eceaf6;
  --panel: #ffffff;
  --panel-2: #f5f3fc;
  --panel-3: #ece9f8;
  --line: rgba(20, 18, 40, 0.1);
  --line-strong: rgba(20, 18, 40, 0.18);
  --text: #1b1930;
  --muted: #5f5b7e;
  --faint: #6f6b8c;
  --shadow: 0 18px 50px rgba(80, 70, 140, 0.14);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  /* Chinese typography defaults */
  word-break: keep-all;
  overflow-wrap: break-word;
  hanging-punctuation: allow-end;
}
h1, h2, h3 { word-break: keep-all; text-wrap: balance; }
p { text-wrap: pretty; }
code {
  font: 13px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--panel-2);
  padding: 1px 6px; border-radius: 5px; color: var(--accent-2);
  white-space: nowrap;
}
.num { white-space: nowrap; }

/* ---------------- sidebar ---------------- */
.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; padding: 0 6px; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--grad);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
}
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  background: transparent; color: var(--muted);
  border: none; border-radius: 10px;
  padding: 11px 13px; font-size: 14px; cursor: pointer;
  text-align: left; transition: background 0.12s, color 0.12s;
}
.nav-item span { font-size: 16px; width: 20px; text-align: center; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.side-foot { display: flex; flex-direction: column; gap: 10px; }
.side-foot .ver { color: var(--faint); font-size: 11px; text-align: center; }
.ghost {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 12px; font-size: 13px; cursor: pointer;
}
.ghost:hover { background: var(--panel-2); border-color: var(--accent); }
.ghost.danger:hover { border-color: var(--err); color: var(--err); }

/* ---------------- main ---------------- */
.main { flex: 1; min-width: 0; padding: 34px 42px 80px; max-width: 1100px; }
.tab.hidden { display: none; }
.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0 0 6px; font-size: 24px; }
.page-head .sub { margin: 0; color: var(--muted); font-size: 14px; max-width: 46ch; }

.primary {
  background: var(--grad); color: #fff; border: none;
  border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; box-shadow: 0 6px 18px rgba(99, 102, 241, 0.32);
  transition: filter 0.12s, transform 0.1s;
}
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: scale(0.98); }
.primary:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); }
select, input[type="text"], input[type="password"], input[type="number"], textarea {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; font-size: 14px; font-family: inherit;
}
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18); }

/* ---------------- workstation ---------------- */
.ws-controls { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.ws-controls .arrow { color: var(--faint); font-size: 18px; padding-bottom: 9px; }
.ws-controls .field select { min-width: 140px; }
.chip-btn {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  width: 38px; height: 38px; cursor: pointer; font-size: 15px;
}
.chip-btn:hover { background: var(--panel-2); border-color: var(--accent); }

.ws-providers { margin-bottom: 14px; }
.ws-providers > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; font-size: 13px; cursor: pointer; user-select: none;
  transition: all 0.12s;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.chip.on { background: var(--panel-3); color: var(--text); border-color: var(--accent); }
.chip.on .dot { background: var(--accent-2); }
.chip.disabled { opacity: 0.45; cursor: not-allowed; }

.ws-input {
  width: 100%; min-height: 150px; resize: vertical;
  line-height: 1.7; margin-bottom: 10px;
}
.ws-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.ws-actions .spacer { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }

.ws-results { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.result-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
  animation: prism-rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.result-card:nth-child(2) { animation-delay: 0.07s; }
.result-card:nth-child(3) { animation-delay: 0.14s; }
.result-card:nth-child(4) { animation-delay: 0.21s; }
@keyframes prism-rise {
  from { opacity: 0; transform: translateY(12px); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}
@media (prefers-reduced-motion: reduce) { .result-card { animation: none; } }
.result-card.best { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.rc-head { display: flex; align-items: center; gap: 9px; }
.rc-head .name { font-weight: 600; font-size: 14px; }
.rc-head .model { color: var(--faint); font-size: 12px; }
.rc-head .badge-best {
  margin-left: auto; background: var(--grad); color: #fff;
  font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 600;
}
.rc-body { font-size: 15px; line-height: 1.75; white-space: pre-wrap; min-height: 40px; }
.rc-body.loading { color: var(--muted); font-style: italic; }
.rc-body.error { color: var(--err); font-size: 13px; }
.rc-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.rc-meta b { color: var(--text); font-weight: 600; white-space: nowrap; }
.rc-meta .fast { color: var(--ok); }
.rc-meta .copy { margin-left: auto; cursor: pointer; color: var(--accent); }
.rc-meta .copy:hover { text-decoration: underline; }

/* ---------------- providers ---------------- */
.add-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.add-bar select { min-width: 180px; }
.prov-list { display: flex; flex-direction: column; gap: 14px; }
.prov-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
}
.prov-card.disabled { opacity: 0.62; }
.prov-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.prov-top .ptype {
  font-size: 11px; background: var(--panel-3); color: var(--accent-2);
  padding: 3px 9px; border-radius: 6px; white-space: nowrap;
}
.prov-top .pname { font-weight: 600; font-size: 16px; flex: 1; background: transparent; border: none; color: var(--text); }
.prov-top .pname:focus { outline: none; border-bottom: 1px solid var(--accent); }
.prov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.prov-grid .full { grid-column: 1 / -1; }
.prov-field { display: flex; flex-direction: column; gap: 5px; }
.prov-field label { font-size: 12px; color: var(--muted); }
.prov-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.prov-actions .spacer { flex: 1; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.switch input { width: 0; height: 0; opacity: 0; position: absolute; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--panel-3); position: relative; transition: background 0.15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.test-result { font-size: 12px; padding: 4px 0; }
.test-result.ok { color: var(--ok); }
.test-result.err { color: var(--err); }
.key-wrap { display: flex; gap: 6px; }
.key-wrap input { flex: 1; }
.key-wrap button { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 0 10px; cursor: pointer; font-size: 12px; }

/* ---------------- prompts ---------------- */
.prompt-list { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.prompt-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.prompt-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.prompt-top .pname { font-weight: 600; font-size: 15px; background: transparent; border: none; color: var(--text); flex: 1; }
.prompt-top .pname:focus { outline: none; border-bottom: 1px solid var(--accent); }
.prompt-top .builtin-tag { font-size: 11px; color: var(--faint); background: var(--panel-2); padding: 2px 8px; border-radius: 6px; }
.prompt-card textarea { width: 100%; min-height: 80px; resize: vertical; line-height: 1.6; }
.prompt-card.builtin textarea { opacity: 0.85; }

/* ---------------- glossary ---------------- */
.gloss-table, .usage-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.gloss-table th, .usage-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.gloss-table td, .usage-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.gloss-table input { width: 100%; }
.gloss-table .del, .usage-table .del { color: var(--err); cursor: pointer; background: none; border: none; font-size: 16px; }
.usage-table td.num { white-space: nowrap; }

/* ---------------- usage ---------------- */
.usage-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 28px; }
.ucard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.ucard .label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.ucard .val { font-size: 26px; font-weight: 700; white-space: nowrap; }
.ucard .val small { font-size: 14px; color: var(--muted); font-weight: 400; }
.usage-detail h3 { font-size: 16px; margin: 0 0 4px; }
#usage-reset { margin-top: 18px; }

/* ---------------- settings ---------------- */
.settings-grid { display: flex; flex-direction: column; gap: 4px; max-width: 620px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.set-row label { font-size: 14px; }
.set-row label small { display: block; color: var(--faint); font-size: 12px; margin-top: 2px; }
.set-row select, .set-row input[type="number"] { min-width: 180px; }
.set-row input[type="number"] { width: 100px; min-width: 0; text-align: right; }
.toggle-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.saved-hint { color: var(--ok); font-size: 13px; margin-top: 18px; opacity: 0; transition: opacity 0.2s; }
.saved-hint.show { opacity: 1; }

/* ---------------- toast ---------------- */
#toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--panel-3); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 10px 18px; font-size: 13px; box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
}
.toast.err { border-color: var(--err); color: var(--err); }
.toast.ok { border-color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.empty { color: var(--faint); font-size: 14px; padding: 30px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
