/* Code Reviewer — navy + off-white surfaces, mint / coral / orange / teal accents from the logo */

:root {
  --space: 1.25rem;
  --radius-btn: 12px;
  --radius-card: 16px;
}

:root,
[data-theme="dark"] {
  --bg: #0a1020;
  --bg-elevated: #121c32;
  --card: #162238;
  --card-border: #2a3d5c;
  --text: #eef2f8;
  --text-muted: #a8b4c8;
  --accent: #5fd3a8;
  --accent-hover: #7ee0bb;
  --accent-soft: rgba(95, 211, 168, 0.22);
  --lesson: #f6a54a;
  --lesson-bg: rgba(246, 165, 74, 0.1);
  --input-bg: #0d1526;
  --header-bg: #162238;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-text: #fecaca;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  --gradient-sidebar: linear-gradient(180deg, #121c32 0%, #0a1020 100%);
  --gradient-panel: none;
  --switch-track-night: #334155;
  --switch-track-day: #243047;
  --switch-thumb-night: #1e2a3f;
  --switch-thumb-day: #5fd3a8;
  --sev-high: #ff7a6b;
  --sev-medium: #f6a54a;
  --sev-low: #5fb8c4;
  --primary: #1d7f60;
  --primary-hover: #23916d;
  --line-high: rgba(255, 122, 107, 0.1);
  --line-medium: rgba(246, 165, 74, 0.08);
  --line-low: rgba(95, 184, 196, 0.08);
  --scrollbar-track: #0a1020;
  --scrollbar-thumb: #121c32;
  --scrollbar-thumb-hover: #2a3d5c;
  --panel: #162238;
  --panel-inner: #121c32;
  --editor-bg: #0a111f;
  --editor-gutter: #0d1626;
  --editor-line: #5b6b86;
  --editor-border: #2a3d5c;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --editor-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  --body-glow: rgba(95, 211, 168, 0.1);
  --badge-bg: rgba(95, 211, 168, 0.08);
  --pill-bg: #243047;
  --pill-border: #3d4f6a;
  --pill-text: #d4dae3;
  --pill-hover: rgba(255, 255, 255, 0.06);
  --pill-active-text: #f4f3ef;
  --success-bg: rgba(34, 197, 94, 0.15);
  --success-text: #86efac;
  --switch-thumb-glow: rgba(107, 140, 175, 0.45);
}

