.results-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.results-header h2 { margin: 0; }
.results-header .results-actions { margin: 0; display: flex; gap: 8px; }
:root {
  --bg: #0b0f14;
  --surface: #121826;
  --text: #e6edf3;
  --muted: #9fb0c0;
  --primary: #4f8cff;
  --primary-600: #3c6fe0;
  --ok: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --card: #0f1522;
  --border: #1f2937;
  --para-gap: 0.1.8em; /* extra visual gap after newlines in display */
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  max-width: 1100px;
  padding: 0 16px;
  margin: 0 auto;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* Hide header during active typing test */
body.testing .app-header { display: none; }

.app-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px;
}

/* Mobile header navigation tweaks */
@media (max-width: 520px) {
  .app-header .container { flex-wrap: wrap; gap: 8px; }
  .app-header h1 { font-size: 18px; }
  .header-actions { width: 100%; display: flex; gap: 8px; }
  .header-actions button, .header-actions a { flex: 1; min-width: 0; height: 36px; padding: 8px 10px; }
}

.help-tip {
  display: inline-block;
  margin-left: 8px;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 999px;
  font-size: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: help;
}

.ai-prompt-block { margin: 8px 0 12px; }
.ai-prompt {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  white-space: pre-wrap;
}

h1, h2, h3 {
  margin: 0 0 12px 0;
}

.header-actions button, .header-actions a {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.header-actions .primary { background: var(--primary); border-color: var(--primary-600); color: #fff; }
.header-actions button:hover, .header-actions a:hover { filter: brightness(1.05); }
/* Active state for non-primary buttons only */
.header-actions .active { background: var(--card); color: var(--text); }
/* Ensure primary stays readable even when also marked active */
.header-actions .primary.active { background: var(--primary); color: #fff; border-color: var(--primary-600); }

.view { display: none; margin: 24px 0 48px; }
.view.active { display: block; }
.test-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.test-header h2 { margin: 0; }
.test-header .stats { margin: 0; }
.test-header .test-actions.inline { margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}

.settings-left { margin-right: 12px; }

@media (max-width: 840px) {
  .settings-grid { grid-template-columns: 1fr; }
  .settings-left { margin-right: 0; }
}

.settings-right { position: sticky; top: 76px; align-self: start; }
.settings-right .field:first-child { margin-top: 0; }
.settings-right .panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.font-controls { display: grid; grid-template-columns: auto auto auto 1fr; gap: 8px; align-items: center; }
.font-size-display { color: var(--muted); text-align: center; }
/* Refined styling for font size controls and Start Test button */
.font-controls button {
  height: 40px;
  min-width: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.font-controls button:hover { filter: brightness(1.06); }
.font-controls button:active { transform: translateY(1px); }
.font-controls #font-decrease,
.font-controls #font-increase {
  font-weight: 700;
  font-size: 16px;
}
.font-controls #font-reset { min-width: 64px; }
.font-size-display {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 600;
}

/* Start Test button emphasis */
#start-test.primary {
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: .01em;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-600) 100%);
  border-color: var(--primary-600);
  box-shadow: 0 6px 18px rgba(79,140,255,.25);
}
#start-test.primary:hover { filter: brightness(1.05); box-shadow: 0 8px 22px rgba(79,140,255,.32); }
#start-test.primary:active { transform: translateY(1px); box-shadow: 0 4px 12px rgba(79,140,255,.2); }
#start-test.primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79,140,255,.35), 0 6px 18px rgba(79,140,255,.25);
}

.templates-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.template-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.template-item .name { font-weight: 600; }
.template-item .meta { color: var(--muted); font-size: 12px; }
.template-item button { white-space: nowrap; }

@media (max-width: 480px) {
  .template-item { flex-wrap: wrap; }
}

.label { display: block; font-weight: 600; margin-bottom: 8px; }

textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  resize: vertical;
  transition: border-color .2s, box-shadow .2s;
  min-height: 220px;
  font-family: inherit; /* ensure textarea matches display font for identical wrapping */
}

.text-stats { margin-top: 6px; font-size: 12px; }

select, input[type="number"], .typing-input {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  transition: border-color .2s, box-shadow .2s;
}

/* Compact styling for custom duration input */
#custom-duration-wrap .label { font-size: 12px; margin-bottom: 6px; color: var(--muted); }
#custom-seconds { height: 34px; padding: 6px 10px; font-size: 14px; border-radius: 8px; max-width: 160px; }

.field { margin: 12px 0; }
.field + .field { margin-top: 14px; }

.checkbox { display: flex; align-items: center; gap: 10px; cursor: pointer; }

.settings-actions, .results-actions, .test-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

button.primary {
  background: var(--primary);
  color: white;
  border: 1px solid var(--primary-600);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .04s ease, filter .2s ease;
  height: 40px;
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .04s ease, filter .2s ease;
  height: 40px;
}

button.primary:hover { filter: brightness(1.05); }
button.secondary:hover { filter: brightness(1.1); }
button.primary:active, button.secondary:active { transform: translateY(1px); }

textarea:focus, select:focus, input[type="number"]:focus, .typing-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,140,255,.25);
}

.stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.stat { background: var(--card); border: 1px solid var(--border); padding: 10px 12px; border-radius: 10px; }
.stat { min-width: 120px; display: flex; justify-content: space-between; }
.stat-label { color: var(--muted); margin-right: 8px; }
.stat-value { font-weight: 700; }

.test-text {
  box-sizing: border-box;
  min-height: 160px;
  height: 10.8em; /* ~6 lines at 1.8 line-height */
  overflow-y: scroll; /* always reserve scrollbar width for consistent wrapping */
  overflow-x: hidden;
  padding: 16px;
  padding-bottom: calc(16px + 1.8em); /* keep one extra line visible at bottom, matching typing input */
  scroll-padding-bottom: 1.8em; /* ensure scrollIntoView leaves space at bottom */
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  line-height: 1.8;
  font-size: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-variant-ligatures: none;
  word-wrap: break-word;
  white-space: pre-wrap;
  width: 100%;
}

/* Ensure an extra visual line at the bottom even when content ends exactly at the viewport */

.test-text .char { opacity: 0.65; }
.test-text .char.active { opacity: 1; text-decoration: underline; text-underline-offset: 3px; }
.test-text .char.ok { color: var(--ok); opacity: 1; }
.test-text .char.bad { color: var(--bad); opacity: 1; }
.test-text .char.current-word { background: transparent; }
.test-text .char.word-bad { color: inherit; }
.test-text .char.space { opacity: 0.5; }
.test-text .char.space.bad {
  background: transparent;
  outline: none;
  border-radius: 0;
  box-shadow: inset 0 -2px 0 rgba(239,68,68,.5); /* subtle underline instead of full highlight */
  opacity: 1;
}
.test-text .char.nl-next { position: relative; }
.test-text .char.nl-next::after { content: '↵'; position: absolute; right: -10px; top: 0; color: var(--muted); opacity: .9; font-size: 12px; display: inline-block; padding-bottom: var(--para-gap); }
.typing-hint { margin-top: 10px; color: var(--muted); font-size: 14px; min-height: 20px; display: block; opacity: 0.8; }
.typing-hint .kbd { display: inline-block; padding: 2px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; background: var(--card); color: var(--text); font-weight: 600; }

.typing-input { box-sizing: border-box; display: block; width: 100%; margin-top: 14px; font-size: 16px; line-height: 1.8; height: 10.8em; padding: 16px; padding-bottom: calc(16px + 1.8em); /* keep one extra line visible */ resize: none; overflow-y: scroll; overflow-x: hidden; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-variant-ligatures: none; }
body.inline-mode .typing-input { display: none !important; }

/* Inline mode container (typing over text like typeracer) */
.inline-box {
  box-sizing: border-box;
  min-height: 220px;
  height: 16.2em; /* show ~9 lines at 1.8 line-height */
  overflow-y: scroll; /* reserve scrollbar width for consistent wrapping */
  overflow-x: hidden;
  padding: 16px;
  padding-bottom: calc(16px + 1.8em);
  scroll-padding-bottom: 1.8em; /* keep one extra line visible at bottom */
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  line-height: 1.8;
  font-size: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-variant-ligatures: none;
  white-space: pre-wrap;
  overflow-wrap: normal; /* do not break inside words */
  word-break: keep-all; /* keep words intact; break only at spaces/newlines */
}
.inline-box .word { display: inline-block; }
.inline-box:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,140,255,.25);
}
.inline-box .char { opacity: 0.65; }
.inline-box .char.ok { color: var(--ok); opacity: 1; }
.inline-box .char.bad { color: var(--bad); opacity: 1; }
.inline-box .char.space { opacity: 0.5; }
.inline-box .char.space.bad {
  background: transparent;
  outline: none;
  border-radius: 0;
  box-shadow: inset 0 -2px 0 rgba(239,68,68,.5);
  opacity: 1;
}
.inline-box .caret {
  display: inline-block;
  width: 1px;
  background: var(--primary);
  height: 1.2em;
  vertical-align: -0.2em;
  animation: caretBlink 1s step-end infinite;
}
.inline-box .char.nl-next::after {
  content: '⏎';
  position: relative;
  left: 4px;
  color: var(--muted);
  opacity: .9;
  font-size: 12px;
}
@keyframes caretBlink { 50% { opacity: 0; } }

.results-cards {
  display: flex;
  gap: 12px;
  flex-wrap: nowrap; /* keep in one horizontal line */
  overflow-x: auto; /* allow horizontal scroll if needed */
  padding-bottom: 4px; /* avoid scrollbar overlap */
}

@media (max-width: 640px) {
  .results-cards { grid-template-columns: 1fr; }
}

.view-results h2 { margin-bottom: 12px; }
.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
  min-width: 180px; /* compact width for horizontal layout */
  flex: 0 0 auto;
}
.result-card::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(79,140,255,.12);
}
.result-label {
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 12px;
}
.result-value { font-size: 32px; font-weight: 800; }
.result-card.ok .result-value { color: var(--ok); }
.result-card.warn .result-value { color: var(--warn); }
.result-card.bad .result-value { color: var(--bad); }

