:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --ink: #18211d;
  --muted: #66736b;
  --line: #d8e0da;
  --panel: #ffffff;
  --soft: #edf5f1;
  --accent: #156f5a;
  --accent-ink: #ffffff;
  --warn: #b94b3f;
  --blue: #315f8f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(100%, 760px); margin: 0 auto; padding: 18px 14px 32px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0 16px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2rem, 9vw, 3.4rem); line-height: 1; }
h2 { margin-bottom: 12px; font-size: 1.12rem; }

.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: var(--panel); color: var(--accent); font-size: 1.35rem; }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 16px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.55); }
.tab { min-height: 42px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 850; }
.tab.is-active { background: var(--ink); color: #fff; }
.view { display: none; }
.view.is-active { display: block; }

.hero-panel, .study-card, .word-form, .backup-box, .ai-section, .progress-panel, .status-grid article { border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.9); box-shadow: 0 16px 36px rgba(35,52,44,.07); }
.hero-panel, .study-card, .word-form, .backup-box, .ai-section, .progress-panel { padding: 18px; margin-bottom: 12px; }
.prompt-label, .helper, .backup-box p { color: var(--muted); line-height: 1.55; }
.prompt-label { margin-bottom: 8px; font-weight: 850; }
.hero-panel h2 { font-size: clamp(1.6rem, 7vw, 2.6rem); margin-bottom: 8px; }

.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.status-grid article { min-height: 78px; padding: 12px; }
.status-grid span { display: block; color: var(--muted); font-size: .82rem; }
.status-grid strong { display: block; margin-top: 8px; font-size: clamp(1.35rem, 7vw, 2rem); }
.progress-panel { display: grid; gap: 12px; }
.progress-panel p { margin-bottom: 0; color: var(--muted); }
.progress-track { height: 12px; border-radius: 999px; background: #dbe6df; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .2s ease; }

.study-card { position: relative; min-height: 310px; }
.sound-button { position: absolute; top: 18px; right: 18px; min-width: 60px; min-height: 36px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.word-face { display: grid; min-height: 150px; align-content: center; gap: 12px; }
.word-face p { margin: 0; overflow-wrap: anywhere; font-size: clamp(2.4rem, 14vw, 5rem); font-weight: 900; line-height: 1; }
.word-face span { width: fit-content; max-width: 100%; padding: 6px 10px; border-radius: 999px; background: var(--soft); color: var(--accent); font-weight: 850; overflow-wrap: anywhere; }
.answer-panel { border-top: 1px solid var(--line); padding-top: 16px; }
.answer-panel strong { display: block; margin-bottom: 8px; font-size: 1.35rem; }
.answer-panel p { color: var(--muted); }
.answer-panel small { color: var(--blue); font-weight: 800; }

.study-actions, .button-row { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 10px 0; }
.primary, .secondary, .danger, .file-button { min-height: 50px; border-radius: 8px; border: 1px solid transparent; padding: 0 14px; display: inline-grid; place-items: center; font-weight: 900; text-align: center; }
.primary { background: var(--accent); color: var(--accent-ink); }
.secondary, .file-button { background: var(--panel); border-color: var(--line); color: var(--ink); }
.danger { background: #fff2ee; border-color: #f0c3bb; color: var(--warn); }
.wide { width: 100%; }

label { display: grid; gap: 6px; margin-bottom: 12px; color: var(--muted); font-weight: 800; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); padding: 12px; }
textarea { resize: vertical; }
.file-button input { display: none; }
.list-toolbar { display: grid; grid-template-columns: 1fr minmax(120px, auto) auto; gap: 8px; margin: 12px 0; }
.word-list, .preview-list, .level-ladder { display: grid; gap: 8px; }
.word-item, .preview-item, .level-ladder article, .level-card { border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.78); padding: 14px; }
.word-item { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.word-item strong, .preview-item strong, .level-card strong, .level-ladder strong { display: block; font-size: 1.08rem; overflow-wrap: anywhere; }
.word-item span, .preview-item span, .level-card span, .level-ladder span { display: block; margin-top: 4px; color: var(--accent); font-weight: 850; overflow-wrap: anywhere; }
.word-item p, .level-card p, .level-ladder p { margin: 6px 0 0; color: var(--muted); }
.word-item button { min-width: 48px; min-height: 38px; border: 1px solid #f0c3bb; border-radius: 8px; background: #fff8f6; color: var(--warn); font-weight: 850; }
.level-ladder article.is-current { border-color: var(--accent); background: var(--soft); }
.preview-title { margin: 12px 0 4px; color: var(--blue); font-weight: 900; }
.result { min-height: 24px; color: var(--muted); }
.result.success { color: var(--accent); font-weight: 850; }
.result.warning { color: var(--warn); font-weight: 850; }
.result.loading { color: var(--blue); font-weight: 850; }
.empty { color: var(--muted); }

@media (min-width: 640px) {
  .study-actions { grid-template-columns: repeat(4, 1fr); }
  .button-row { grid-template-columns: repeat(2, 1fr); }
  .level-ladder { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 430px) {
  .tabs { grid-template-columns: repeat(2, 1fr); }
  .status-grid, .word-item, .list-toolbar { grid-template-columns: 1fr; }
}
.answer-input-wrap {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.answer-input-wrap input:disabled {
  background: #eef4f0;
  color: var(--muted);
}

.bulk-add {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.bulk-add h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}
