:root {
  --bg: #fafaf8;
  --paper: #ffffff;
  --soft: #f3f3ef;
  --line: #e6e5df;
  --line-2: #d2d0c8;
  --ink: #161614;
  --ink-2: #52514b;
  --ink-3: #838179;
  --brand: #3858e9;
  --brand-soft: #eef2ff;
  --bad: #b91c1c;
  --bad-soft: #fef2f2;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.surface { display: none; }
.surface.is-active { display: block; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--paper);
  color: var(--ink);
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #ffffff; }
.btn-brand:hover { background: #2c4ad3; border-color: #2c4ad3; }
.btn-ink { background: var(--ink); border-color: var(--ink); color: #ffffff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ================= PUBLIC PORTAL ================= */
.p-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 250, 248, .94);
  border-bottom: 1px solid var(--line);
}
.p-header-in {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.p-brand { display: inline-flex; align-items: center; gap: 10px; font-size: 16px; white-space: nowrap; }
.p-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--brand);
  color: var(--brand);
  background: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.p-nav { display: flex; gap: 24px; font-size: 14px; color: var(--ink-2); }
.p-nav a:hover { color: var(--ink); }

/* Portal Main Tool Hero */
.p-hero { padding: 40px 0 56px; }
.p-hero-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.p-hero-top h1 { margin: 0; font-size: 28px; font-weight: 400; line-height: 1.3; }
.p-hero-top p { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); }

.mode-switch {
  display: inline-flex;
  background: var(--soft);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--line);
}
.mode-switch button {
  border: 0;
  background: transparent;
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.mode-switch button.is-active { background: var(--paper); color: var(--ink); }

/* DeepL-inspired Dual-Pane Workbench Card */
.portal-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 26px rgba(22, 22, 20, .04);
}
.portal-pane { display: none; }
.portal-pane.is-active { display: block; }
.portal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #fcfcfb;
  flex-wrap: wrap;
}
.dual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.dual-grid > * { min-width: 0; }
.dual-left {
  padding: 20px 22px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dual-right {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.src-edit {
  width: 100%;
  min-height: 132px;
  border: 0;
  outline: 0;
  resize: vertical;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.75;
  background: transparent;
  color: var(--ink);
}
.out-main { font-size: 16px; line-height: 1.85; color: var(--ink); }
.out-compare {
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 13.5px;
  color: var(--ink-2);
}
.hl-ok { background: var(--brand-soft); color: var(--brand); padding: 1px 5px; border-radius: 4px; }
.hl-bad { background: var(--bad-soft); color: var(--bad); padding: 1px 4px; border-radius: 4px; text-decoration: line-through; }
.gloss-strip {
  border-top: 1px solid var(--line);
  padding: 14px 22px;
  background: #fcfcfb;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  font-size: 13px;
}
.gloss-chip { color: var(--ink-2); }
.gloss-chip strong { font-weight: 400; color: var(--brand); }

/* Dictionary Mode inside Portal */
.dict-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.dict-search input {
  flex: 1;
  border: 0;
  outline: 0;
  font-size: 16px;
  background: transparent;
  min-width: 0;
}
.dict-list { padding: 4px 22px 16px; }
.dict-entry {
  display: grid;
  grid-template-columns: 180px 140px 1fr 120px;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.dict-entry:last-child { border-bottom: 0; }

/* Commercial Showcase below fold */
.p-sec { padding: 52px 0; border-top: 1px solid var(--line); }
.p-sec-head { margin-bottom: 28px; }
.p-sec-head h2 { margin: 0 0 6px; font-size: 24px; font-weight: 400; }
.p-sec-head p { margin: 0; font-size: 14px; color: var(--ink-2); }
.pack-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.pack-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pack-card h3 { margin: 0; font-size: 17px; font-weight: 400; }
.pack-card p { margin: 0; font-size: 13.5px; color: var(--ink-2); flex: 1; }
.p-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0;
  font-size: 13px;
  color: var(--ink-3);
}
.p-footer-in { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* ================= QUIET WORKSPACE ================= */
.q-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.q-bar-in {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.q-layout {
  display: grid;
  grid-template-columns: 204px 1fr;
  gap: 28px;
  padding: 28px 0 64px;
  align-items: start;
}
.q-layout > * { min-width: 0; }
.q-menu { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 82px; }
.q-menu-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
}
.q-menu-btn:hover { background: var(--soft); color: var(--ink); }
.q-menu-btn.is-active { background: var(--paper); color: var(--brand); box-shadow: inset 0 0 0 1px var(--line); }
.q-view { display: none; }
.q-view.is-active { display: block; }
.q-sheet {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 16px;
}
.q-sheet h2 { margin: 0 0 4px; font-size: 18px; font-weight: 400; }
.q-sheet-sub { margin: 0 0 16px; font-size: 13px; color: var(--ink-3); }
.table-scroll { overflow-x: auto; max-width: 100%; }
.table-scroll table { min-width: 560px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-weight: 400; color: var(--ink-3); font-size: 12.5px; }
tr:last-child td { border-bottom: 0; }
.field {
  border: 1px solid var(--line-2);
  background: var(--paper);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 13.5px;
  outline: 0;
  min-width: 0;
}
.field:focus { border-color: var(--brand); }
.muted { color: var(--ink-3); }
.text-brand { color: var(--brand); }
.text-bad { color: var(--bad); }
.nowrap { white-space: nowrap; }
.row-flex { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-layout[hidden], .denied-wrap[hidden] { display: none; }
.denied-wrap {
  padding: 72px 16px;
  display: flex;
  justify-content: center;
}
.denied-card {
  width: 100%;
  max-width: 460px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 28px;
  text-align: center;
}
.denied-ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.denied-card h1 { margin: 0 0 8px; font-size: 20px; font-weight: 400; }
.denied-card p { margin: 0 0 22px; font-size: 13.5px; color: var(--ink-2); }
.denied-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.status-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--soft);
  color: var(--ink-2);
}
.status-pill.is-active { background: var(--brand-soft); color: var(--brand); }
.status-pill.is-draft { background: #fef9c3; color: #854d0e; }
.neg-chip {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bad-soft);
  color: var(--bad);
  font-family: var(--mono);
  font-size: 12px;
}
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.code-pre {
  margin: 0;
  background: #171715;
  color: #f3f2ed;
  border-radius: 9px;
  padding: 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  overflow-x: auto;
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--ink);
  color: #ffffff;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  z-index: 40;
}
.toast.is-show { opacity: 1; }

@media (max-width: 880px) {
  .wrap { padding: 0 16px; }
  .p-nav, .p-brand .mono { display: none; }
  .p-hero { padding: 24px 0 36px; }
  .p-hero-top h1 { font-size: 22px; }
  .dual-grid, .pack-grid, .q-layout, .form-grid { grid-template-columns: 1fr; }
  .dual-left { border-right: 0; border-bottom: 1px solid var(--line); }
  .dict-entry { grid-template-columns: 1fr; gap: 4px; }
  .q-menu { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .q-bar-in { height: auto; padding: 10px 0; flex-wrap: wrap; }
  .mode-switch { flex-wrap: wrap; }
}