.mistakes-wrap { margin-top: 16px; }
.mistakes-wrap .char { display: inline; }
.mistakes-wrap .char.bad { background: var(--bad); color: #fff; padding: 1px 2px; border-radius: 2px; }

.mistakes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.mistakes-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.mistakes-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: 'Inter', monospace;
  font-size: 14px;
  line-height: 1.5;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, padding 0.3s ease-out, opacity 0.3s ease-out;
  opacity: 0;
  white-space: pre-wrap; /* Preserve whitespace and line breaks */
}

.mistakes-content.expanded {
  max-height: 500px;
  opacity: 1;
  padding: 12px;
  overflow-y: auto;
}

.mistakes-content.collapsed {
  max-height: 0;
  opacity: 0;
  padding: 0 12px;
}

.mistakes-content .char {
  display: inline;
}

.mistakes-content .char.bad {
  background: var(--bad);
  color: #fff;
  padding: 1px 2px;
  border-radius: 2px;
}

.small {
  font-size: 12px;
  padding: 6px 10px;
  transition: all 0.2s ease;
}

.results-actions { margin-top: 16px; }
/* Results action buttons */
.results-actions button { height: 42px; border-radius: 12px; padding: 0 14px; }
#retry-test.primary {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-600) 100%);
  border-color: var(--primary-600);
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(79,140,255,.22);
}
#retry-test.primary:hover { filter: brightness(1.05); box-shadow: 0 8px 22px rgba(79,140,255,.30); }
#retry-test.primary:active { transform: translateY(1px); box-shadow: 0 4px 12px rgba(79,140,255,.2); }

#new-test.secondary, #copy-results.secondary {
  background: var(--surface);
  border-color: var(--border);
}
#new-test.secondary:hover, #copy-results.secondary:hover { filter: brightness(1.08); }
#new-test.secondary:active, #copy-results.secondary:active { transform: translateY(1px); }

.recent-form { padding: 0 0 12px; }
.recent-list { max-height: 300px; overflow: auto; display: grid; gap: 10px; padding: 8px 0; }
.recent-item { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: pointer; }

/* Light theme */
body.light {
  --bg: #f7fafc;
  --surface: #ffffff;
  --text: #0b1220;
  --muted: #4a5568;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --card: #ffffff;
  --border: #e2e8f0;
}

/* Prevent background scroll when modal dialogs are open */
body.modal-open { overflow: hidden; }

dialog::backdrop { background: rgba(0,0,0,.6); }
#mobile-dialog::backdrop { background: #000; }
dialog { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }

/* AI Help dialog styling */
#ai-help-dialog { width: min(680px, 92vw); padding: 0; }
#ai-help-dialog .recent-form { padding: 16px 16px 10px; }
#ai-help-dialog h3 { margin: 0 0 8px; }
#ai-help-dialog p { margin: 0 0 10px; }
#ai-help-dialog .ai-prompt-block {
  margin: 10px 0 14px;
  background: linear-gradient(180deg, rgba(79,140,255,.08), rgba(79,140,255,.04));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12) inset;
}
#ai-help-dialog .ai-prompt-block .label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
#ai-help-dialog .ai-prompt {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 14px;
  background: var(--card);
  border: 1px dashed var(--primary-600);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: inset 0 0 0 1px rgba(79,140,255,.18);
}
#ai-help-dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 6px 0 0; padding: 0; }

/* Empty text dialog styling */
#empty-text-dialog { width: min(420px, 92vw); padding: 0; }
#empty-text-dialog .recent-form { padding: 16px; }
#empty-text-dialog h3 { margin: 0 0 10px; }
#empty-text-dialog p.muted {
  margin: 0 0 12px;
  background: rgba(239,68,68,.10);
  border: 1px solid rgba(239,68,68,.35);
  border-left-width: 3px;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
}
#empty-text-dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 6px 0 0; padding: 0; }

/* Mobile dialog styling */
#mobile-dialog { width: min(560px, 92vw); padding: 0; }
#mobile-dialog .recent-form { padding: 24px 18px 20px; background: #000; color: #fff; text-align: center; }
#mobile-dialog[open] { display: block; }
#mobile-dialog h3 { margin: 4px 0 10px; color: #fff; font-size: 22px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; }
#mobile-dialog { box-shadow: 0 24px 48px rgba(0,0,0,.75); }
#mobile-dialog .mobile-message { margin: 12px auto 16px; color: #cbd5e1; max-width: 60ch; text-align: left; line-height: 1.75; }
#mobile-dialog .mobile-lead { font-weight: 900; color: #fff; font-size: 17px; margin-bottom: 12px; text-align: center; letter-spacing: .01em; }
#mobile-dialog .mobile-steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
#mobile-dialog .mobile-steps li { display: grid; grid-template-columns: 28px 1fr; align-items: start; gap: 10px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.10); border-radius: 12px; padding: 12px 14px; }
#mobile-dialog .mobile-steps .icon { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 999px; background: rgba(79,140,255,.18); color: #fff; border: 1px solid rgba(79,140,255,.35); }
#mobile-dialog .mobile-steps strong { color: #fff; }
#mobile-dialog .mobile-steps li:hover { background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.18); }
#mobile-dialog .mobile-steps li span { color: #dbe3ec; }
#mobile-dialog .mobile-steps li span strong { color: #fff; }

