:root {
  --bg: #f4f4fb;
  --card: #ffffff;
  --ink: #1c2033;
  --muted: #7a7e93;
  --accent: #5b5bd6;
  --accent-soft: #ececfd;
  --good: #1a9e6e;
  --bad: #d94f4f;
  --line: #e7e8f2;
  --shadow: 0 2px 10px rgba(28, 32, 51, .06);
}

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 72px; /* nav */
}

header#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 8px;
}
#topbar h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
#streak-box {
  display: flex; align-items: center; gap: 4px;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; border-radius: 999px; padding: 4px 12px; font-size: .9rem;
}

.view { display: none; padding: 8px 18px 24px; flex: 1; }
.view.active { display: block; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

/* ---- home / goal ---- */
.goal-card { display: flex; align-items: center; gap: 18px; margin: 10px 0 16px; }
.goal-ring { position: relative; width: 96px; height: 96px; flex-shrink: 0; }
.goal-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--accent-soft); stroke-width: 10; }
.ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 276.5;
  stroke-dashoffset: 276.5;
  transition: stroke-dashoffset .4s ease;
}
.ring-text {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.05rem;
}
.goal-text h2 { font-size: 1.05rem; margin-bottom: 4px; }
.goal-text p { color: var(--muted); font-size: .92rem; line-height: 1.35; }

#btn-start {
  width: 100%; padding: 16px; border: 0; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 1.05rem; font-weight: 700;
  cursor: pointer; transition: transform .08s ease, opacity .15s;
}
#btn-start:active { transform: scale(.98); }
#btn-start:disabled { opacity: .5; cursor: default; }
.hint { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 10px; line-height: 1.5; }

/* ---- quiz ---- */
.q-meta { display: flex; justify-content: space-between; align-items: center; margin: 12px 2px; font-size: .85rem; color: var(--muted); }
.tag { background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 2px 8px; font-weight: 600; }
.q-card { text-align: center; padding: 26px 18px; }
.q-prompt { color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.q-word { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.q-pron { color: var(--muted); font-size: .95rem; margin-top: 6px; min-height: 1.2em; }

#options { display: flex; flex-direction: column; gap: 10px; }
#options button{
  background: var(--card); border: 1.5px solid var(--line); border-radius: 14px;
  padding: 15px; font-size: 1rem; font-weight: 600; color: var(--ink);
  cursor: pointer; transition: border-color .15s, background .15s, transform .08s;
  text-align: left;
}
#options button:active { transform: scale(.99); }
#options button.correct { border-color: var(--good); background: #e9f7f1; color: var(--good); }
#options button.wrong   { border-color: var(--bad);  background: #fdeded; color: var(--bad); }
#options button:disabled { cursor: default; opacity: 1; }

.reveal-card { margin-top: 14px; }
.reveal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.verdict { font-weight: 800; font-size: .95rem; }
.verdict.ok { color: var(--good); }
.verdict.no { color: var(--bad); }
.reveal-card h3 { font-size: 1.3rem; }
.reveal-card ul { margin: 10px 0 0 0; padding-left: 0; list-style: none; }
.reveal-card ul li { margin-bottom: 8px; line-height: 1.45; font-size: .95rem; }
.reveal-card li b.pos { color: var(--accent); font-style: italic; margin-right: 6px; }
.example { color: var(--muted); font-style: italic; font-size: .92rem; margin: 8px 0 12px; line-height: 1.45; }

/* ---- buttons ---- */
.btn-primary { appearance: none; border: 0; }
.btn-primary, .btn-secondary, .btn-danger {
  display: block; width: 100%; padding: 14px; border-radius: 12px;
  font-size: .98rem; font-weight: 700; cursor: pointer; margin: 6px 0;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:disabled { opacity: .5; }
.btn-primary.small { width: auto; padding: 10px 18px; }
.btn-secondary { background: var(--accent-soft); color: var(--accent); border: 0; }
.btn-danger { background: #fdeded; color: var(--bad); border: 0; }

/* ---- progress ---- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.stat { text-align: center; padding: 16px 8px; margin-bottom: 0; }
.stat h3 { font-size: 1.6rem; font-weight: 800; }
.stat p { color: var(--muted); font-size: .8rem; margin-top: 2px; }
#view-progress .card { margin-top: 10px; }
#view-progress h3 { margin-bottom: 12px; font-size: 1rem; }

.level-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.level-row .lvl-label { width: 118px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.level-row .lvl-count { width: 34px; text-align: right; font-size: .85rem; font-weight: 700; }
.lvl-bar { flex: 1; height: 10px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.lvl-fill { height: 100%; border-radius: 999px; transition: width .3s ease; }

/* ---- browse ---- */
#search {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 12px; font-size: 1rem; background: var(--card); margin: 8px 0;
  outline: none;
}
#search:focus { border-color: var(--accent); }
.filters { display: flex; gap: 8px; margin-bottom: 12px; }
.chip {
  border: 1.5px solid var(--line); background: var(--card); color: var(--muted);
  padding: 7px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#word-list { list-style: none; padding: 0; }
#word-list li {
  background: var(--card); border-radius: 14px; padding: 13px 16px; margin-bottom: 8px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; cursor: pointer;
}
#word-list li .wl-word { font-weight: 700; flex: 1; }
#word-list li .wl-pos { color: var(--muted); font-size: .78rem; }
#word-list li .bk { color: var(--accent); font-size: 1rem; }
.dot { width: 10px; height: 10px; border-radius: 999px; flex-shrink: 0; }

/* ---- sheet ---- */
#sheet-backdrop {
  position: fixed; inset: 0; background: rgba(20, 20, 35, .45); z-index: 40;
}
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--card); border-radius: 22px 22px 0 0;
  max-width: 480px; margin: 0 auto; padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,.18);
}
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.sheet-head h3 { font-size: 1.6rem; font-weight: 800; }
#sinventory { display: none; }
#d-syns { color: var(--muted); font-size: .9rem; margin-top: 10px; }
.level-badge {
  display: inline-block; font-size: .78rem; font-weight: 700; padding: 4px 10px;
  border-radius: 999px; margin: 6px 0 12px;
}
#sheet ul { list-style: none; padding: 0; }
#sheet ul li { margin-bottom: 8px; line-height: 1.45; font-size: .95rem; }
#sheet ul li b.pos { color: var(--accent); font-style: italic; margin-right: 6px; }

.one-line { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }

/* ---- settings ---- */
#view-settings .row { display: flex; gap: 10px; align-items: center; }
#goal-input {
  width: 90px; padding: 10px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 1rem;
}

/* ---- nav ---- */
#nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: var(--card);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
}
.nav-btn {
  background: none; border: 0; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 2px; color: var(--muted); font-size: 1.15rem; padding: 2px 14px;
}
.nav-btn span { font-size: .68rem; font-weight: 600; }
.nav-btn.active { color: var(--accent); }

/* ---- toast ---- */
#toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: .85rem; z-index: 60; opacity: .95;
}
