
:root {
  --navy: #17324d;
  --navy-2: #244d70;
  --blue-soft: #eaf2f8;
  --paper: #ffffff;
  --background: #f4f6f8;
  --text: #163047;
  --muted: #6b7c8c;
  --line: #dce4ea;
  --correct: #287a4a;
  --correct-bg: #e8f5ed;
  --review: #a55a16;
  --review-bg: #fff1df;
  --danger: #a13e3e;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}
* { box-sizing: border-box; }
html { background: var(--background); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, .flash-card:focus-visible {
  outline: 3px solid rgba(36, 77, 112, .25);
  outline-offset: 3px;
}
#app {
  width: min(100%, 760px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--background);
  padding-bottom: calc(86px + var(--safe-bottom));
}
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(18px + var(--safe-top)) 18px 12px;
}
.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
}
h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: var(--navy);
  font-size: 24px;
  line-height: 1;
}
main { padding: 0 16px 24px; }
.view { display: none; }
.view.active { display: block; }
.summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0 12px;
}
.summary-row > div {
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.8);
  text-align: center;
}
.summary-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}
.summary-row strong { font-size: 16px; }
.control-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 10px;
}
.control-button {
  display: flex;
  min-height: 58px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  color: var(--text);
}
.control-button span { color: var(--muted); font-size: 11px; }
.control-button strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 12px 0;
  padding: 4px;
  border-radius: 14px;
  background: #e6ebef;
}
.mode-tab {
  min-height: 40px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}
.mode-tab.active {
  background: var(--paper);
  color: var(--navy);
  box-shadow: 0 2px 8px rgba(23,50,77,.08);
}
.progress-wrap {
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: #dfe6eb;
}
.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--navy-2);
  transition: width .2s ease;
}
.position-text {
  margin: 6px 2px 9px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}
.flash-card {
  display: flex;
  min-height: 310px;
  padding: 28px 22px;
  border: 1px solid rgba(23,50,77,.08);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 14px 34px rgba(23,50,77,.10);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#cardContent { width: 100%; text-align: center; }
.category-chip {
  display: inline-block;
  max-width: 100%;
  margin-bottom: 24px;
  padding: 7px 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--navy-2);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#termText {
  margin: 0;
  font-size: clamp(28px, 8vw, 40px);
  line-height: 1.35;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}
.prompt-text {
  margin: 0;
  font-size: clamp(18px, 4.8vw, 22px);
  line-height: 1.85;
  text-align: left;
  overflow-wrap: anywhere;
}
.tap-hint {
  margin: 26px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.answer-area { margin-top: 24px; }
.divider {
  width: 56px;
  height: 2px;
  margin: 0 auto 21px;
  border-radius: 99px;
  background: var(--line);
}
.answer-term {
  text-align: center;
}
.answer-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 13px;
}
.answer-button {
  min-height: 54px;
  border: 0;
  border-radius: 16px;
  font-weight: 800;
}
.answer-button.correct { background: var(--correct-bg); color: var(--correct); }
.answer-button.review { background: var(--review-bg); color: var(--review); }
.skip-button {
  width: 100%;
  min-height: 44px;
  margin-top: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.hidden { display: none !important; }
.empty-state { padding: 30px 10px; text-align: center; }
.empty-state h2 { margin: 0 0 10px; font-size: 21px; }
.empty-state p { margin: 0; color: var(--muted); line-height: 1.6; }
.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  width: min(100%, 760px);
  height: calc(72px + var(--safe-bottom));
  margin: 0 auto;
  padding: 7px 16px var(--safe-bottom);
  border-top: 1px solid rgba(23,50,77,.08);
  background: rgba(255,255,255,.94);
  grid-template-columns: 1fr 1fr;
  backdrop-filter: blur(18px);
}
.nav-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.nav-button.active { color: var(--navy); }
.nav-icon { display: block; margin-bottom: 3px; font-size: 20px; }
.history-hero {
  display: flex;
  padding: 24px;
  border-radius: 22px;
  background: var(--navy);
  color: white;
  flex-direction: column;
  align-items: center;
}
.history-hero p { margin: 0 0 6px; opacity: .75; font-size: 13px; }
.history-hero strong { font-size: 48px; line-height: 1.1; }
.history-hero span { margin-top: 4px; opacity: .75; font-size: 13px; }
.history-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0 20px;
}
.history-card {
  min-height: 86px;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
  text-align: center;
}
.history-card span { display: block; min-height: 32px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.history-card strong { font-size: 22px; }
.section-title { margin: 0 0 10px; font-size: 18px; }
.category-history {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
}
.category-row {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}
.category-row:last-child { border-bottom: 0; }
.category-row-head {
  display: flex;
  margin-bottom: 8px;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.category-row-head strong { min-width: 46px; text-align: right; }
.mini-progress {
  height: 6px;
  overflow: hidden;
  border-radius: 99px;
  background: #e7edf1;
}
.mini-progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--navy-2);
}
.category-row-detail { margin-top: 6px; color: var(--muted); font-size: 11px; }
.data-actions { display: grid; gap: 9px; margin-top: 16px; }
.secondary-button, .danger-button, .primary-button {
  min-height: 50px;
  border-radius: 14px;
  font-weight: 800;
}
.secondary-button { border: 1px solid var(--line); background: var(--paper); color: var(--navy); }
.danger-button { border: 1px solid #efd1d1; background: #fff5f5; color: var(--danger); }
.primary-button { width: 100%; border: 0; background: var(--navy); color: white; }
dialog {
  width: min(calc(100% - 24px), 620px);
  max-height: calc(100dvh - 36px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 22px;
  background: var(--paper);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0,0,0,.22);
}
dialog::backdrop { background: rgba(15,31,45,.5); backdrop-filter: blur(3px); }
.dialog-panel {
  display: flex;
  max-height: calc(100dvh - 36px);
  padding: 20px;
  flex-direction: column;
}
.dialog-panel.compact { max-height: none; }
.dialog-header { display: flex; margin-bottom: 12px; align-items: flex-start; justify-content: space-between; }
.dialog-header h2 { margin: 0; font-size: 22px; }
.dialog-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: var(--background);
  color: var(--muted);
  font-size: 24px;
}
.dialog-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.dialog-tools button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--navy);
  font-size: 13px;
  font-weight: 700;
}
.category-options {
  flex: 1;
  margin-bottom: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.category-option {
  display: grid;
  padding: 13px;
  border-bottom: 1px solid var(--line);
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.category-option:last-child { border-bottom: 0; }
.category-option input { width: 19px; height: 19px; accent-color: var(--navy-2); }
.category-option small { color: var(--muted); }
.install-steps { margin: 6px 0 22px; padding-left: 23px; line-height: 1.9; }
@media (min-width: 650px) {
  .flash-card { min-height: 360px; }
}