.recent-form { padding: 0 0 12px; }
.recent-list { max-height: 360px; overflow: auto; display: grid; gap: 10px; padding: 8px 0; }
.recent-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.recent-item:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(0,0,0,.22); border-color: var(--primary-600); background: var(--card); }
.recent-item:active { transform: translateY(0); box-shadow: 0 6px 16px rgba(0,0,0,.18); }
.recent-item:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(79,140,255,.35); }

/* Recent dialog specific sizing */
#recent-dialog { width: min(700px, 92vw); padding: 0; }
#recent-dialog .recent-form { padding: 16px; }
#recent-dialog h3 { margin: 0 0 10px; }
#recent-dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 6px 0 0; padding: 0; }

.app-footer {
  padding: 16px 0 32px;
  color: var(--muted);
}
.app-footer .container { text-align: center; }
.muted { color: var(--muted); }

/* Lessons */
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 16px; }
.pill {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.pill.active { background: var(--primary); color: #fff; border-color: var(--primary-600); }
.pill.active .pill-count { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.25); color: #fff; }
.pill-count { 
  display: inline-block; 
  margin-left: 6px; 
  padding: 0 8px; 
  border-radius: 999px; 
  background: var(--surface); 
  border: 1px solid var(--border); 
  color: var(--muted); 
  font-weight: 700; 
  font-size: 12px; 
}

.lessons-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
@media (max-width: 1000px) { .lessons-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 740px) { .lessons-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .lessons-grid { grid-template-columns: 1fr; } }

.lesson-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lesson-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.25); border-color: var(--primary-600); }
.lesson-card:hover .lesson-title { color: var(--primary); }
.lesson-title { 
  font-weight: 700; 
  font-size: 16px; 
  line-height: 1.3; 
  color: var(--text);
  margin-bottom: 4px;
  transition: color 0.2s ease;
}
.lesson-meta { color: var(--muted); font-size: 12px; }
.lesson-meta .duration { color: var(--primary); font-weight: 600; }
.lesson-actions { display: flex; justify-content: space-between; align-items: center; }
.lesson-play { width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; border: 1px solid var(--border); cursor: pointer; }
.lesson-play:hover { filter: brightness(1.08); }
.lesson-play span { font-size: 18px; }

/* Content Sources Styles */
.sources-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}

.sources-left { margin-right: 12px; }

@media (max-width: 840px) {
  .sources-grid { grid-template-columns: 1fr; }
  .sources-left { margin-right: 0; }
}

.sources-right { position: sticky; top: 76px; align-self: start; }
.sources-right .field:first-child { margin-top: 0; }
.sources-right .panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }

.sources-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.content-preview {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}

.content-preview h3 {
  margin: 0 0 12px 0;
  color: var(--text);
}

.preview-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  margin-bottom: 12px;
}

.preview-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.sources-help-content {
  display: grid;
  gap: 16px;
  margin: 12px 0;
}

.help-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.help-section h4 {
  margin: 0 0 6px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.help-section p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

/* Compact styling for sources duration input */
#custom-duration-wrap-sources .label { font-size: 12px; margin-bottom: 6px; color: var(--muted); }
#custom-seconds-sources { height: 34px; padding: 6px 10px; font-size: 14px; border-radius: 8px; max-width: 160px; }

/* Font controls for sources */
.font-controls button {
  height: 40px;
  min-width: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.font-controls button:hover { filter: brightness(1.06); }
.font-controls button:active { transform: translateY(1px); }
.font-controls #font-decrease-sources,
.font-controls #font-increase-sources {
  font-weight: 700;
  font-size: 16px;
}
.font-controls #font-reset-sources { min-width: 64px; }
.font-size-display {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 600;
}

/* Start Test button emphasis for sources */
#start-test-sources.primary {
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: .01em;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-600) 100%);
  border-color: var(--primary-600);
  box-shadow: 0 6px 18px rgba(79,140,255,.25);
}
#start-test-sources.primary:hover { filter: brightness(1.05); box-shadow: 0 8px 22px rgba(79,140,255,.32); }
#start-test-sources.primary:active { transform: translateY(1px); box-shadow: 0 4px 12px rgba(79,140,255,.2); }
#start-test-sources.primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79,140,255,.35), 0 6px 18px rgba(79,140,255,.25);
}

/* Enhanced Content Sources Guide Styles */
.sources-help-content {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 8px;
}

.sources-help-content .help-section {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.sources-help-content .help-section h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.sources-help-content .help-section p {
  margin: 8px 0;
  line-height: 1.5;
  color: var(--text-secondary);
}

.sources-help-content .small-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.category-tag {
  display: inline-block;
  padding: 4px 8px;
  background: var(--primary-100);
  color: var(--primary-700);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--primary-200);
}