/* Light mode: warm off-white surfaces, same navy accent */
[data-theme="light"] {
  --bg: #efe9dc;
  --bg-elevated: #e9e2d3;
  --card: #f3eee2;
  --card-border: #d6cdb9;
  --text: #2f3a4a;
  --text-muted: #555f6e;
  --accent: #1f7a5c;
  --accent-hover: #258a69;
  --accent-soft: rgba(31, 122, 92, 0.14);
  --lesson: #9a5a10;
  --lesson-bg: rgba(214, 128, 40, 0.1);
  --input-bg: #f7f2e6;
  --header-bg: #e7e0d0;
  --danger-bg: #f6e4df;
  --danger-text: #a3342b;
  --shadow: 0 8px 22px rgba(70, 55, 30, 0.08);
  --gradient-sidebar: linear-gradient(180deg, #e9e2d3 0%, #efe9dc 100%);
  --gradient-panel: none;
  --switch-track-night: #334155;
  --switch-track-day: #a9bdd6;
  --switch-thumb-night: #243047;
  --switch-thumb-day: #f6b73c;
  --scrollbar-track: #efe9dc;
  --scrollbar-thumb: #d6cdb9;
  --scrollbar-thumb-hover: #c7bda5;
  --sev-high: #b5412f;
  --sev-medium: #9a5a10;
  --sev-low: #2d6f7a;
  --primary: #1f7a5c;
  --primary-hover: #258a69;
  --line-high: rgba(181, 65, 47, 0.08);
  --line-medium: rgba(154, 90, 16, 0.08);
  --line-low: rgba(45, 111, 122, 0.08);
  --panel: #e7e0d0;
  --panel-inner: #f3eee2;
  --editor-bg: #f7f2e6;
  --editor-gutter: #eee7d6;
  --editor-line: #877f6a;
  --editor-border: #d6cdb9;
  --glass-bg: rgba(60, 50, 30, 0.04);
  --glass-border: rgba(60, 50, 30, 0.12);
  --editor-shadow: 0 6px 18px rgba(70, 55, 30, 0.08);
  --body-glow: rgba(95, 211, 168, 0);
  --badge-bg: rgba(31, 122, 92, 0.08);
  --pill-bg: #e7e0d0;
  --pill-border: #d6cdb9;
  --pill-text: #4a5360;
  --pill-hover: rgba(31, 122, 92, 0.09);
  --pill-active-text: #2f3a4a;
  --success-bg: rgba(22, 120, 70, 0.12);
  --success-text: #26683f;
  --switch-thumb-glow: rgba(246, 183, 60, 0.55);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  overscroll-behavior-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.result-sections::-webkit-scrollbar,
.editor-shell .CodeMirror-scroll::-webkit-scrollbar,
.fix-code-block::-webkit-scrollbar,
.result-body pre::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
.result-sections::-webkit-scrollbar-track,
.editor-shell .CodeMirror-scroll::-webkit-scrollbar-track,
.fix-code-block::-webkit-scrollbar-track,
.result-body pre::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
.result-sections::-webkit-scrollbar-thumb,
.editor-shell .CodeMirror-scroll::-webkit-scrollbar-thumb,
.fix-code-block::-webkit-scrollbar-thumb,
.result-body pre::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid var(--scrollbar-track);
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
.result-sections::-webkit-scrollbar-thumb:hover,
.editor-shell .CodeMirror-scroll::-webkit-scrollbar-thumb:hover,
.fix-code-block::-webkit-scrollbar-thumb:hover,
.result-body pre::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.result-sections,
.fix-code-block,
.result-body pre {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

@media print {
  .sidebar,
  .editor-panel,
  .editor-toolbar,
  .editor-actions,
  .results-toolbar,
  .theme-switch,
  .fix-dialog {
    display: none !important;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .result-sections,
  .summary-card {
    break-inside: avoid;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Alexandria", system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(ellipse 80% 50% at 50% -20%, var(--body-glow), transparent);
  color: var(--text);
  line-height: 1.6;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w, 240px) minmax(0, 1fr);
  min-height: 100vh;
  direction: ltr; /* sidebar stays on the left in both languages */
}

html[dir="rtl"] .sidebar,
html[dir="rtl"] .main {
  direction: rtl;
}

.sidebar {
  background: var(--gradient-sidebar);
  border-right: 1px solid var(--card-border);
  padding: var(--space);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space);
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: start;
}

.sidebar-resizer {
  position: absolute;
  top: 0;
  right: -5px;
  width: 10px;
  height: 100%;
  z-index: 5;
  cursor: col-resize;
  touch-action: none;
  outline: none;
}

.sidebar-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 2px;
  background: transparent;
  transition: background 0.15s ease;
}

.sidebar-resizer:hover::after,
.sidebar-resizer:focus-visible::after,
body.is-resizing .sidebar-resizer::after {
  background: var(--accent);
}

/* Spring back after the elastic overscroll offset (set from script.js) */
.is-bouncing-back {
  transition: transform 0.55s cubic-bezier(0.22, 1.35, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  html,
  .result-sections {
    scroll-behavior: auto;
  }
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--card-border);
  text-align: center;
}

.select-input,
.code-editor {
  width: 100%;
  font-family: "Alexandria", ui-monospace, monospace;
  font-size: 1rem;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
}

.select-input:focus,
.code-editor:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.main {
  padding: var(--space);
  display: flex;
  flex-direction: column;
  gap: var(--space);
  min-width: 0;
}

.header-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.pill-group {
  display: inline-flex;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  border-radius: calc(var(--radius-btn) + 2px);
  padding: 4px;
  gap: 2px;
}

.pill-btn {
  border: none;
  background: transparent;
  color: var(--pill-text);
  border-radius: var(--radius-btn);
  min-width: 2.5rem;
  min-height: 2.35rem;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.pill-btn:hover {
  background: var(--pill-hover);
}

.pill-btn.active {
  background: var(--accent-soft);
  color: var(--pill-active-text);
  box-shadow: 0 0 12px var(--accent-soft);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, var(--split, 50%)) 14px minmax(0, 1fr);
  gap: 0;
  flex: 1;
  direction: ltr; /* editor left, analysis right */
}

html[dir="rtl"] .panel {
  direction: rtl;
}

.split-divider {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
  outline: none;
}

.split-grip {
  width: 4px;
  height: 44px;
  border-radius: 999px;
  background: var(--card-border);
  transition: background 0.15s ease, height 0.15s ease, width 0.15s ease;
}

.split-divider:hover .split-grip,
.split-divider:focus-visible .split-grip,
body.is-resizing .split-grip {
  background: var(--accent);
  height: 72px;
  width: 5px;
}

.split-divider:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-soft);
  border-radius: 8px;
}

