:root {
  --bg: #FBFBFA;
  --surface: #FFFFFF;
  --surface-subtle: #F7F6F3;
  --border: #EAEAEA;
  --text: #111111;
  --text-body: #2F3437;
  --text-muted: #787774;

  --pastel-green-bg: #EDF3EC;
  --pastel-green-fg: #346538;
  --pastel-blue-bg: #E1F3FE;
  --pastel-blue-fg: #1F6C9F;
  --pastel-yellow-bg: #FBF3DB;
  --pastel-yellow-fg: #956400;
  --pastel-red-bg: #FDEBEC;
  --pastel-red-fg: #9F2F2D;

  --font-sans: "SF Pro Display", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Newsreader", "Georgia", "Songti SC", "STSong", serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Menlo", "Consolas", monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text-body);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.ambient-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 18% 12%, rgba(180, 168, 140, 0.045), transparent 52%);
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* Header */
.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  color: var(--text);
}

.brand-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.user-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Main & Typography */
.main-content {
  padding-top: 48px;
  padding-bottom: 84px;
}

.hero-block {
  max-width: 780px;
  margin-bottom: 36px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 10px 0;
}

.editorial-title {
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text);
  margin: 0 0 14px 0;
}

.subtitle {
  margin: 0;
  font-size: 15px;
  color: var(--text-muted);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text);
}

.section-heading {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}

.muted-text {
  color: var(--text-muted);
  margin: 4px 0 0 0;
}

.small-text {
  font-size: 13px;
}

.strong-text {
  color: var(--text);
  font-weight: 600;
}

.meta-mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* Cards & Bento */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  transition: box-shadow 200ms ease;
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-card {
  max-width: 540px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.text-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: border-color 150ms ease;
}

.text-input:focus {
  border-color: #111111;
}

.mono-input {
  font-family: var(--font-mono);
}

.work-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.bento-grid {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .bento-grid {
    grid-template-columns: 1fr;
  }
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 2px 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-neutral {
  background: var(--surface-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-green {
  background: var(--pastel-green-bg);
  color: var(--pastel-green-fg);
}

.badge-blue {
  background: var(--pastel-blue-bg);
  color: var(--pastel-blue-fg);
}

.badge-yellow {
  background: var(--pastel-yellow-bg);
  color: var(--pastel-yellow-fg);
}

.badge-red {
  background: var(--pastel-red-bg);
  color: var(--pastel-red-fg);
}

/* Buttons */
.btn-primary {
  background: #111111;
  color: #FFFFFF;
  border: 1px solid #111111;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, transform 120ms ease;
}

.btn-primary:hover {
  background: #333333;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 15px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.btn-outline:hover {
  border-color: #111111;
  background: var(--surface-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

/* Dropzone */
.dropzone {
  border: 1px dashed #CCCCCC;
  background: var(--surface-subtle);
  border-radius: 8px;
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: #111111;
  background: #F3F2EE;
}

.upload-icon {
  width: 30px;
  height: 30px;
  color: var(--text);
  margin-bottom: 8px;
}

.drop-title {
  margin: 0 0 6px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.dropzone .btn-outline {
  margin-top: 14px;
}

.selected-bar {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.selected-meta {
  display: flex;
  flex-direction: column;
}

.selected-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Radio Config */
.radio-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.radio-card.active {
  border-color: #111111;
  background: var(--surface-subtle);
}

.radio-card input[type="radio"] {
  margin-top: 4px;
  accent-color: #111111;
}

.radio-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-len-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.compact-input {
  width: 104px;
  padding: 5px 8px;
  font-size: 13px;
}

.spec-note {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Alerts & Progress */
.alert-box {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13.5px;
}

.alert-red {
  background: var(--pastel-red-bg);
  color: var(--pastel-red-fg);
  border: 1px solid rgba(159, 47, 45, 0.16);
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #111111;
  transition: width 220ms ease;
}

/* Results */
.results-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.download-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 20px 0;
}

@media (max-width: 720px) {
  .metrics-strip {
    grid-template-columns: repeat(2, 1fr);
  }
}

.metric-cell {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-subtle);
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 12px;
  color: var(--text-muted);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.compact-search {
  max-width: 280px;
  padding: 7px 11px;
  font-size: 13px;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-body);
  cursor: pointer;
}

.checkbox-inline input {
  accent-color: #111111;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #FAF9F6;
}

.align-right {
  text-align: right !important;
}

.ref-cell {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Inline AB1 Viewer */
.viewer-card {
  padding: 0;
  overflow: hidden;
}

.window-chrome {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.window-dots {
  display: flex;
  gap: 6px;
}

.window-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #E2E2DF;
  border: 1px solid #D4D4D0;
}

.viewer-controls {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.jump-group,
.slider-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 9px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-body);
  cursor: pointer;
}

.chip-btn:hover {
  border-color: #111111;
}

.chip-edit {
  background: var(--pastel-yellow-bg);
  color: var(--pastel-yellow-fg);
  border-color: rgba(149, 100, 0, 0.25);
}

.chip-het {
  background: var(--pastel-blue-bg);
  color: var(--pastel-blue-fg);
  border-color: rgba(31, 108, 159, 0.25);
}

.slider-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}

.slider-label input[type="range"] {
  width: 84px;
  accent-color: #111111;
}

.edited-chips-row {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.minimap-box {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: #0F172A;
  color: #CBD5E1;
}

.minimap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.channel-legend {
  display: flex;
  gap: 12px;
}

.channel-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.channel-legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.minimap-canvas {
  width: 100%;
  height: 36px;
  display: block;
  cursor: pointer;
}

.track-panel {
  padding: 12px 20px;
  background: #0F172A;
  color: #F1F5F9;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.track-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.trace-canvas {
  width: 100%;
  height: 220px;
  display: block;
  cursor: grab;
}

.trace-canvas:active {
  cursor: grabbing;
}

/* Footer & Reveal */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 500ms cubic-bezier(0.16, 1, 0.3, 1), transform 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