.length-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.length-item {
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.uniqueness-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.feature-item {
  padding: 6px 10px;
  background: var(--success-100);
  color: var(--success-700);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--success-200);
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .category-tag {
    background: var(--primary-900);
    color: var(--primary-300);
    border-color: var(--primary-700);
  }
  
  .length-item {
    background: var(--surface);
    border-color: var(--border);
  }
  
  .feature-item {
    background: var(--success-900);
    color: var(--success-300);
    border-color: var(--success-700);
  }
}

/* Info Button Styles */
.info-button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 4px 6px;
  margin-left: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.info-button:hover {
  background: var(--primary-100);
  color: var(--primary-600);
  border-color: var(--primary-300);
  transform: scale(1.05);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.info-button:active {
  transform: scale(0.95);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Dark mode for info button */
[data-theme="dark"] .info-button {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-secondary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .info-button:hover {
  background: var(--primary-900);
  color: var(--primary-400);
  border-color: var(--primary-700);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Help Tip Button Styles (ⓘ buttons) */
.help-tip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 4px 6px;
  margin-left: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.help-tip:hover {
  background: var(--primary-100);
  color: var(--primary-600);
  border-color: var(--primary-300);
  transform: scale(1.05);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.help-tip:active {
  transform: scale(0.95);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Dark mode for help tip buttons */
[data-theme="dark"] .help-tip {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-secondary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .help-tip:hover {
  background: var(--primary-900);
  color: var(--primary-400);
  border-color: var(--primary-700);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Auto-refresh Info Dialog Styles */
#auto-refresh-info-dialog {
  max-width: 600px;
  max-height: 80vh;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow-y: auto;
}

#auto-refresh-info-dialog .recent-form {
  padding: 24px;
  position: relative;
}

#auto-refresh-info-dialog .dialog-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  margin: 0;
  padding: 0;
}

#auto-refresh-info-dialog .close-button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

#auto-refresh-info-dialog .close-button:hover {
  background: var(--error-100);
  color: var(--error-600);
  border-color: var(--error-300);
  transform: scale(1.05);
}

#auto-refresh-info-dialog .close-button:active {
  transform: scale(0.95);
}

#auto-refresh-info-dialog h3 {
  color: var(--primary-600);
  margin-bottom: 8px;
  font-size: 20px;
  font-weight: 600;
}

#auto-refresh-info-dialog .muted {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 14px;
}

#auto-refresh-info-dialog .help-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

#auto-refresh-info-dialog .help-section h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

#auto-refresh-info-dialog .help-section p {
  margin: 0 0 12px 0;
  color: var(--text-secondary);
  font-size: 14px;
}

#auto-refresh-info-dialog .help-section ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
}

#auto-refresh-info-dialog .help-section li {
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.5;
}

#auto-refresh-info-dialog .help-section li strong {
  color: var(--text);
  font-weight: 600;
}

/* Dark mode for auto-refresh dialog */
[data-theme="dark"] #auto-refresh-info-dialog {
  border-color: var(--border);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] #auto-refresh-info-dialog h3 {
  color: var(--primary-400);
}

[data-theme="dark"] #auto-refresh-info-dialog .help-section {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] #auto-refresh-info-dialog .help-section h4 {
  color: var(--text);
}

[data-theme="dark"] #auto-refresh-info-dialog .help-section p {
  color: var(--text-secondary);
}

[data-theme="dark"] #auto-refresh-info-dialog .help-section li {
  color: var(--text);
}

[data-theme="dark"] #auto-refresh-info-dialog .help-section li strong {
  color: var(--text);
}

[data-theme="dark"] #auto-refresh-info-dialog .close-button {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-secondary);
}

[data-theme="dark"] #auto-refresh-info-dialog .close-button:hover {
  background: var(--error-900);
  color: var(--error-400);
  border-color: var(--error-700);
}

/* Sources Help Dialog Styles */
#sources-help-dialog {
  max-width: 600px;
  max-height: 80vh;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow-y: auto;
}

#sources-help-dialog .recent-form {
  padding: 24px;
  position: relative;
}

#sources-help-dialog .dialog-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  margin: 0;
  padding: 0;
}

#sources-help-dialog .close-button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

#sources-help-dialog .close-button:hover {
  background: var(--error-100);
  color: var(--error-600);
  border-color: var(--error-300);
  transform: scale(1.05);
}

#sources-help-dialog .close-button:active {
  transform: scale(0.95);
}

/* Dark mode for sources help dialog */
[data-theme="dark"] #sources-help-dialog {
  border-color: var(--border);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] #sources-help-dialog .close-button {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-secondary);
}

[data-theme="dark"] #sources-help-dialog .close-button:hover {
  background: var(--error-900);
  color: var(--error-400);
  border-color: var(--error-700);
}

/* Enhanced styling for sources help dialog content */
#sources-help-dialog h3 {
  color: var(--primary-600);
  margin-bottom: 8px;
  font-size: 20px;
  font-weight: 600;
}

#sources-help-dialog .muted {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 14px;
}

#sources-help-dialog .sources-help-content {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 8px;
}

#sources-help-dialog .help-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#sources-help-dialog .help-section h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

#sources-help-dialog .help-section p {
  margin: 0 0 12px 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

#sources-help-dialog .help-section p:last-child {
  margin-bottom: 0;
}

