* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  height: 100dvh;
  background: #1e1e1e;
  color: #d4d4d4;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) 14px calc(env(safe-area-inset-bottom) + 14px);
}
button, select { font-family: inherit; cursor: pointer; }
.wrap { max-width: 800px; width: 100%; flex: 1; display: flex; flex-direction: column; min-height: 0; }

.top { display: flex; align-items: center; gap: 10px; }
.deck {
  flex: 1; min-width: 0; appearance: none; -webkit-appearance: none;
  background: #252526; color: #d4d4d4; border: none; border-radius: 8px;
  padding: 10px 12px; font-size: 14px; font-weight: 500;
}
.icon {
  background: #252526; color: #aaa; border: none; border-radius: 8px;
  width: 40px; height: 40px; display: grid; place-items: center;
}

.progress { display: flex; height: 4px; border-radius: 2px; background: #2d2d2d; overflow: hidden; margin: 10px 0 0; }
.bar { height: 100%; transition: width .25s ease; }
.bar.known { background: #5f8a4a; }
.bar.miss { background: #a34d54; }
.mode { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: .5px; height: 0; overflow: visible; }
.mode:not(:empty) { height: auto; margin-top: 8px; }

.card {
  flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; margin-top: 12px;
  background: #252526; border-radius: 12px; padding: 24px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
  -webkit-overflow-scrolling: touch;
}
pre {
  margin: 0; padding: 0; background: transparent !important; white-space: pre;
  overflow-x: auto; scrollbar-width: none;
}
pre::-webkit-scrollbar { display: none; }
code {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', Menlo, Monaco, monospace;
  font-size: 14px; line-height: 1.6; background: transparent !important; padding: 0 !important;
}
.hljs { background: transparent !important; padding: 0 !important; }
.divider { height: 1px; background: #444; margin: 24px 0; display: none; }
.answer { display: none; }
.revealed .divider, .revealed .answer { display: block; }
.badge {
  display: none; background: #5a2f33; color: #e88; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; margin-bottom: 16px; text-transform: uppercase; letter-spacing: .5px;
}
.badge.on { display: inline-block; }
.badge.known { background: #3d6a5e; color: #98c379; }
.empty { display: none; color: #98c379; font-size: 18px; text-align: center; padding: 60px 10px; line-height: 1.5; }
.empty small { display: block; color: #888; font-size: 14px; margin-top: 8px; }

.controls { display: flex; gap: 12px; padding-top: 14px; }
.btn {
  flex: 1; padding: 16px 12px; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 500; color: #fff; transition: transform .1s, filter .1s;
}
.btn:active { transform: scale(.97); filter: brightness(1.15); }
.btn-reveal { background: #3d3d3d; color: #d4d4d4; }
.btn-again { background: #a34d54; }
.btn-good { background: #5f8a4a; }
.btn-nav { background: #2d2d2d; color: #999; flex: 0 0 52px; font-size: 20px; }
.grade { display: none; flex: 1; gap: 12px; }
.revealed-ctl .grade { display: flex; }
.revealed-ctl .btn-reveal { display: none; }
.status { text-align: center; margin-top: 12px; color: #555; font-size: 13px; }

.sheet-bg {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55);
  display: none; align-items: flex-end; justify-content: center; z-index: 10;
}
.sheet-bg.open { display: flex; }
.sheet {
  background: #252526; width: 100%; max-width: 800px; max-height: 88dvh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 20px 18px calc(env(safe-area-inset-bottom) + 20px);
}
.sheet h3 {
  font-size: 12px; color: #888; text-transform: uppercase; letter-spacing: .5px; margin: 18px 0 8px;
}
.sheet h3:first-child { margin-top: 0; }
.seg { display: flex; background: #1e1e1e; border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; background: none; border: none; color: #999; padding: 10px 4px;
  border-radius: 8px; font-size: 13px; font-weight: 500;
}
.seg button.on { background: #3d3d3d; color: #fff; }
.dstat { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 8px 0; font-size: 14px; }
.dstat .n { color: #888; font-size: 12px; font-variant-numeric: tabular-nums; }
.dstat .progress { grid-column: 1 / -1; margin: 0; height: 3px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid #333; font-size: 15px;
}
.row:last-of-type { border-bottom: none; }
.row button {
  background: #3d3d3d; color: #d4d4d4; border: none; border-radius: 8px;
  padding: 8px 16px; font-size: 14px; font-weight: 500;
}
.row button.danger { background: #5a2f33; color: #e88; }
.pair { display: flex; gap: 8px; }
.muted { display: block; color: #888; font-size: 13px; margin-top: 2px; }
.close {
  width: 100%; margin-top: 14px; padding: 14px; background: #3d3d3d; color: #d4d4d4;
  border: none; border-radius: 10px; font-size: 15px; font-weight: 500;
}

/* Phone in landscape: little vertical room, so tighten the chrome around the card. */
@media (orientation: landscape) and (max-height: 500px) {
  body {
    padding: 8px calc(env(safe-area-inset-right) + 12px) calc(env(safe-area-inset-bottom) + 4px)
      calc(env(safe-area-inset-left) + 12px);
  }
  .top { gap: 8px; }
  .deck { padding: 6px 10px; }
  .icon { width: 34px; height: 34px; }
  .progress { margin-top: 6px; }
  .card { margin-top: 8px; padding: 14px 18px; }
  .divider { margin: 14px 0; }
  .controls { padding-top: 8px; gap: 8px; }
  .btn { padding: 9px 12px; font-size: 14px; }
  .btn-nav { flex-basis: 44px; font-size: 18px; }
  .status { margin-top: 4px; font-size: 11px; }
}

@media (min-width: 700px) and (min-height: 501px) {
  body { padding: 40px; }
  .card { padding: 32px; }
  code { font-size: 15px; }
}