body.is-resizing {
  cursor: col-resize;
  user-select: none;
}

body.is-resizing .panel {
  pointer-events: none;
}

.panel {
  background: var(--panel);
  background-image: var(--gradient-panel);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1rem 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 520px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.panel:hover {
  border-color: var(--accent-soft);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.select-input {
  width: auto;
  min-width: 160px;
}

.editor-shell {
  flex: 1;
  min-height: 340px;
  border: 1px solid var(--editor-border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--editor-bg);
  box-shadow: var(--editor-shadow);
  direction: ltr;
}

.editor-shell .CodeMirror {
  height: 100%;
  min-height: 340px;
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.55;
}

/* Override CodeMirror's own theme colors so the editor reads as a separate card in both modes */
.editor-shell .CodeMirror {
  background: var(--editor-bg);
}

[data-theme="light"] .editor-shell .CodeMirror {
  color: var(--text);
}

.editor-shell .CodeMirror-gutters {
  background: var(--editor-gutter);
  border-right: 1px solid var(--editor-border);
}

.editor-shell .CodeMirror-linenumber {
  min-width: 2.2ch;
  padding: 0 0.7rem 0 0.5rem;
  font-size: 0.78rem;
  color: var(--editor-line);
}

.editor-shell .CodeMirror-activeline-background,
.editor-shell .CodeMirror-focused .CodeMirror-activeline-background {
  background: var(--accent-soft);
}

.btn-sm {
  min-height: 38px;
  padding: 0.45rem 0.95rem;
  font-size: 0.88rem;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--text);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.loading-bar {
  height: 3px;
  background: var(--input-bg);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.loading-bar-fill {
  height: 100%;
  width: 35%;
  background: linear-gradient(90deg, var(--accent), #93c5fd);
  border-radius: inherit;
  transform: translateX(-100%);
}

.loading-bar.active .loading-bar-fill {
  animation: load-slide 1.2s ease-in-out infinite;
}

@keyframes load-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(320%);
  }
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  border: 1px dashed var(--card-border);
  border-radius: 14px;
  margin-top: 0.5rem;
  background:
    radial-gradient(circle at 50% 28%, var(--accent-soft), transparent 62%),
    linear-gradient(160deg, var(--panel-inner), transparent 70%);
}

.empty-state p {
  margin: 0;
  max-width: 28ch;
  font-size: 1rem;
}

.empty-art {
  width: min(190px, 60%);
  height: auto;
  color: var(--accent);
}

.empty-art .art-core {
  fill: var(--accent-soft);
  transform-box: fill-box;
  transform-origin: center;
  animation: art-pulse 2.8s ease-in-out infinite;
}

.empty-art .art-spark {
  transform-box: fill-box;
  transform-origin: center;
  animation: art-twinkle 2.8s ease-in-out infinite;
}

@keyframes art-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

@keyframes art-twinkle {
  0%, 100% { opacity: 0.6; transform: scale(0.9) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.15) rotate(20deg); }
}

@media (prefers-reduced-motion: reduce) {
  .empty-art .art-core,
  .empty-art .art-spark,
  .status-badge.loading::before {
    animation: none;
  }
}

.result-card-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0;
  margin-bottom: 0.45rem;
  cursor: pointer;
  text-align: inherit;
}

