:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #1a1d21;
  --text-2: #586170;
  --text-3: #8b94a0;
  --border: rgba(18, 22, 28, 0.09);
  --border-strong: rgba(18, 22, 28, 0.16);
  --shadow: 0 1px 2px rgba(18, 22, 28, 0.04), 0 6px 20px rgba(18, 22, 28, 0.05);
  --track: #e6e9ee;
  --accent: #185fa5;
  --good: #1d9e75;
  --warn: #d9a400;
  --bad: #d8513b;
  --radius: 18px;
  --radius-sm: 11px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161b22;
    --surface-2: #1d242d;
    --text: #e7ebef;
    --text-2: #9aa4b1;
    --text-3: #69727e;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);
    --shadow: none;
    --track: #232b35;
    --accent: #6fb0ee;
    --good: #46c79f;
    --warn: #e7bd4b;
    --bad: #ef7359;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(18px, 3.5vw, 40px) clamp(14px, 3.5vw, 32px) 56px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: clamp(18px, 3vw, 28px);
}
.topbar__title h1 {
  margin: 0;
  font-size: clamp(20px, 3.4vw, 28px);
  font-weight: 700;
  letter-spacing: 0.01em;
}
.topbar__title h1 span { color: var(--text-2); font-weight: 600; }
.subtitle { margin: 4px 0 0; color: var(--text-2); font-size: clamp(12px, 2.4vw, 14px); }

.freshness {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text-2);
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.is-fresh { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 22%, transparent); }
.dot.is-stale { background: var(--warn); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 22%, transparent); }
.dot.is-old   { background: var(--bad);  box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 22%, transparent); }

/* ---------- banner ---------- */
.banner {
  margin-bottom: 16px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 36%, transparent);
  color: var(--text);
  font-size: 13.5px;
}

/* ---------- hero: estimated vocabulary ---------- */
.hero {
  display: flex; gap: clamp(16px, 3vw, 32px); align-items: center; justify-content: space-between;
  flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 28px) clamp(18px, 3vw, 30px); margin-bottom: clamp(14px, 2.2vw, 20px);
}
.hero__main { min-width: 0; flex: 1 1 280px; }
.hero__label { font-size: 13px; color: var(--text-2); font-weight: 600; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hero__hint { font-size: 11px; color: var(--text-3); font-weight: 400; cursor: help; }
.hero__num { display: flex; align-items: baseline; gap: 7px; margin: 6px 0 12px; }
#hero-vocab { font-size: clamp(40px, 9vw, 62px); font-weight: 700; line-height: 1; color: var(--good); letter-spacing: -0.01em; }
.hero__unit { font-size: clamp(16px, 3vw, 22px); font-weight: 500; color: var(--text-2); }
.hero__bar { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; max-width: 440px; }
.hero__bar-fill { height: 100%; background: var(--good); border-radius: 999px; transition: width .8s cubic-bezier(.22,.61,.36,1); }
.hero__sub { margin-top: 10px; font-size: 13px; color: var(--text-2); }
.hero__stats { display: grid; grid-template-columns: repeat(2, minmax(94px, 1fr)); gap: 10px; }
.hstat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; text-align: center; }
.hstat b { display: block; font-size: 20px; font-weight: 700; line-height: 1.15; }
.hstat span { font-size: 11px; color: var(--text-3); }

/* ---------- activity chart ---------- */
.activity-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: clamp(14px, 2.4vw, 20px) clamp(16px, 2.4vw, 22px);
  margin-bottom: clamp(14px, 2.2vw, 20px);
}
.activity__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.activity__title { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.activity__today { font-size: 13px; font-weight: 500; color: var(--accent); white-space: nowrap; }
.activity__chart { display: flex; align-items: stretch; gap: clamp(3px, 1.1vw, 8px); height: 104px; }
.abar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.abar__col { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.abar__fill { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; transition: height .6s ease; }
.abar__lbl { font-size: 10px; color: var(--text-3); white-space: nowrap; }

/* ---------- decks grid ---------- */
.decks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
  gap: clamp(14px, 2.2vw, 20px);
}
.loading { color: var(--text-3); padding: 40px 0; text-align: center; grid-column: 1 / -1; }

.deck {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(16px, 2.4vw, 22px);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.deck > * { min-width: 0; }

.deck__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.deck__name { font-size: clamp(18px, 2.6vw, 21px); font-weight: 700; margin: 0; }
.deck__name small { font-weight: 500; color: var(--text-3); font-size: 0.62em; margin-left: 6px; }
.deck__rates { display: flex; gap: 18px; }
.rate { text-align: right; line-height: 1.1; }
.rate b { font-size: clamp(20px, 3.2vw, 24px); font-weight: 700; }
.rate span { display: block; font-size: 11px; color: var(--text-3); margin-top: 2px; }
.rate.est b { color: var(--text); }
.rate.started b { color: var(--accent); }
.rate.mastered b { color: var(--good); }
.deck__studied { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); margin: 0 0 13px; }
.deck__studied .dot { width: 7px; height: 7px; }

/* today's remaining */
.today {
  display: flex;
  align-items: stretch;
  gap: 9px;
  margin-bottom: 16px;
}
.today__label {
  font-size: 12px;
  color: var(--text-2);
  align-self: center;
  white-space: nowrap;
  font-weight: 600;
}
.tstat {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 9px 6px 7px;
  text-align: center;
}
.tstat b { font-size: clamp(20px, 3.4vw, 26px); font-weight: 700; line-height: 1.05; display: block; }
.tstat span { font-size: 11px; color: var(--text-3); }
.tstat.new b   { color: var(--text); }
.tstat.review b{ color: var(--accent); }
.tstat.learn b { color: #b07400; }
@media (prefers-color-scheme: dark) { .tstat.learn b { color: #e7bd4b; } }

/* the bar */
.bar {
  display: flex;
  width: 100%;
  height: 34px;
  border-radius: 9px;
  overflow: hidden;
  background: var(--track);
}
.bar__seg { height: 100%; transition: width .6s cubic-bezier(.22,.61,.36,1); min-width: 0; }

.annot {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 15px;
  margin-top: 12px;
}
.annot__item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.annot__item b { font-weight: 700; color: var(--text); }

/* subdecks */
.subs { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.subs__title { font-size: 13.5px; color: var(--text-2); margin: 0 0 13px; font-weight: 600; }
.sub { margin: 16px 0; }
.sub__top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.sub__name { font-size: 15px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub__stats { font-size: 12.5px; color: var(--text-3); white-space: nowrap; flex: none; }
.sub__bottom { display: flex; align-items: center; gap: 12px; }
.sub__bottom .bar { height: 22px; border-radius: 7px; flex: 1; min-width: 0; }
.sub__rate { font-size: 14px; font-weight: 500; color: var(--text-2); text-align: right; white-space: nowrap; flex: none; min-width: 56px; }

/* ---------- footer ---------- */
.foot { margin-top: 26px; color: var(--text-3); font-size: 12px; text-align: center; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (max-width: 430px) {
  .deck__rates { gap: 14px; }
  .today { gap: 7px; }
  .sub__rate { min-width: 48px; }
}
