/* Typing Test — Desktop Styles */
:root {
  --bg: #0f172a;           /* slate-900 */
  --panel: #111827;        /* gray-900 */
  --panel-soft: #0c1526;   /* subtle dark panel */
  --text: #e5e7eb;         /* gray-200 */
  --muted: #9ca3af;        /* gray-400 */
  --brand: #6366f1;        /* indigo-500 */
  --brand-2: #8b5cf6;      /* violet-500 */
  --ok: #10b981;           /* emerald-500 */
  --warn: #f59e0b;         /* amber-500 */
  --danger: #ef4444;       /* red-500 */
  --card: #0b1220;         /* deep panel */
  --border: rgba(255,255,255,.08);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

/* Light theme variables */
:root[data-theme="light"] {
  --bg: #f8fafc;           /* slate-50 */
  --panel: #ffffff;        /* white */
  --panel-soft: #f1f5f9;   /* slate-100 */
  --text: #0f172a;         /* slate-900 */
  --muted: #475569;        /* slate-600 */
  --brand: #4f46e5;        /* indigo-600 */
  --brand-2: #7c3aed;      /* violet-600 */
  --ok: #059669;           /* emerald-600 */
  --warn: #d97706;         /* amber-600 */
  --danger: #dc2626;       /* red-600 */
  --card: #ffffff;
  --border: rgba(2,6,23,.12);
  --shadow: 0 8px 24px rgba(2,6,23,.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', 'Montserrat', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app { max-width: 1100px; margin: 28px auto; padding: 0 20px; }
.app-header { margin-bottom: 18px; }
.header-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { width: 22px; height: 22px; border-radius: 6px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.home-btn, .theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-soft); color: var(--text); cursor: pointer; text-decoration: none; }
.home-btn:hover, .theme-toggle:hover { filter: brightness(1.05); }
.theme-toggle[aria-pressed="true"] { background: #e5e7eb; color: #0b1220; border-color: rgba(0,0,0,.15); }
.icon { width: 20px; height: 20px; }
.title { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.subtitle { margin-top: 6px; color: var(--muted); font-size: 14px; }

.controls {
  display: grid;
  grid-template-columns: 1fr 1.2fr auto;
  gap: 16px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.control-group { display: grid; gap: 8px; align-content: start; }
.control-group[data-visible="false"] { display: none; }
.control-label { color: var(--muted); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }

.segmented { display: inline-flex; background: var(--panel-soft); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented-btn {
  appearance: none; border: 0; color: var(--text); background: transparent; padding: 8px 12px; border-radius: 10px;
  cursor: pointer; font-weight: 600; letter-spacing: .01em; transition: all .2s ease;
}
.segmented-btn:hover { background: rgba(99,102,241,.08); }
.segmented-btn.is-active { background: rgba(99,102,241,.18); border: 1px solid rgba(99,102,241,.35); }

/* quote-controls removed */

.actions-group { align-content: end; justify-items: end; }
.btn { background: #4f46e5; color: #fff; border: 0; padding: 10px 14px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.btn:hover { filter: brightness(1.05); }
.btn.is-active, .btn[aria-pressed="true"] { background: #312e81; box-shadow: inset 0 2px 0 rgba(255,255,255,.06); }
.btn-secondary { background: var(--panel-soft); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn-secondary:hover { filter: brightness(1.05); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 18px 0; }
.stat { background: var(--panel-soft); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; text-align: center; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-value { margin-top: 4px; font-size: 24px; font-weight: 800; }
.stat-suffix { margin-left: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
/* stat-icon removed */

.test { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; position: relative; min-height: 220px; display: grid; }
.text-wrapper { position: relative; overflow: hidden; }
.text { line-height: 1.8; font-size: 20px; color: #dbeafe; }
:root[data-theme="light"] .text { color: #0f172a; }

/* Text coloring */
.char { color: #a8b3cf; }
:root[data-theme="light"] .char { color: #334155; }
.char.correct { color: #9be6c9; }
.char.incorrect { color: #fecaca; background: rgba(239,68,68,.08); border-bottom: 2px solid rgba(239,68,68,.45); }
.char.current { position: relative; }
.char.current::after {
  content: '';
  position: absolute; left: -1px; bottom: -2px; width: calc(100% + 2px); height: 2px; background: linear-gradient(90deg, #8b5cf6, #6366f1);
  animation: caret 1s ease-in-out infinite;
}
@keyframes caret { 0%,100%{opacity:.2} 50%{opacity:1} }

.hidden-input { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }

.footer-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.hint { color: var(--muted); font-size: 13px; }

/* Focus (minimal) mode */
.app[data-focus="true"] .app-header,
.app[data-focus="true"] .controls,
.app[data-focus="true"] .stats,
.app[data-focus="true"] .footer-actions { display: none; }

.app[data-focus="true"] .test {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 24px 0;
  min-height: calc(100vh - 48px);
}

.app[data-focus="true"] .text { font-size: 22px; }

/* Modal */
.modal { display: none; position: fixed; inset: 0; z-index: 50; }
.modal.active { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }
.modal-content { position: relative; z-index: 1; margin: 6vh auto; max-width: 720px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-close { background: transparent; border: 0; color: var(--text); font-size: 18px; cursor: pointer; }
.modal-body { padding: 18px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--border); }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.result-card { background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: 12px; padding: 14px; text-align: center; }
.result-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.result-value { margin-top: 6px; font-size: 22px; font-weight: 800; }

.chart-section { margin-top: 16px; background: var(--panel-soft); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.chart-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }

/* Focus ring */
button:focus-visible, .select:focus-visible { outline: 2px solid rgba(99,102,241,.6); outline-offset: 2px; }

/* Desktop only tuning */
@media (max-width: 900px) {
  .controls { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .select { min-width: 0; width: 100%; }
}

