:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a2433;
  --text-dim: #5a6b7d;
  --accent: #1e3a5f;
  --accent-2: #2f6690;
  --good: #3aa76d;
  --easy: #3a7ca5;
  --hard: #d99a3d;
  --again: #c9515b;
  --border: #e1e6ea;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1b2b;
    --surface: #17263b;
    --text: #eef2f6;
    --text-dim: #9fb0c2;
    --accent: #7fd8be;
    --accent-2: #4f9ac9;
    --border: #22354d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.hidden { display: none !important; }

h1 {
  font-size: 1.5rem;
  margin: 0 0 4px;
  color: var(--accent);
}

.hint { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 20px; }
.error { color: var(--again); font-size: 0.85rem; min-height: 1.2em; }

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 14px;
}

input[type="text"], input[type="url"], input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--accent-2);
  color: #fff;
  padding: 14px;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 10px;
}

.btn-secondary {
  background: transparent;
  color: var(--text-dim);
  padding: 12px;
  margin-top: 8px;
  font-size: 0.95rem;
}

.btn-icon {
  background: transparent;
  color: var(--text-dim);
  font-size: 1.3rem;
  padding: 6px 10px;
}

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

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 6px;
  text-align: center;
}

.stat span {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-2);
}

.stat label {
  margin: 0;
  font-size: 0.72rem;
}

.session-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-2);
  transition: width 0.25s ease;
}

#prompt-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 280px;
  justify-content: center;
}

.prompt-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin: 0 0 8px;
}

.prompt-name {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  margin: 8px 0 0;
}

#structure-canvas { max-width: 100%; height: auto; }

.mc-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.mc-options button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 8px;
  font-size: 0.95rem;
  color: var(--text);
  min-height: 56px;
}

.mc-options button.correct { background: color-mix(in srgb, var(--good) 25%, var(--surface)); border-color: var(--good); }
.mc-options button.wrong { background: color-mix(in srgb, var(--again) 25%, var(--surface)); border-color: var(--again); }

.mc-options button canvas { max-width: 100%; height: auto; display: block; margin: 0 auto; }

.typed-input { margin-top: 16px; }

.feedback-area {
  margin-top: 16px;
  text-align: center;
}

#feedback-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.rate-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.rate-buttons button {
  padding: 14px 4px;
  border-radius: 10px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
}

.rate.again { background: var(--again); }
.rate.hard { background: var(--hard); }
.rate.good { background: var(--good); }
.rate.easy { background: var(--easy); }