#sources-help-dialog .small-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

#sources-help-dialog .category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

#sources-help-dialog .category-tag {
  background: var(--primary-100);
  color: var(--primary-700);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--primary-200);
}

#sources-help-dialog .length-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

#sources-help-dialog .length-item {
  padding: 8px 12px;
  background: var(--success-100);
  color: var(--success-700);
  border-radius: 6px;
  font-size: 12px;
  text-align: center;
  font-weight: 500;
  border: 1px solid var(--success-200);
}

#sources-help-dialog .uniqueness-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

#sources-help-dialog .feature-item {
  padding: 6px 10px;
  background: var(--success-100);
  color: var(--success-700);
  border-radius: 6px;
  font-size: 12px;
  text-align: center;
  font-weight: 500;
  border: 1px solid var(--success-200);
}

/* Dark mode for enhanced sources help dialog */
[data-theme="dark"] #sources-help-dialog h3 {
  color: var(--primary-400);
}

[data-theme="dark"] #sources-help-dialog .help-section {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] #sources-help-dialog .help-section h4 {
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] #sources-help-dialog .help-section p {
  color: var(--text-secondary);
}

[data-theme="dark"] #sources-help-dialog .small-text {
  color: var(--text-secondary);
  border-color: var(--border);
}

[data-theme="dark"] #sources-help-dialog .category-tag {
  background: var(--primary-900);
  color: var(--primary-300);
  border-color: var(--primary-700);
}

[data-theme="dark"] #sources-help-dialog .length-item {
  background: var(--success-900);
  color: var(--success-300);
  border-color: var(--success-700);
}

[data-theme="dark"] #sources-help-dialog .feature-item {
  background: var(--success-900);
  color: var(--success-300);
  border-color: var(--success-700);
}

/* Practice Lessons Info Dialog Styles */
#lessons-info-dialog {
  max-width: 600px;
  max-height: 80vh;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow-y: auto;
}

#lessons-info-dialog .recent-form {
  padding: 24px;
  position: relative;
}

#lessons-info-dialog .dialog-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  margin: 0;
  padding: 0;
}

#lessons-info-dialog .close-button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

#lessons-info-dialog .close-button:hover {
  background: var(--error-100);
  color: var(--error-600);
  border-color: var(--error-300);
  transform: scale(1.05);
}

#lessons-info-dialog .close-button:active {
  transform: scale(0.95);
}

#lessons-info-dialog h3 {
  color: var(--primary-600);
  margin-bottom: 8px;
  font-size: 20px;
  font-weight: 600;
}

#lessons-info-dialog .muted {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 14px;
}

#lessons-info-dialog .help-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#lessons-info-dialog .help-section h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

#lessons-info-dialog .help-section p {
  margin: 0 0 12px 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

#lessons-info-dialog .help-section p:last-child {
  margin-bottom: 0;
}

#lessons-info-dialog .help-section ul,
#lessons-info-dialog .help-section ol {
  margin: 0 0 12px 0;
  padding-left: 20px;
  color: var(--text);
}

#lessons-info-dialog .help-section li {
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.5;
}

#lessons-info-dialog .help-section li strong {
  color: var(--text);
  font-weight: 600;
}

#lessons-info-dialog .small-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

#lessons-info-dialog .category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

#lessons-info-dialog .category-tag {
  background: var(--primary-100);
  color: var(--primary-700);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--primary-200);
}

/* Dark mode for lessons info dialog */
[data-theme="dark"] #lessons-info-dialog {
  border-color: var(--border);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] #lessons-info-dialog h3 {
  color: var(--primary-400);
}

[data-theme="dark"] #lessons-info-dialog .help-section {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] #lessons-info-dialog .help-section h4 {
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] #lessons-info-dialog .help-section p {
  color: var(--text-secondary);
}

[data-theme="dark"] #lessons-info-dialog .help-section li {
  color: var(--text);
}

[data-theme="dark"] #lessons-info-dialog .help-section li strong {
  color: var(--text);
}

[data-theme="dark"] #lessons-info-dialog .small-text {
  color: var(--text-secondary);
  border-color: var(--border);
}

[data-theme="dark"] #lessons-info-dialog .category-tag {
  background: var(--primary-900);
  color: var(--primary-300);
  border-color: var(--primary-700);
}

[data-theme="dark"] #lessons-info-dialog .close-button {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-secondary);
}

[data-theme="dark"] #lessons-info-dialog .close-button:hover {
  background: var(--error-900);
  color: var(--error-400);
  border-color: var(--error-700);
}

/* Print Results Button Styling */
#print-results {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Print Details Dialog Styling */
#print-details-dialog {
  max-width: 520px;
  width: 90vw;
  max-height: 70vh;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

#print-details-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

#print-details-dialog .recent-form {
  padding: 0;
  margin: 0;
  overflow-y: auto;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}

#print-details-dialog h3 {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: white;
  margin: 0;
  padding: 20px 20px 20px 25px; /* Extra left padding for grip dots */
  border-radius: 12px 12px 0 0;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

