:root {
  --font-sans: "Instrument Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-cjk: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --color-app: #f7f6f3;
  --color-sidebar: #efede8;
  --color-status: #f2f0ec;
  --color-panel: #ffffff;
  --color-dialog: #fbfaf8;
  --color-footer: #f5f4f0;
  --color-text: #1f1f1d;
  --color-text-2: rgba(0, 0, 0, 0.55);
  --color-border: rgba(0, 0, 0, 0.08);
  --color-gutter: rgba(0, 0, 0, 0.07);
  --color-accent: oklch(0.58 0.1 225);
  --color-accent-bg: oklch(0.95 0.02 225);
  --color-accent-text: oklch(0.42 0.09 225);
  --color-pinyin: oklch(0.5 0.07 225);
  --color-ok: oklch(0.5 0.12 160);
  --color-ok-dot: oklch(0.62 0.14 160);
}

* { box-sizing: border-box; }

html, body, #app {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--color-app);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
}

textarea {
  resize: none;
  border: none;
  outline: none;
  width: 100%;
  height: 100%;
  background: transparent;
  color: inherit;
}

.app-shell {
  display: flex;
  height: 100%;
  min-height: 0;
}

.sidebar {
  width: 188px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 16px;
}

.logo {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--color-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

.brand-name {
  font-weight: 600;
  font-size: 14px;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-2);
  padding: 0 4px;
  margin-bottom: 6px;
}

.sidebar-section {
  padding: 0 12px;
  margin-bottom: 20px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--color-text-2);
}

.nav-item:hover { background: rgba(255,255,255,0.5); }
.nav-item.active {
  background: #fff;
  color: var(--color-text);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.nav-item .badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-accent-text);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-dashed {
  border: 1px dashed rgba(0,0,0,0.18);
  border-radius: 999px;
  padding: 2px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-2);
}

.chip-dashed:hover:not(:disabled) {
  border-color: var(--color-accent);
  color: var(--color-accent-text);
}

.chip-dashed:disabled { opacity: 0.4; cursor: default; }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  padding: 12px;
}

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--color-panel);
  border-bottom: 1px solid var(--color-border);
}

.topbar h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pin-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
  background: var(--color-accent-bg);
  color: var(--color-accent-text);
}

.pin-pill.off {
  background: rgba(0,0,0,0.04);
  color: var(--color-text-2);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
}

.pin-pill.off .dot { background: rgba(0,0,0,0.25); }

.btn {
  border: 1px solid var(--color-border);
  background: #fff;
  border-radius: 7px;
  padding: 4px 12px;
  font-size: 12.5px;
}

.btn:hover { background: var(--color-app); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
  font-weight: 500;
}
.btn-primary:hover { filter: brightness(0.95); background: var(--color-accent); }

.panels {
  flex: 1;
  min-height: 0;
  display: flex;
}

.panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-panel);
}

.panel + .panel {
  border-left: 1px solid var(--color-gutter);
}

.panel-header {
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--color-border);
}

.panel-header select {
  border: none;
  background: transparent;
  font-weight: 600;
  font-size: 13.5px;
  max-width: 150px;
  outline: none;
}

.source-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent-text);
}

.spacer { flex: 1; }

.mode-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  padding: 2px;
  gap: 0;
}

.mode-toggle button {
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--color-text-2);
}

.mode-toggle button.active {
  background: var(--color-accent-bg);
  color: var(--color-accent-text);
  font-weight: 500;
}

.panel-body {
  flex: 1;
  min-height: 0;
  padding: 20px;
  overflow: auto;
}

.panel-body .en-text {
  font-size: 16.5px;
  line-height: 1.55;
}

.panel-body .zh-text {
  font-family: var(--font-cjk);
  font-size: 19px;
  line-height: 1.7;
}

.panel-body .pinyin-line {
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  color: var(--color-pinyin);
}

.panel-footer {
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-top: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-2);
}

.panel-footer .link {
  color: var(--color-accent-text);
}
.panel-footer .link:hover { text-decoration: underline; }
.panel-footer .err { color: #c0392b; }

.statusbar {
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--color-status);
  border-top: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-2);
}

.statusbar .left { display: flex; gap: 12px; }
.statusbar .ok { color: var(--color-ok); display: flex; align-items: center; gap: 6px; }
.statusbar .ok .dot { background: var(--color-ok-dot); }
.statusbar .warn { color: #a67c00; }
.statusbar .bad { color: #c0392b; }

/* Settings modal */
.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal {
  width: min(700px, 100%);
  max-height: 90vh;
  background: var(--color-dialog);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.3);
  display: flex;
  overflow: hidden;
}

.modal-nav {
  width: 170px;
  flex-shrink: 0;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
  padding: 12px;
}

.modal-nav h2 {
  margin: 0 0 8px 8px;
  font-size: 13px;
}

.modal-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.modal-content {
  flex: 1;
  overflow: auto;
  padding: 20px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--color-footer);
  border-top: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-2);
}

.field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-2);
  margin-bottom: 6px;
}

.field-box {
  border: 1px solid var(--color-border);
  border-radius: 9px;
  background: #fff;
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-text-2);
}

.banner-warn {
  margin-top: 16px;
  border: 1px solid oklch(0.85 0.06 60);
  background: oklch(0.97 0.02 80);
  color: oklch(0.45 0.08 90);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 12.5px;
}

.loading-progress {
  position: relative;
  display: block;
  width: 8rem;
  height: 8rem;
  margin: 20vh auto 1rem;
}

.loading-progress circle {
  fill: none;
  stroke: #e0e0e0;
  stroke-width: 0.6rem;
  transform-origin: 50% 50%;
  transform: rotate(-90deg);
}

.loading-progress circle:last-child {
  stroke: var(--color-accent, #4a7fa5);
  stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
  transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-2);
}

.loading-progress-text:after {
  content: var(--blazor-load-percentage-text, "Loading");
}

#blazor-error-ui {
  background: lightyellow;
  bottom: 0;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem 0.7rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}
