:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#app { width: 100%; height: 100%; position: relative; }
.screen { width: 100%; height: 100%; position: absolute; top: 0; left: 0; display: flex; flex-direction: column; }
.screen.hidden { display: none; }
.focusable { transition: all 0.15s ease; border: 2px solid transparent; cursor: pointer; outline: none; }
.focusable:focus { border-color: var(--focus-ring); box-shadow: 0 0 20px var(--focus-glow); }
.hidden { display: none !important; }

/* ---- app layout ---- */
.screen { padding: 18px; gap: 14px; }

.hdr { display: flex; align-items: baseline; justify-content: space-between; flex-shrink: 0; }
.hdr h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.hdr.sm h1 { font-size: 22px; }
.sub, .prog { font-size: 14px; color: var(--text-secondary); }

/* ---- home menu ---- */
.menu { display: flex; flex-direction: column; gap: 14px; justify-content: center; flex: 1; }
.menu-btn {
  width: 100%; min-height: 88px; background: var(--bg-secondary);
  border-radius: 16px; display: flex; flex-direction: column;
  align-items: flex-start; justify-content: center; padding: 0 22px; gap: 4px;
  color: var(--text-primary);
}
.mb-label { font-size: 21px; font-weight: 600; }
.mb-sub { font-size: 14px; color: var(--text-secondary); }
.menu-btn.accent .mb-sub { color: var(--accent); font-weight: 600; }

/* ---- study card ---- */
.card-face {
  flex: 1; background: var(--bg-secondary); border-radius: 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 26px; gap: 18px; text-align: center;
}
.card-face.revealed { border-top: 3px solid var(--accent-secondary); }
.cf-side { font-size: 13px; letter-spacing: 2px; color: var(--text-secondary); text-transform: uppercase; }
.cf-text { font-size: 32px; font-weight: 700; line-height: 1.25; word-break: break-word; }
.cf-hint { font-size: 13px; color: var(--text-muted); margin-top: 8px; }

.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; flex-shrink: 0; }
.rate-btn {
  min-height: 88px; background: var(--bg-tertiary); border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--text-primary);
}
.rb-label { font-size: 16px; font-weight: 600; }
.rb-int { font-size: 12px; color: var(--text-muted); }
.rate-btn.g0 .rb-label { color: var(--danger); }
.rate-btn.g1 .rb-label { color: var(--text-secondary); }
.rate-btn.g2 .rb-label { color: var(--accent); }
.rate-btn.g3 .rb-label { color: var(--accent-secondary); }

/* ---- add: fields + keyboard ---- */
.fields { display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.field-chip {
  background: var(--bg-secondary); border-radius: 12px; padding: 10px 16px;
  min-height: 58px; display: flex; flex-direction: column; align-items: flex-start;
  justify-content: center; gap: 3px; color: var(--text-primary);
}
.field-chip.active { background: var(--bg-tertiary); }
.fc-label { font-size: 12px; letter-spacing: 1.5px; color: var(--text-secondary); }
.field-chip.active .fc-label { color: var(--accent); }
.fc-text { font-size: 19px; font-weight: 500; min-height: 22px; word-break: break-word; }

.kb { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; flex: 1; align-content: start; }
.key {
  min-height: 48px; background: var(--bg-tertiary); border-radius: 10px;
  font-size: 19px; color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
}
.key-space { grid-column: span 4; font-size: 14px; color: var(--text-secondary); }
.key-fn { grid-column: span 2; color: var(--danger); font-size: 22px; }
.key-save { grid-column: span 6; min-height: 52px; font-size: 17px; font-weight: 600; color: var(--accent-secondary); background: var(--bg-secondary); }

/* ---- browse list ---- */
.list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: flex; align-items: center; gap: 12px; background: var(--bg-secondary);
  border-radius: 10px; padding: 12px 14px; min-height: 58px; color: var(--text-primary);
}
.lr-front { font-size: 17px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lr-back { font-size: 14px; color: var(--text-secondary); max-width: 40%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lr-due { font-size: 11px; font-weight: 700; color: var(--accent-secondary); border: 1px solid var(--accent-secondary); border-radius: 6px; padding: 2px 6px; }

/* ---- detail ---- */
.detail-card { background: var(--bg-secondary); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.dc-text { font-size: 22px; font-weight: 600; word-break: break-word; }
.dc-hr { border: none; border-top: 1px solid var(--bg-tertiary); margin: 10px 0; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.detail-meta span { font-size: 13px; color: var(--text-secondary); background: var(--bg-secondary); padding: 6px 10px; border-radius: 8px; }

/* ---- stats ---- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; flex: 1; align-content: center; }
.stat { background: var(--bg-secondary); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.st-num { font-size: 32px; font-weight: 700; }
.st-lbl { font-size: 13px; color: var(--text-secondary); }
.stat.accent .st-num { color: var(--accent); }
.stat.ok .st-num { color: var(--accent-secondary); }

/* ---- shared ---- */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; }
.empty-emoji { font-size: 48px; color: var(--accent-secondary); }
.empty-title { font-size: 22px; font-weight: 600; }
.empty-sub { font-size: 14px; color: var(--text-secondary); }
.footbar { display: flex; gap: 10px; margin-top: auto; flex-shrink: 0; }
.btn {
  flex: 1; min-height: 56px; border-radius: 12px; background: var(--bg-tertiary);
  color: var(--text-primary); font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; padding: 0 20px;
}
.btn.ghost { background: var(--bg-secondary); }
.btn.danger { color: var(--danger); }

.toast {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--bg-tertiary); color: var(--text-primary); font-size: 15px;
  padding: 12px 22px; border-radius: 12px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease; box-shadow: 0 4px 24px rgba(0,0,0,0.6); z-index: 10;
}
.toast.show { opacity: 1; }