#print-details-dialog .dialog-header {
  cursor: grab;
  user-select: none;
  position: relative;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#print-details-dialog .dialog-header:active {
  cursor: grabbing;
}

/* Drag grip indicators */
#print-details-dialog .dialog-header::before {
  content: '⋮⋮';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: 0.7;
  letter-spacing: 2px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.8);
  z-index: 1;
}

/* Additional grip dots on the right side */
#print-details-dialog .dialog-header::after {
  content: '⋮⋮';
  position: absolute;
  right: 50px; /* Position before the info button */
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: 0.5;
  letter-spacing: 2px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.6);
  z-index: 1;
}

#print-details-dialog .info-button {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

#print-details-dialog .info-button:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
}

#print-details-dialog .muted {
  color: var(--muted);
  font-size: 14px;
  margin: 16px 20px 20px 20px;
  line-height: 1.5;
  padding: 0;
}


#print-details-dialog .field {
  margin: 0 20px 16px 20px;
  position: relative;
  box-sizing: border-box;
}

#print-details-dialog .label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  position: relative;
}


#print-details-dialog input,
#print-details-dialog textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

#print-details-dialog input:focus,
#print-details-dialog textarea:focus {
  outline: none;
  border-color: var(--primary);
}

#print-details-dialog input:hover,
#print-details-dialog textarea:hover {
  border-color: var(--primary-600);
}

#print-details-dialog textarea {
  resize: vertical;
  min-height: 70px;
  line-height: 1.5;
}

#print-details-dialog menu {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin: 20px 20px 0 20px;
  padding: 16px 0 0 0;
  border-top: 1px solid var(--border);
  box-sizing: border-box;
  flex-shrink: 0;
}

#print-details-dialog .primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(79, 140, 255, 0.3);
}

#print-details-dialog .primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 140, 255, 0.4);
}

#print-details-dialog .primary:active {
  transform: translateY(0);
}

#print-details-dialog .secondary {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

#print-details-dialog .secondary:hover {
  background: var(--surface);
  border-color: var(--primary);
  color: var(--primary);
}

/* Dark theme adjustments for print dialog */
[data-theme="dark"] #print-details-dialog {
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] #print-details-dialog .print-preview-info {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  border-color: #3b82f6;
}

[data-theme="dark"] #print-details-dialog .print-preview-info h4 {
  color: #93c5fd;
}

[data-theme="dark"] #print-details-dialog .print-preview-info li {
  color: #dbeafe;
}

[data-theme="dark"] #print-details-dialog input,
[data-theme="dark"] #print-details-dialog textarea {
  background: var(--card);
}

[data-theme="dark"] #print-details-dialog input:focus,
[data-theme="dark"] #print-details-dialog textarea:focus {
  border-color: var(--primary);
}

/* Print Info Dialog Styling */
#print-info-dialog {
  max-width: 500px;
  width: 90vw;
  max-height: 80vh;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

#print-info-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

#print-info-dialog .recent-form {
  padding: 0;
  margin: 0;
  overflow-y: auto;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

#print-info-dialog h3 {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: white;
  margin: 0;
  padding: 20px;
  border-radius: 12px 12px 0 0;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
}

#print-info-dialog .muted {
  color: var(--muted);
  font-size: 14px;
  margin: 16px 20px 20px 20px;
  line-height: 1.5;
  padding: 0;
}

#print-info-dialog .info-content {
  padding: 0 20px;
  flex: 1;
  overflow-y: auto;
}

#print-info-dialog .info-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

#print-info-dialog .info-section h4 {
  color: var(--primary);
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

#print-info-dialog .info-section ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
}

#print-info-dialog .info-section li {
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.4;
}

#print-info-dialog .info-tip {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
  color: #92400e;
  font-size: 14px;
  line-height: 1.5;
}

#print-info-dialog menu {
  display: flex;
  justify-content: center;
  margin: 20px 20px 0 20px;
  padding: 16px 0 0 0;
  border-top: 1px solid var(--border);
  box-sizing: border-box;
  flex-shrink: 0;
}

/* Dark theme for print info dialog */
[data-theme="dark"] #print-info-dialog .info-section {
  background: var(--card);
  border-color: var(--border);
}

[data-theme="dark"] #print-info-dialog .info-tip {
  background: linear-gradient(135deg, #451a03 0%, #78350f 100%);
  border-color: #d97706;
  color: #fbbf24;
}

/* Name Required Dialog Styling */
#name-required-dialog {
  max-width: 400px;
  width: 90vw;
  max-height: 60vh;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

#name-required-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

#name-required-dialog .recent-form {
  padding: 0;
  margin: 0;
  overflow-y: auto;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
}

#name-required-dialog h3 {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: white;
  margin: 0;
  padding: 20px;
  border-radius: 12px 12px 0 0;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
}

#name-required-dialog .muted {
  color: var(--muted);
  font-size: 14px;
  margin: 16px 20px 20px 20px;
  line-height: 1.5;
  padding: 0;
}

#name-required-dialog .name-required-content {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin: 0 20px;
}

#name-required-dialog .name-required-icon {
  font-size: 32px;
  flex-shrink: 0;
  opacity: 0.8;
}