.badge-count {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.result-body.collapsed {
  display: none;
}

.finding-item summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.finding-item summary::-webkit-details-marker {
  display: none;
}

/* Chevron so collapsed findings read as expandable (native marker is hidden above) */
.finding-item summary::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-inline-end: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.finding-item[open] summary::after {
  transform: rotate(-135deg);
}

.severity-badge {
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
}

.sev-high {
  background: rgba(248, 113, 113, 0.2);
  color: var(--sev-high);
}

.sev-medium {
  background: rgba(251, 191, 36, 0.2);
  color: var(--sev-medium);
}

.finding-title {
  font-weight: 600;
  flex: 1;
}

.finding-line {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: "JetBrains Mono", monospace;
}

.finding-body {
  margin-top: 0.5rem;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.finding-body p {
  margin: 0 0 0.35rem;
}

.finding-fix {
  margin: 0.35rem 0 0;
  padding-top: 0.35rem;
  border-top: 1px solid var(--card-border);
}

.fix-dialog {
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 0;
  max-width: min(720px, 92vw);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
}

.fix-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.fix-dialog-inner {
  padding: 1rem 1.15rem 1.15rem;
  margin: 0;
}

.fix-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.fix-dialog-head h3 {
  margin: 0;
}

.fix-explanation {
  font-size: 0.92rem;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.fix-code-block {
  margin: 0.75rem 0;
  padding: 0.85rem;
  max-height: 320px;
  overflow: auto;
  background: var(--input-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
}

.fix-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.editor-actions {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.btn {
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  padding: 0.65rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

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

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-secondary {
  background: transparent;
  border-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

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

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

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  background: var(--accent-soft);
  color: var(--text-muted);
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.status-badge.loading {
  color: var(--accent);
  border-color: var(--accent);
}

.status-badge.loading::before {
  animation: badge-pulse 1s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.5); opacity: 1; }
}

.status-badge.success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: color-mix(in srgb, var(--success-text) 35%, transparent);
}

.status-badge.success::before,
.status-badge.error::before {
  opacity: 1;
}

.status-badge.error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: color-mix(in srgb, var(--danger-text) 35%, transparent);
}

.error-box {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.error-box.lang-hint {
  background: var(--accent-soft);
  color: var(--text);
  border: 1px solid var(--accent);
}

.hidden {
  display: none !important;
}

.result-card h3 {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
}

.result-body {
  font-size: 0.98rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.result-body .placeholder {
  margin: 0;
  opacity: 0.65;
}

.result-body pre {
  background: var(--input-bg);
  border-radius: 10px;
  padding: 0.75rem;
  overflow: auto;
  font-size: 0.88rem;
}

.result-body code {
  font-family: ui-monospace, Consolas, monospace;
}

.footer-credit {
  font-size: 0.82rem;
  opacity: 0.88;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.footer-credit:hover,
.footer-credit:focus-visible {
  color: var(--accent);
  opacity: 1;
}

/* Visible color change while the link is pressed */
.footer-credit:active {
  color: #e5a50a;
  opacity: 1;
}

/* =========================================================================
   Accessibility
   ========================================================================= */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Visually hidden until focused (clip instead of an off-screen transform, which can leak into
   full-page captures and print). */
.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-btn);
  background: var(--accent);
  color: #f4f3ef;
  font-weight: 600;
  text-decoration: none;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
}

.skip-link:focus {
  clip-path: none;
  width: auto;
  height: auto;
  overflow: visible;
}

.result-body .placeholder {
  opacity: 0.85;
}

/* =========================================================================
   Sidebar history
   ========================================================================= */

.history {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.history-head h2 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.history-clear {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.2rem 0.5rem;
}

.history-clear:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
}

.history-empty {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.history-item {
  position: relative;
  display: flex;
  align-items: stretch;
}

.history-open {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  text-align: start;
  font: inherit;
  color: var(--text);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 0.5rem 1.9rem 0.5rem 0.7rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

html[dir="rtl"] .history-open {
  padding: 0.5rem 0.7rem 0.5rem 1.9rem;
}

.history-open:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.history-title {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.history-dot {
  position: absolute;
  top: 0.65rem;
  inset-inline-end: 1.6rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sev-high);
}

.history-delete {
  position: absolute;
  top: 50%;
  inset-inline-end: 0.35rem;
  transform: translateY(-50%);
  width: 1.4rem;
  height: 1.4rem;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.history-item:hover .history-delete,
.history-delete:focus-visible {
  opacity: 1;
}

.history-delete:hover {
  color: var(--danger-text);
  background: var(--danger-bg);
}

/* =========================================================================
   Editor extras: counter, shortcut hint, file drop
   ========================================================================= */

.editor-shell {
  position: relative;
}

.editor-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.char-count {
  font-variant-numeric: tabular-nums;
}

.char-count.warn {
  color: var(--sev-medium);
}

.char-count.over {
  color: var(--sev-high);
  font-weight: 600;
}

.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  direction: ltr;
}

kbd {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  border: 1px solid var(--card-border);
  border-bottom-width: 2px;
  background: var(--panel-inner);
  color: var(--text);
}

.kbd-label {
  margin-inline-start: 0.25rem;
}

.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--editor-bg) 80%, transparent);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  color: var(--accent);
  font-weight: 600;
  pointer-events: none;
}

.cm-flash-line {
  background: var(--accent-soft) !important;
  transition: background 0.4s ease;
}

/* =========================================================================
   Results: progress, skeleton, severity filter
   ========================================================================= */

.progress-text {
  margin: 0 0 0.6rem;
  font-size: 0.88rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-btn);
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.stat-chip b {
  font-variant-numeric: tabular-nums;
}

.stat-chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.stat-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.stat-chip.sev-high b {
  color: var(--sev-high);
}

.stat-chip.sev-medium b {
  color: var(--sev-medium);
}

.stat-chip.sev-low b {
  color: var(--sev-low);
}

.result-sections[data-filter="high"] .finding-item:not([data-sev="high"]),
.result-sections[data-filter="medium"] .finding-item:not([data-sev="medium"]),
.result-sections[data-filter="low"] .finding-item:not([data-sev="low"]) {
  display: none;
}

button.finding-line {
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  padding: 0.1rem 0.4rem;
  color: var(--accent);
}

button.finding-line:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* =========================================================================
   Fix dialog: tabs + diff
   ========================================================================= */

.fix-dialog:not(.confirm-dialog) {
  width: min(900px, 94vw);
  max-width: none;
}

.tabs {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-btn);
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.diff-stats {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.diff-view {
  margin: 0.75rem 0;
  max-height: 380px;
  overflow: auto;
  border: 1px solid var(--editor-border);
  border-radius: 10px;
  background: var(--editor-bg);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.84rem;
  line-height: 1.55;
}

.diff-row {
  display: grid;
  grid-template-columns: 3rem 3rem 1.4rem 1fr;
  min-width: max-content;
}

.diff-row code {
  white-space: pre;
  font-family: inherit;
  padding-inline-end: 1rem;
}

.diff-no {
  text-align: end;
  padding-inline-end: 0.6rem;
  color: var(--editor-line);
  user-select: none;
}

.diff-sign {
  text-align: center;
  font-weight: 600;
  user-select: none;
}

.diff-add {
  background: rgba(34, 197, 94, 0.14);
}

.diff-add .diff-sign {
  color: var(--success-text);
}

.diff-del {
  background: rgba(239, 68, 68, 0.14);
}

.diff-del .diff-sign {
  color: var(--sev-high);
}

.diff-gap {
  padding: 0.25rem 0.9rem;
  color: var(--editor-line);
  background: var(--editor-gutter);
  font-size: 0.78rem;
  user-select: none;
}

.confirm-dialog {
  width: min(420px, 92vw);
}

.confirm-text {
  margin: 0 0 1rem;
  font-size: 1rem;
  line-height: 1.6;
}

/* =========================================================================
   Toasts
   ========================================================================= */

.toasts {
  position: fixed;
  inset-block-end: 1.25rem;
  inset-inline-end: 1.25rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2.5rem));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-btn);
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  cursor: pointer;
  pointer-events: auto;
  animation: toast-in 0.22s ease-out;
}

.toast-out {
  animation: toast-out 0.2s ease-in forwards;
}

.toast-icon {
  flex-shrink: 0;
  width: 1.3rem;
  height: 1.3rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--accent-soft);
  color: var(--accent);
}

