/* Theme variables live in shared/variables.css — loaded before this file. */

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg, #0f1117);
  color: var(--text, #e2e8f0);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Page header ────────────────────────────────────── */
.page-header {
  text-align: center;
  padding: 1.25rem 1.5rem 0.65rem;
  border-bottom: 1px solid var(--border, #2d3148);
  flex-shrink: 0;
}

.page-header h1 { font-size: 1.55rem; font-weight: 700; margin-bottom: 0.25rem; }
.page-header h1 .accent { color: var(--accent-3); }
.page-header p { color: var(--muted, #8892a4); font-size: 0.85rem; max-width: 640px; margin: 0 auto; line-height: 1.5; }

.back-link {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: var(--muted, #8892a4);
  text-decoration: none;
  font-size: 0.8rem;
}
.back-link:hover { color: var(--accent-3); }

/* ── Theme toggle ───────────────────────────────────── */
.theme-toggle {
  position: fixed;
  top: 0.75rem;
  right: 1rem;
  z-index: 100;
  background: var(--surface, #1a1d27);
  border: 1px solid var(--border, #2d3148);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text, #e2e8f0);
  line-height: 1;
}
.theme-toggle:hover { background: var(--surface-2, #22253a); }

/* ── Controls row (mode toggle + presets) ──────────── */
.controls-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border, #2d3148);
  background: var(--surface, #1a1d27);
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ── Mode toggle ────────────────────────────────────── */
.mode-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border, #2d3148);
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.mode-btn {
  background: var(--surface-2, #22253a);
  border: none;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  font-family: inherit;
  color: var(--muted, #8892a4);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.mode-btn:not(:last-child) { border-right: 1px solid var(--border, #2d3148); }
.mode-btn:hover { background: var(--highlight); color: var(--text, #e2e8f0); }
.mode-btn.active { background: var(--accent-3); color: #fff; }

/* ── Model status / progress ────────────────────────── */
.model-status {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border, #2d3148);
  background: var(--surface, #1a1d27);
  flex-shrink: 0;
}

.model-status-text {
  font-size: 0.78rem;
  color: var(--accent-3);
  margin-bottom: 0.3rem;
}

.model-progress-bar {
  height: 4px;
  background: var(--surface-2, #22253a);
  border-radius: 2px;
  overflow: hidden;
}

.model-progress-fill {
  height: 100%;
  background: var(--accent-3);
  border-radius: 2px;
  width: 0%;
  transition: width 0.2s ease;
}

/* ── Preset bar ─────────────────────────────────────── */
.preset-bar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.preset-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted, #8892a4);
  margin-right: 0.2rem;
}

.preset-btn {
  background: var(--surface-2, #22253a);
  border: 1px solid var(--border, #2d3148);
  border-radius: 20px;
  padding: 0.22rem 0.65rem;
  font-size: 0.75rem;
  color: var(--text, #e2e8f0);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}
.preset-btn:hover { background: var(--highlight); border-color: var(--accent-3); }
.preset-btn.active { background: var(--accent-3); border-color: var(--accent-3); color: #fff; }

/* ── Main layout ────────────────────────────────────── */
.attn-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: auto 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Input row ──────────────────────────────────────── */
.input-row {
  display: flex;
  align-items: stretch;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border, #2d3148);
  background: var(--surface, #1a1d27);
  flex-shrink: 0;
}

.sentence-input {
  flex: 1;
  background: var(--surface-2, #22253a);
  border: 1px solid var(--border, #2d3148);
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text, #e2e8f0);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  resize: vertical;
  min-height: 2.4rem;
  line-height: 1.5;
}
.sentence-input:focus { border-color: var(--accent-3); }

/* ── Head selector bar ──────────────────────────────── */
.head-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border, #2d3148);
  background: var(--surface, #1a1d27);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.head-row-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #8892a4);
}

.head-btn {
  background: var(--surface-2, #22253a);
  border: 1px solid var(--border, #2d3148);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text, #e2e8f0);
  cursor: pointer;
  transition: background 0.12s;
  font-family: inherit;
  font-weight: 600;
}
.head-btn:hover { background: var(--highlight); border-color: var(--accent-3); }
.head-btn.active { background: var(--accent-3); border-color: var(--accent-3); color: #fff; }

.head-label-text {
  font-size: 0.8rem;
  color: var(--accent-3);
  font-weight: 500;
  margin-left: 0.25rem;
}

/* ── Heatmap panel ──────────────────────────────────── */
.heatmap-panel {
  overflow: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  border-right: 1px solid var(--border, #2d3148);
}

#heatmap-canvas {
  display: block;
  cursor: crosshair;
  border-radius: 4px;
}

.heatmap-info {
  font-size: 0.78rem;
  color: var(--muted, #8892a4);
  min-height: 1.2em;
}

.preset-highlight {
  background: var(--highlight);
  border: 1px solid var(--accent-3);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  font-size: 0.78rem;
  color: var(--text, #e2e8f0);
  display: none;
  line-height: 1.4;
}

/* ── Arc diagram panel ──────────────────────────────── */
.arc-panel {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  gap: 0.6rem;
  overflow-y: auto;
  min-height: 0;
}

.arc-panel-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #8892a4);
}

#arc-canvas {
  display: block;
  border-radius: 4px;
}

.arc-sentence {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem;
  font-size: 0.82rem;
  line-height: 1.8;
}

.arc-tok {
  cursor: pointer;
  padding: 0.1rem 0.15rem;
  border-radius: 3px;
  transition: background 0.1s;
  white-space: pre;
}
.arc-tok:hover { background: var(--surface-2, #22253a); }
.arc-tok--focus { color: var(--accent-2); font-weight: 600; }
.arc-tok--connected { color: var(--accent-3); }

.threshold-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.threshold-label {
  font-size: 0.75rem;
  color: var(--muted, #8892a4);
  flex-shrink: 0;
}

.threshold-slider {
  flex: 1;
  min-width: 80px;
  accent-color: var(--accent-3);
}

.threshold-val {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-3);
  width: 2.5em;
  text-align: right;
}

/* ── Mobile layout ──────────────────────────────────── */
.mobile-tab-bar {
  display: none;
  gap: 0;
  border-bottom: 1px solid var(--border, #2d3148);
  background: var(--surface, #1a1d27);
  flex-shrink: 0;
}

.mobile-tab {
  flex: 1;
  padding: 0.5rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--muted, #8892a4);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.mobile-tab.active {
  color: var(--accent-3);
  border-bottom-color: var(--accent-3);
}

@media (max-width: 700px) {
  body { overflow: auto; }

  .mobile-tab-bar { display: flex; }

  .attn-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    overflow: visible;
  }

  .heatmap-panel {
    border-right: none;
    border-bottom: 1px solid var(--border, #2d3148);
    overflow: visible;
  }

  .arc-panel { overflow: visible; }

  .arc-panel.panel-hidden,
  .heatmap-panel.panel-hidden { display: none; }

  .input-row { flex-wrap: wrap; }
  .sentence-input { min-width: 0; }

  .controls-row { gap: 0.5rem; }
}