#name-required-dialog .name-required-content p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

#name-required-dialog menu {
  display: flex;
  justify-content: center;
  margin: 20px 20px 0 20px;
  padding: 16px 0 0 0;
  border-top: 1px solid var(--border);
  box-sizing: border-box;
  flex-shrink: 0;
}

/* Dark theme for name required dialog */
[data-theme="dark"] #name-required-dialog .name-required-content {
  background: var(--card);
  border-color: var(--border);
}

/* Custom Scrollbar Styling for Dialogs */
#print-details-dialog .recent-form::-webkit-scrollbar,
#print-info-dialog .recent-form::-webkit-scrollbar {
  width: 6px;
}

#print-details-dialog .recent-form::-webkit-scrollbar-track,
#print-info-dialog .recent-form::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}

#print-details-dialog .recent-form::-webkit-scrollbar-thumb,
#print-info-dialog .recent-form::-webkit-scrollbar-thumb {
  background: rgba(79, 140, 255, 0.3);
  border-radius: 3px;
  transition: background 0.3s ease;
}

#print-details-dialog .recent-form::-webkit-scrollbar-thumb:hover,
#print-info-dialog .recent-form::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 140, 255, 0.5);
}

/* Firefox scrollbar styling */
#print-details-dialog .recent-form,
#print-info-dialog .recent-form {
  scrollbar-width: thin;
  scrollbar-color: rgba(79, 140, 255, 0.3) transparent;
}

/* Dark theme scrollbar adjustments */
[data-theme="dark"] #print-details-dialog .recent-form::-webkit-scrollbar-thumb,
[data-theme="dark"] #print-info-dialog .recent-form::-webkit-scrollbar-thumb {
  background: rgba(79, 140, 255, 0.4);
}

[data-theme="dark"] #print-details-dialog .recent-form::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] #print-info-dialog .recent-form::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 140, 255, 0.6);
}

[data-theme="dark"] #print-details-dialog .recent-form,
[data-theme="dark"] #print-info-dialog .recent-form {
  scrollbar-color: rgba(79, 140, 255, 0.4) transparent;
}

/* Hide scrollbar for Name Required Dialog and Print Info Dialog */
#name-required-dialog .recent-form::-webkit-scrollbar,
#print-info-dialog .recent-form::-webkit-scrollbar {
  display: none;
}

#name-required-dialog .recent-form,
#print-info-dialog .recent-form {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

/* Animation for dialog appearance */
@keyframes dialogSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes dialogSlideOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.95) translateY(-20px);
  }
}

#print-details-dialog[open],
#print-info-dialog[open],
#name-required-dialog[open] {
  animation: dialogSlideIn 0.3s ease-out;
}

#print-details-dialog.closing,
#print-info-dialog.closing,
#name-required-dialog.closing {
  animation: dialogSlideOut 0.2s ease-in forwards;
}

/* Custom closing animation for dragged dialog */
#print-details-dialog.closing {
  animation: dialogSlideOutFromPosition 0.2s ease-in forwards;
}

@keyframes dialogSlideOutFromPosition {
  from {
    opacity: 1;
    transform: var(--closing-transform, scale(1) translateY(0));
  }
  to {
    opacity: 0;
    transform: var(--closing-transform, scale(0.95) translateY(-20px));
  }
}

/* Responsive adjustments */
@media (max-width: 600px) {
  #print-details-dialog {
    max-width: 95vw;
    width: 95vw;
    max-height: 80vh;
    margin: 10px;
  }
  
  #print-details-dialog h3 {
    margin: 0;
    padding: 16px 20px;
    font-size: 16px;
  }
  
  #print-details-dialog .muted {
    margin: 16px 16px 20px 16px;
  }
  
  #print-details-dialog .field {
    margin: 0 16px 16px 16px;
  }
  
  #print-details-dialog menu {
    margin: 20px 16px 0 16px;
    flex-direction: column;
    gap: 8px;
  }
  
  #print-details-dialog .primary,
  #print-details-dialog .secondary {
    width: 100%;
    justify-content: center;
  }
}

/* Print-specific styles for the main app */
@media print {
  .app-header,
  .results-actions,
  .app-footer,
  .pwa-install,
  .net-toast {
    display: none !important;
  }
  
  .view-results {
    box-shadow: none !important;
    border: none !important;
    background: white !important;
    color: black !important;
  }
  
  .results-cards {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 20px !important;
    margin-bottom: 20px !important;
  }
  
  .result-card {
    background: #f8f9fa !important;
    border: 1px solid #e9ecef !important;
    padding: 15px !important;
    text-align: center !important;
  }
  
  .result-label {
    color: #666 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    margin-bottom: 5px !important;
  }
  
  .result-value {
    color: #05339C !important;
    font-size: 24px !important;
    font-weight: 700 !important;
  }
  
  .mistakes-wrap {
    background: #fff5f5 !important;
    border: 1px solid #fed7d7 !important;
    padding: 20px !important;
    margin-top: 20px !important;
  }
  
  .mistakes-wrap h3 {
    color: #c53030 !important;
    margin: 0 0 15px 0 !important;
    font-size: 18px !important;
  }
}