.toast-success .toast-icon {
  background: var(--success-bg);
  color: var(--success-text);
}

.toast-error .toast-icon {
  background: var(--danger-bg);
  color: var(--danger-text);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* =========================================================================
   404 page
   ========================================================================= */

.notfound-body {
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.notfound {
  max-width: 460px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.notfound h1 {
  margin: 0;
  font-size: 1.3rem;
}

.notfound-text {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.notfound-code {
  margin: 0;
  font-size: 4.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
}

.notfound .btn {
  text-decoration: none;
  display: inline-block;
}

/* Numeric readouts keep left-to-right order inside the RTL layout. */
.char-count,
.diff-stats {
  direction: ltr;
  unicode-bidi: isolate;
}

/* =========================================================================
   Header, icons, app frame
   ========================================================================= */

:root {
  --header-h: 60px;
}

.icon {
  width: 1.05em;
  height: 1.05em;
  flex-shrink: 0;
}

.top-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 var(--space);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--card-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
}


.brand-text {
  min-width: 0;
}

/* Small code glyphs rising out from under the logo */
.brand-mark {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.code-bits {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.code-bits i {
  position: absolute;
  bottom: -2px;
  left: 50%;
  font: 600 9px/1 ui-monospace, "Cascadia Code", Consolas, monospace;
  font-style: normal;
  color: var(--accent, #3b82f6);
  opacity: 0;
  white-space: nowrap;
  animation: code-rise 3.6s ease-out infinite;
}

.code-bits i:nth-child(1) { --dx: -16px; animation-delay: 0s; }
.code-bits i:nth-child(2) { --dx: 12px;  animation-delay: 0.6s; }
.code-bits i:nth-child(3) { --dx: -6px;  animation-delay: 1.2s; }
.code-bits i:nth-child(4) { --dx: 18px;  animation-delay: 1.8s; }
.code-bits i:nth-child(5) { --dx: -20px; animation-delay: 2.4s; }
.code-bits i:nth-child(6) { --dx: 4px;   animation-delay: 3s; }

@keyframes code-rise {
  0%   { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
  20%  { opacity: 0.9; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), 14px) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .code-bits { display: none; }
}


.brand-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
}

.brand-tagline {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.3;
  color: var(--text-muted);
  white-space: nowrap;
}

.icon-btn {
  width: 2.35rem;
  height: 2.35rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--accent-soft);
}

[data-theme="dark"] .icon-sun,
[data-theme="light"] .icon-moon {
  display: none;
}

.lang-pills {
  padding: 2px;
}

.lang-pills .lang-btn {
  min-height: 2rem;
  padding: 0.1rem 0.7rem;
  font-size: 0.85rem;
}

.mobile-tabs {
  display: none;
}

/* Desktop: the history sidebar can be folded away to give the editor and results more room. */
@media (min-width: 1025px) {
  body.sidebar-collapsed .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  body.sidebar-collapsed .sidebar {
    display: none;
  }

  .history-toggle[aria-expanded="true"] {
    border-color: var(--accent);
    color: var(--accent);
  }
}

.app-shell {
  min-height: calc(100vh - var(--header-h));
}

.sidebar {
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  z-index: 20;
}

.workspace {
  height: calc(100vh - var(--header-h) - 2 * var(--space));
  min-height: 560px;
  flex: none;
}

.panel {
  min-height: 0;
  box-shadow: none;
}

.panel:hover {
  border-color: var(--card-border);
}

.editor-shell {
  min-height: 0;
  box-shadow: none;
}

.editor-shell .CodeMirror {
  min-height: 0;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.6rem;
}

.editor-toolbar .btn-ghost {
  border-color: transparent;
  color: var(--text);
  min-height: 34px;
  padding: 0.3rem 0.65rem;
}

.editor-actions .btn {
  min-height: 46px;
}

/* =========================================================================
   Findings on the code
   ========================================================================= */

.editor-shell .finding-gutter {
  width: 1.1rem;
}

.finding-marker {
  display: block;
  width: 0.62rem;
  height: 0.62rem;
  margin: 0.38rem auto 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.finding-marker:hover,
.finding-marker:focus-visible {
  transform: scale(1.4);
}

.finding-marker-high {
  background: var(--sev-high);
}

.finding-marker-medium {
  background: var(--sev-medium);
}

.finding-marker-low {
  background: var(--sev-low);
}

.cm-finding-high {
  background: var(--line-high);
}

.cm-finding-medium {
  background: var(--line-medium);
}

.cm-finding-low {
  background: var(--line-low);
}

/* =========================================================================
   Review progress and verdict
   ========================================================================= */

.stages {
  list-style: none;
  margin: 0.5rem 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.stages li {
  position: relative;
  padding: 0.55rem 0;
  padding-inline-start: 1.9rem;
  color: var(--text-muted);
  opacity: 0.6;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.stages li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0.25rem;
  top: 0.95rem;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 2px solid var(--card-border);
  background: var(--panel);
  z-index: 1;
}

.stages li:not(:last-child)::after {
  content: "";
  position: absolute;
  inset-inline-start: calc(0.25rem + 0.35rem - 1px);
  top: 1.4rem;
  bottom: -0.95rem;
  width: 2px;
  background: var(--card-border);
}

.stages li.done,
.stages li.active {
  opacity: 1;
}

.stages li.done::before {
  background: var(--success-text);
  border-color: var(--success-text);
}

.stages li.active {
  color: var(--text);
  font-weight: 600;
}

.stages li.active::before {
  border-color: var(--accent);
  background: var(--accent);
  animation: badge-pulse 1s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .stages li.active::before {
    animation: none;
  }
}

.summary-card {
  padding-bottom: 0.85rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--card-border);
}

.summary-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.93rem;
}

.verdict {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  --verdict: var(--success-text);
}

.verdict[data-level="high"] {
  --verdict: var(--sev-high);
}

.verdict[data-level="medium"] {
  --verdict: var(--sev-medium);
}

.verdict[data-level="low"] {
  --verdict: var(--sev-low);
}

.verdict h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--verdict);
}

.verdict-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--verdict);
}

