:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #252540;
  --accent: #7c6fff;
  --accent-light: #a594ff;
  --text: #e8e8f0;
  --text-dim: #8888aa;
  --success: #4ade80;
  --warning: #facc15;
  --danger: #f87171;
  --radius: 16px;
}

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

body {
  font-family: -apple-system, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  width: 100%;
}

/* Header */
header {
  padding: 12px 20px 8px;
}

.progress-bar {
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  margin-bottom: 10px;
}

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

.header-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-dim);
}

#session-score { color: var(--success); }

/* Main */
main {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.source-badge {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
}

/* Timer Ring */
.timer-container {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto;
}

.timer-ring {
  width: 120px;
  height: 120px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--surface2);
  stroke-width: 8;
}

.ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339.3;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}

.ring-fg.warning { stroke: var(--warning); }
.ring-fg.danger  { stroke: var(--danger); }

#timer-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
}

/* Prompt Card */
.prompt-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
}

.prompt-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.zh-text {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

.notes-text {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  line-height: 1.5;
}

/* Input Area */
.input-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#ja-input {
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--surface2);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 20px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

#ja-input:focus { border-color: var(--accent); }
#ja-input::placeholder { color: var(--text-dim); font-size: 16px; }

.input-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-btn {
  background: var(--surface);
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 20px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

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

.primary-btn {
  flex: 1;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.primary-btn:hover { opacity: 0.9; }
.primary-btn:active { transform: scale(0.98); }

.voice-status {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  min-height: 16px;
}

/* Result Area */
.result-area {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-label {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.result-label.correct { color: var(--success); }
.result-label.timeout { color: var(--warning); }

.ja-answer {
  font-size: 22px;
  text-align: center;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

.word-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.word-chip {
  background: var(--surface2);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 14px;
  color: var(--accent-light);
}

.result-actions {
  display: flex;
  gap: 10px;
}

.secondary-btn {
  background: var(--surface2);
  color: var(--text);
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.secondary-btn:hover { background: #333360; }

/* Footer */
footer {
  padding: 12px 20px 24px;
  display: flex;
  gap: 8px;
  justify-content: center;
}

.footer-btn {
  background: var(--surface);
  color: var(--text-dim);
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.footer-btn:hover { background: var(--surface2); color: var(--text); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-content h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-content label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  color: var(--text-dim);
}

.modal-content input[type="number"] {
  width: 60px;
  background: var(--surface2);
  border: none;
  border-radius: 8px;
  padding: 8px;
  color: var(--text);
  font-size: 16px;
  text-align: center;
}

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.listening { animation: pulse 1s infinite; }

/* Responsive */
@media (max-height: 700px) {
  .timer-container { width: 90px; height: 90px; }
  .timer-ring { width: 90px; height: 90px; }
  #timer-display { font-size: 28px; }
  .zh-text { font-size: 20px; }
}
