:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-soft: #eef4f8;
  --text: #172033;
  --muted: #667085;
  --line: #d9dee8;
  --accent: #b42335;
  --accent-strong: #8f1d2d;
  --accent-2: #1463a5;
  --good: #16803c;
  --warn: #b54708;
  --shadow: 0 12px 32px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 16px 92px;
}

.screen {
  display: none;
}

.screen-active {
  display: block;
}

.topbar {
  padding: 10px 0 12px;
}

.topbar.compact {
  padding-bottom: 8px;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 1.25;
}

.eyebrow,
.section-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.hero-panel,
.settings-panel,
.memory-panel,
.question-item,
.stat-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 14px;
  align-items: center;
  min-height: 156px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.hero-panel h2 {
  margin: 6px 0;
  font-size: 22px;
  line-height: 1.22;
}

.hero-panel p {
  line-height: 1.55;
}

.ring-stat {
  aspect-ratio: 1;
  border: 8px solid #e6ecf2;
  border-top-color: var(--accent);
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-align: center;
}

.ring-stat strong,
.ring-stat span {
  display: block;
}

.ring-stat strong {
  font-size: 21px;
}

.ring-stat span {
  color: var(--muted);
  font-size: 12px;
}

.primary-action,
.secondary-action,
.danger-action,
.file-action,
.bottom-nav button,
.chip,
.small-action,
.icon-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.primary-action,
.secondary-action,
.danger-action,
.file-action {
  width: 100%;
  margin: 8px 0;
  padding: 0 14px;
}

.primary-action {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
}

.secondary-action,
.file-action {
  background: var(--panel);
  color: var(--text);
}

.danger-action {
  background: #fff5f5;
  color: var(--accent-strong);
  border-color: #f0c6cc;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stat-tile {
  min-height: 74px;
  padding: 10px;
}

.stat-tile strong {
  display: block;
  font-size: 20px;
}

.stat-tile span {
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
}

.chip {
  flex: 0 0 auto;
  padding: 0 14px;
  background: var(--panel);
  color: var(--text);
}

.chip-active {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: white;
}

.question-list {
  display: grid;
  gap: 10px;
}

.question-item {
  padding: 14px;
}

.question-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.question-item h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
}

.badge {
  flex: 0 0 auto;
  min-width: 34px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--accent-2);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.question-meta,
.question-points,
.empty-state {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.question-points {
  margin-bottom: 0;
}

.app-status {
  min-height: 20px;
  margin: 6px 0 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.question-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.small-action {
  background: var(--panel);
  color: var(--text);
  padding: 0 8px;
  font-size: 13px;
}

.memory-panel,
.settings-panel {
  padding: 14px;
}

.memory-card {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.memory-card:first-child {
  border-top: 0;
  padding-top: 0;
}

.memory-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.memory-card ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.keyword-mask {
  padding: 10px;
  background: var(--panel-soft);
  border-radius: 8px;
  line-height: 1.55;
}

.button-stack {
  display: grid;
  gap: 4px;
}

.file-action {
  display: grid;
  place-items: center;
}

#import-progress {
  display: none;
}

#export-box {
  width: 100%;
  min-height: 112px;
  margin-top: 10px;
  padding: 10px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.bottom-nav button {
  background: white;
  color: var(--text);
  font-size: 14px;
}

.bottom-nav .nav-active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

#training-dialog {
  width: min(440px, calc(100vw - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
}

#training-dialog::backdrop {
  background: rgba(23, 32, 51, 0.42);
}

.training-modal {
  margin: 0;
  padding: 14px;
}

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

.icon-button {
  width: 44px;
  background: var(--panel);
  color: var(--text);
  font-size: 22px;
}

.training-question {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

@media (min-width: 720px) {
  body {
    background: linear-gradient(90deg, #edf1f5, #f7f8fa);
  }
}