.severity-bar {
  display: flex;
  gap: 3px;
  height: 7px;
  margin: 0.6rem 0;
  border-radius: 999px;
  overflow: hidden;
}

.severity-bar span {
  flex: 0 0 0;
  min-width: 0;
  transition: flex-grow 0.4s ease;
}

.severity-bar [data-sev="high"] {
  background: var(--sev-high);
}

.severity-bar [data-sev="medium"] {
  background: var(--sev-medium);
}

.severity-bar [data-sev="low"] {
  background: var(--sev-low);
}

/* =========================================================================
   Results: filter row, export menu, flat sections
   ========================================================================= */

.results-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.results-controls .stats-row {
  margin: 0;
}

.export-menu {
  position: relative;
}

.export-menu summary {
  list-style: none;
  min-height: 34px;
  padding: 0.3rem 0.7rem;
}

.export-menu summary::-webkit-details-marker {
  display: none;
}

.menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  inset-inline-end: 0;
  z-index: 15;
  min-width: 190px;
  padding: 0.3rem;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow);
}

.menu-item {
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  text-align: start;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--accent-soft);
}

.result-sections {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  padding-inline-end: 0.25rem;
}

.result-card-toggle {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 0.5rem 0;
  background: var(--panel);
  font-size: 0.95rem;
}

