/* ============================================
   Edwin's Mandarin Coach - Styles
   Tanpa framework eksternal supaya jalan penuh saat offline.
   ============================================ */

:root {
  --bg: #4c1d95;
  --bg2: #6d28d9;
  --bg3: #db2777;
  --surface: rgba(255, 255, 255, 0.12);
  --surface-solid: #ffffff;
  --border: rgba(255, 255, 255, 0.22);
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.72);
  --ink: #1f2937;
  --ink-dim: #6b7280;
  --accent: #7c3aed;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 45%, var(--bg3) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(16px + var(--safe-top)) 16px calc(28px + var(--safe-bottom));
  animation: fade .25s ease;
}
.center-screen { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Header ---------- */
.hero { text-align: center; margin: 8px 0 20px; }
.hero h1 { font-size: 40px; margin: 0 0 4px; letter-spacing: 2px; }
.hero p { margin: 2px 0; color: var(--text-dim); font-size: 15px; }
.hero-total { font-size: 13px !important; }

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.topbar h2 { flex: 1; font-size: 16px; font-weight: 600; margin: 0; text-align: center; color: var(--text-dim); }
.topbar-spacer { width: 44px; }
.icon-btn {
  width: 44px; height: 44px; flex: none;
  border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 20px; cursor: pointer;
}

/* ---------- Panel ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; font-size: 14px; color: var(--text-dim); }
.panel-head b { color: var(--text); font-size: 16px; }
.hint { font-size: 13px; color: var(--text-dim); line-height: 1.6; margin: 10px 0 0; }
.hint.center { text-align: center; }

.progress { height: 10px; border-radius: 99px; background: rgba(255,255,255,.2); overflow: hidden; }
.progress.thin { height: 5px; margin-bottom: 18px; }
.progress i { display: block; height: 100%; background: #fff; border-radius: 99px; transition: width .3s ease; }

/* ---------- Level picker ---------- */
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.level-card {
  position: relative;
  padding: 12px 6px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.14);
  color: var(--text);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: transform .15s ease, background .15s ease;
}
.level-card:active { transform: scale(.97); }
.level-card.active { background: #fff; color: var(--accent); border-color: #fff; font-weight: 700; }
.level-num { font-size: 22px; font-weight: 700; line-height: 1; }
.level-count { font-size: 11px; opacity: .8; }
.level-bar { display: block; width: 70%; height: 3px; border-radius: 99px; background: rgba(0,0,0,.15); overflow: hidden; }
.level-card.active .level-bar { background: rgba(124,58,237,.2); }
.level-bar i { display: block; height: 100%; background: currentColor; }

/* ---------- Buttons ---------- */
.actions { display: flex; flex-direction: column; gap: 10px; }
.btn {
  width: 100%;
  padding: 15px 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 16px; font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { background: #fff; color: var(--accent); border-color: #fff; }
.btn-danger { background: rgba(239,68,68,.85); border-color: rgba(239,68,68,.9); }
.btn-small { padding: 11px 12px; font-size: 14px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wide { width: 100%; }

/* ---------- Flashcard ---------- */
.card {
  position: relative;
  background: var(--surface-solid);
  color: var(--ink);
  border-radius: 26px;
  padding: 38px 24px 30px;
  min-height: 260px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  box-shadow: 0 18px 40px rgba(0,0,0,.22);
  cursor: pointer;
  margin-bottom: 18px;
}
.card-status {
  position: absolute; top: 14px; left: 16px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ink-dim);
}
.hanzi { font-size: 60px; font-weight: 700; color: var(--accent); line-height: 1.25; word-break: break-word; }
.pinyin { font-size: 20px; color: var(--ink-dim); margin-top: 10px; }
.meaning { font-size: 24px; font-weight: 700; color: #be185d; margin-top: 14px; }
.meaning-big { font-size: 34px; font-weight: 700; color: var(--accent); }
.english { font-size: 14px; color: var(--ink-dim); font-style: italic; margin-top: 6px; }
.tap-hint { font-size: 13px; color: #9ca3af; margin-top: 22px; }
.audio-btn {
  position: absolute; top: 10px; right: 10px;
  width: 42px; height: 42px;
  border-radius: 50%; border: none;
  background: #f3f4f6; color: var(--ink);
  font-size: 18px; cursor: pointer;
}

/* ---------- Grading ---------- */
.grade-row { display: flex; gap: 8px; }
.grade {
  flex: 1;
  padding: 13px 4px;
  border-radius: 14px; border: none;
  color: #fff; font-size: 14px; font-weight: 700;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.grade small { font-weight: 500; font-size: 10px; opacity: .85; }
.grade.again { background: var(--bad); }
.grade.hard  { background: #f97316; }
.grade.good  { background: var(--warn); }
.grade.easy  { background: var(--ok); }

/* ---------- Quiz ---------- */
.quiz-prompt {
  position: relative;
  background: var(--surface-solid);
  color: var(--ink);
  border-radius: 24px;
  padding: 34px 20px;
  text-align: center;
  margin-bottom: 16px;
  box-shadow: 0 14px 32px rgba(0,0,0,.2);
}
.quiz-sub { font-size: 13px; color: var(--ink-dim); margin-top: 10px; }
.quiz-opts { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.quiz-opt {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 15px 16px;
  border-radius: 15px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 17px; text-align: left;
  cursor: pointer;
}
.quiz-opt .opt-key {
  flex: none; width: 26px; height: 26px;
  border-radius: 8px; background: rgba(255,255,255,.2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.quiz-opt.correct { background: var(--ok); border-color: var(--ok); }
.quiz-opt.wrong { background: var(--bad); border-color: var(--bad); }
.quiz-opt:disabled { cursor: default; opacity: 1; }

/* ---------- Daftar kosakata ---------- */
.search-wrap { margin-bottom: 12px; }
.search {
  width: 100%; padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.16);
  color: var(--text);
  font-size: 16px;
}
.search::placeholder { color: rgba(255,255,255,.6); }
.vocab-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.vocab-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.vocab-h { font-size: 26px; font-weight: 700; min-width: 92px; }
.vocab-body { flex: 1; min-width: 0; font-size: 14px; line-height: 1.5; color: var(--text-dim); }
.vocab-tags { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.vocab-body b { color: var(--text); font-weight: 600; }
.vocab-body i { font-size: 12px; }
.vocab-empty { padding: 24px; text-align: center; color: var(--text-dim); }
.badge { font-size: 10px; padding: 4px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: .4px; }
.badge.mastered { background: var(--ok); }
.badge.learning { background: var(--warn); color: #422006; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; font-size: 14px; color: var(--text-dim); }
.pager .btn { width: auto; }

/* ---------- Statistik ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px 8px; text-align: center;
}
.stat b { display: block; font-size: 28px; }
.stat span { font-size: 11px; color: var(--text-dim); }
.stat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stat-table th, .stat-table td { padding: 8px 4px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.12); }
.stat-table th { color: var(--text-dim); font-weight: 500; font-size: 11px; text-transform: uppercase; }
.mini-bar { display: inline-block; width: 42px; height: 5px; border-radius: 99px; background: rgba(255,255,255,.2); overflow: hidden; vertical-align: middle; }
.mini-bar i { display: block; height: 100%; background: #fff; }

/* ---------- Form ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-dim); }
.form label.row { flex-direction: row; align-items: center; gap: 10px; }
.form input[type="number"], .form select {
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.16); color: var(--text);
  font-size: 16px;
}
.form select option { color: #111; }
.form input[type="checkbox"] { width: 20px; height: 20px; }

/* ---------- Selesai ---------- */
.done { text-align: center; padding: 20px; }
.done-icon { font-size: 60px; margin-bottom: 10px; }
.done h2 { margin: 0 0 8px; font-size: 24px; }
.done p { color: var(--text-dim); margin-bottom: 22px; }
.done code { background: rgba(0,0,0,.25); padding: 2px 6px; border-radius: 6px; }

/* ---------- Bar akun (login) ---------- */
@media (min-width: 720px) {
  .hanzi { font-size: 72px; }
  .level-grid { grid-template-columns: repeat(3, 1fr); }
}

.badge.level-tag { background: rgba(255,255,255,.22); color: var(--text); }

.badge.pending { background: rgba(255,255,255,.18); color: var(--text-dim); }
.muted { opacity: .55; }
.warn-note { display: block; margin-top: 6px; font-size: 12px; opacity: .85; }

.form input[type="range"] { width: 100%; accent-color: #fff; }
.panel code { background: rgba(0,0,0,.22); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

.diag-list { list-style: none; margin: 8px 0; padding: 0; font-size: 13px; color: var(--text-dim); }
.diag-list li { padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.1); line-height: 1.5; }
.diag-list li:last-child { border-bottom: none; }

/* ---------- Modul bisnis ---------- */
.biz-panel { border-color: rgba(255,255,255,.34); }
.biz-cat { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); margin: 4px 0 10px; }
.biz-cat select {
  padding: 11px 13px; border-radius: 12px; border: 1px solid var(--border);
  background: rgba(255,255,255,.16); color: var(--text); font-size: 15px;
}
.biz-cat select option { color: #111; }
.contoh {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid #e5e7eb;
  font-size: 14px; color: var(--ink-dim); line-height: 1.6;
}
.contoh b { color: var(--ink); font-size: 17px; }
.vocab-ex { display: inline-block; margin-top: 4px; font-size: 12px; opacity: .75; }

.pola-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.pola {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 14px 16px;
}
.pola-head { display: flex; align-items: center; gap: 10px; }
.pola-no {
  flex: none; width: 24px; height: 24px; border-radius: 8px;
  background: rgba(255,255,255,.2); display: inline-flex;
  align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.pola-p { font-size: 20px; font-weight: 700; }
.pola-pin { font-size: 13px; color: var(--text-dim); margin: 4px 0 0 34px; }
.pola-arti { font-size: 14px; margin: 6px 0 0 34px; }
.pola-contoh {
  margin: 12px 0 0 34px; padding: 10px 12px; border-radius: 12px;
  background: rgba(0,0,0,.16); cursor: pointer; line-height: 1.6;
}
.pola-cn { display: block; font-size: 16px; font-weight: 600; }
.pola-cnp { display: block; font-size: 12px; color: var(--text-dim); }
.pola-cnm { display: block; font-size: 13px; margin-top: 4px; }
