:root {
  --bg: #1c222d;
  --bg-elevated: #232a36;
  --card: #2a3140;
  --card-soft: #323a4a;
  --ink: #f4f6fa;
  --muted: #8b93a7;
  --subtle: #6b7388;
  --line: rgba(255, 255, 255, 0.06);
  --blue: #4f8cff;
  --blue-soft: rgba(79, 140, 255, 0.18);
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, 0.16);
  --red: #ff5c7a;
  --red-soft: rgba(255, 92, 122, 0.14);
  --orange: #ff8a3d;
  --radius: 16px;
  --radius-sm: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-extra-top: 20px;
  --tabbar-h: 72px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
}

[hidden] {
  display: none !important;
}

.app {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding:
    calc(12px + var(--safe-top) + var(--header-extra-top))
    16px
    calc(16px + var(--safe-bottom) + var(--tabbar-h));
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.top-copy {
  display: grid;
  gap: 4px;
}

.brand {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.meta {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.35;
}

.stage {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 12px;
}

.status-card,
.panel,
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.status-card {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
  flex-shrink: 0;
}

.status-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 650;
}

.status-value {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2fbf5a, var(--green));
  transition: width 0.25s ease;
}

.status-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.card {
  padding: 22px 18px 18px;
  min-height: min(48dvh, 380px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  text-align: center;
  cursor: pointer;
  user-select: none;
}

.card.revealed {
  cursor: default;
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.card-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.card-prompt {
  margin: 0;
  font-size: clamp(1.8rem, 7vw, 2.4rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.card-tools {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.btn-exclude {
  font: inherit;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 8px;
}

.btn-skip-pack {
  font: inherit;
  border: 0;
  background: var(--card-soft);
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 11px 16px;
  border-radius: 12px;
  width: min(100%, 240px);
}

.btn-exclude:disabled,
.btn-skip-pack:disabled,
.btn:disabled,
.primary:disabled {
  opacity: 0.45;
  cursor: default;
}

.card-answer {
  margin: 0;
  font-size: clamp(1.2rem, 4.6vw, 1.55rem);
  font-weight: 650;
  color: var(--blue);
  animation: fade-up 0.2s ease;
}

.card-transcription,
.card-plural {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  animation: fade-up 0.2s ease;
}

.card-guide {
  margin: 0;
  color: var(--subtle);
  font-size: 0.82rem;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  animation: fade-up 0.18s ease;
}

.btn {
  font: inherit;
  border: 0;
  cursor: pointer;
  padding: 14px 12px;
  border-radius: 14px;
  font-weight: 650;
  font-size: 0.95rem;
}

.btn-forget {
  background: var(--red-soft);
  color: var(--red);
}

.btn-know {
  background: var(--green-soft);
  color: var(--green);
}

.primary {
  font: inherit;
  border: 0;
  cursor: pointer;
  padding: 14px 22px;
  border-radius: 14px;
  background: var(--blue);
  color: #fff;
  font-weight: 650;
  font-size: 1rem;
  min-width: 180px;
}

.primary:active {
  filter: brightness(0.95);
}

.empty {
  padding: 28px 18px;
  text-align: center;
}

.empty h1 {
  margin: 0 0 8px;
  font-size: 1.3rem;
  font-weight: 700;
}

.empty p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.section-label {
  margin: 2px 2px 8px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--subtle);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--bg-elevated);
}

.segment {
  font: inherit;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 11px;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
}

.segment.active {
  background: var(--card-soft);
  color: var(--ink);
}

.segment:disabled {
  opacity: 0.45;
  cursor: default;
}

.history-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.history-page,
.dict-page {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px;
}

.dict-page {
  grid-template-rows: auto 1fr auto;
}

.journal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
  min-height: 0;
}

.journal-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 2px;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: default;
}

.history-item {
  cursor: pointer;
  border-radius: 12px;
  margin: 0 -6px;
  padding-left: 8px;
  padding-right: 8px;
}

.history-item:active {
  background: rgba(79, 140, 255, 0.08);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 750;
  color: #fff;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.journal-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.journal-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.journal-sub {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.journal-sub.error {
  color: var(--red);
}

.journal-meta {
  display: grid;
  justify-items: end;
  gap: 4px;
  color: var(--subtle);
  font-size: 0.78rem;
}

.journal-mark {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
}

.journal-mark.ok {
  background: var(--green-soft);
  color: var(--green);
}

.journal-mark.bad {
  background: var(--red-soft);
  color: var(--red);
}

.history-item-learned .journal-title {
  color: var(--green);
}

.history-item-pending {
  opacity: 0.65;
}

.history-pack {
  margin: 8px 4px 0;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--subtle);
}

.dict-empty {
  margin: 18px 8px;
  color: var(--muted);
  text-align: center;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 480px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: rgba(28, 34, 45, 0.94);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  z-index: 30;
}

.tab {
  font: inherit;
  border: 0;
  background: transparent;
  color: var(--subtle);
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 14px;
  cursor: pointer;
}

.tab-icon {
  width: 42px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
}

.tab-label {
  font-size: 0.72rem;
  font-weight: 600;
}

.tab.active {
  color: var(--blue);
}

.tab.active .tab-icon {
  background: var(--blue-soft);
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