.result-body {
  padding-bottom: 0.5rem;
}

.finding-item {
  border-top: 1px solid var(--card-border);
  border-inline-start: 3px solid transparent;
  padding: 0.6rem 0.65rem;
  scroll-margin-top: 2.75rem;
  transition: background 0.3s ease;
}

.finding-item[data-sev="high"] {
  border-inline-start-color: var(--sev-high);
}

.finding-item[data-sev="medium"] {
  border-inline-start-color: var(--sev-medium);
}

.finding-item[data-sev="low"] {
  border-inline-start-color: var(--sev-low);
}

.finding-item.finding-flash {
  background: var(--accent-soft);
}

.severity-badge.sev-low {
  background: rgba(147, 180, 224, 0.16);
  color: var(--sev-low);
}

/* =========================================================================
   Tablet and phone: one panel at a time, history in a drawer
   ========================================================================= */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(0, 0, 0, 0.5);
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 85vw);
    height: auto;
    z-index: 40;
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform 0.22s ease, visibility 0.22s;
  }

  body.drawer-open .sidebar {
    visibility: visible;
    transform: none;
  }

  .history-toggle {
    display: inline-flex;
  }

  .mobile-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }

  .mobile-tabs .tab {
    justify-content: center;
    min-height: 40px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
  }

  .workspace[data-view="code"] .results-panel,
  .workspace[data-view="results"] .editor-panel,
  .split-divider,
  .sidebar-resizer {
    display: none;
  }

  .editor-panel {
    height: calc(100dvh - var(--header-h) - 40px - 3 * var(--space));
    min-height: 460px;
  }

  .results-panel {
    min-height: 460px;
  }

  .result-sections {
    overflow: visible;
    flex: none;
  }

  .result-card-toggle {
    top: var(--header-h);
  }

  .finding-item {
    scroll-margin-top: calc(var(--header-h) + 2.75rem);
  }
}

@media (max-width: 640px) {
  .main {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .top-header {
    padding: 0 0.75rem;
  }

  .brand-tagline,
  .brand-name,
  .kbd-hint,
  .history-toggle span {
    display: none;
  }

  .history-toggle {
    width: 2.35rem;
    padding: 0;
  }

  .panel-head h2 {
    font-size: 1.05rem;
  }

  .editor-toolbar .btn-ghost {
    padding: 0.3rem 0.45rem;
    font-size: 0.8rem;
  }

  .editor-actions {
    grid-template-columns: 1.4fr 1fr;
  }
}

@media print {
  .top-header,
  .mobile-tabs,
  .results-controls {
    display: none !important;
  }

  .workspace {
    display: block;
    height: auto;
  }

  .results-panel {
    display: block !important;
    border: none;
  }

  .result-sections {
    overflow: visible;
  }
}

/* Light theme: muted syntax colors instead of CodeMirror's saturated default palette. */
[data-theme="light"] .cm-s-default .cm-keyword,
[data-theme="light"] .cm-s-default .cm-atom,
[data-theme="light"] .cm-s-default .cm-builtin {
  color: #7a4a8c;
}

[data-theme="light"] .cm-s-default .cm-number {
  color: #8a5a14;
}

[data-theme="light"] .cm-s-default .cm-def,
[data-theme="light"] .cm-s-default .cm-variable-2 {
  color: #35608f;
}

[data-theme="light"] .cm-s-default .cm-variable-3,
[data-theme="light"] .cm-s-default .cm-type {
  color: #2c7a68;
}

[data-theme="light"] .cm-s-default .cm-string,
[data-theme="light"] .cm-s-default .cm-string-2 {
  color: #9a4a32;
}

[data-theme="light"] .cm-s-default .cm-comment {
  color: #7a7466;
}

[data-theme="light"] .cm-s-default .cm-meta {
  color: #6b6657;
}

/* ------------------------------ learning ------------------------------ */

.score-badge {
  --ring: var(--success-text);
  margin-inline-start: auto;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--card) 78%, transparent 80% 100%),
    conic-gradient(var(--ring) calc(var(--score, 0) * 10%), var(--card-border) 0);
  text-align: center;
  line-height: 1;
}

.score-badge b {
  display: block;
  font-size: 1.35rem;
  color: var(--ring);
}

.score-badge small {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.62rem;
  color: var(--text-muted);
}

.score-badge[data-level="ok"] {
  --ring: var(--sev-medium);
}

.score-badge[data-level="bad"] {
  --ring: var(--sev-high);
}

.level-select {
  min-width: 130px;
}

.concept-chip {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  white-space: nowrap;
}

.finding-lesson {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-inline-start: 3px solid var(--lesson);
  border-radius: 8px;
  background: var(--lesson-bg);
  color: var(--text);
}

.finding-lesson-icon {
  flex-shrink: 0;
}

.finding-lesson strong {
  color: var(--lesson);
}

.ask-open {
  margin-top: 0.6rem;
  padding: 0.3rem 0.7rem;
  border: 1px dashed var(--card-border);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.ask-open:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ask-open[aria-expanded="true"] {
  display: none;
}

.ask-thread:not(:empty) {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ask-turn {
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  background: var(--panel-inner);
}

.ask-turn b {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.ask-turn p {
  margin: 0;
  white-space: pre-wrap;
  color: var(--text);
}

.ask-turn pre {
  margin: 0.35rem 0;
  padding: 0.5rem;
  overflow-x: auto;
  border-radius: 6px;
  background: var(--editor-bg);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.82rem;
  direction: ltr;
  text-align: left;
}

.ask-you {
  border: 1px solid var(--card-border);
  background: transparent;
}

.ask-pending {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.ask-form[hidden] {
  display: none;
}

.ask-form {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.ask-input {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
}

@media print {
  .ask-form {
    display: none;
  }
}

/* ------------------------------ name ------------------------------ */

.user-chip {
  max-width: 220px;
}

.user-chip #userChipText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name-dialog .fix-dialog-inner {
  text-align: center;
}

.name-dialog h3 {
  margin: 0.5rem 0 0.25rem;
  font-size: 1.25rem;
}

.name-logo {
  display: block;
  margin: 0 auto;
}

.name-input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  font-size: 1rem;
  text-align: center;
}

.level-pills {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

.level-pills legend {
  width: 100%;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.level-pills {
  border: 0;
  padding: 0;
}

.level-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.level-pill span {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-text);
  cursor: pointer;
}

.level-pill input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.level-pill input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.name-error {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--sev-high);
}

.name-dialog .fix-dialog-actions {
  margin-top: 1rem;
}

@media (max-width: 640px) {
  .user-chip {
    max-width: 120px;
  }
}

/* Inline code in findings and follow-up answers */
.finding-body code,
.ask-turn p code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.85em;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  background: var(--editor-bg);
  direction: ltr;
  unicode-bidi: isolate;
}
