:root {
  --bg: #1a1f2e;
  --text: #f5f5f5;
  --muted: rgba(255,255,255,0.7);
  --accent: #ffd166;
  --panel: rgba(255,255,255,0.06);
  --panel-border: rgba(255,255,255,0.12);
  --btn-bg: rgba(255,255,255,0.12);
  --btn-bg-hover: rgba(255,255,255,0.22);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: linear-gradient(135deg, #1a1f2e 0%, #2c3e50 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}
/* Only `body` is the flex container. Applying `display: flex` to `html` AS WELL
   would make body the sole flex item and the `align-items: center` declaration
   on html would shrink body to its intrinsic content width on phones,
   leaving huge empty margins on both sides of the page. */
body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
}
/* Web only, non-phone: never collapse below settings-page width (560px content + 32px padding).
   Phones (≤480px) drop the min-width so the page fills the viewport instead of horizontally scrolling. */
@media (min-width: 481px) {
  html:not(.compact) body { min-width: 592px; }
}
header {
  text-align: center;
  margin-bottom: 24px;
  max-width: 560px;
  width: 100%;
  position: relative;
}
.back-arrow {
  position: absolute;
  top: 0;
  left: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.back-arrow:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.25);
  transform: translateX(-2px);
}
.back-arrow svg { width: 18px; height: 18px; }
@media (max-width: 480px) {
  .back-arrow { width: 34px; height: 34px; }
}
h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 6px;
}
.subtitle {
  color: var(--muted);
  font-size: 13px;
}
.panel {
  width: 100%;
  max-width: 560px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 18px;
}
.panel-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin: 0 0 14px;
  font-weight: 600;
}
.option {
  display: flex;
  /* Top-align so the radio/checkbox sits on the title row, not the visual
     center of (title + helper text) where it appears to float below. */
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease;
  border: 1px solid transparent;
  margin-bottom: 6px;
}
.option:hover { background: rgba(255,255,255,0.05); }
.option input[type="radio"],
.option input[type="checkbox"] {
  margin-right: 14px;
  /* Nudge the 18px control down to the title line's optical center
     (15px font ≈ 21px line box, so center sits ~2px below the top). */
  margin-top: 2px;
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.option-label {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.option-label .primary-text {
  font-size: 15px;
  font-weight: 500;
}
/* Each option is a flex row: the clickable <label> (radio + text) on the left,
   and a non-clickable icon badge in a right-aligned column. The badge sits
   OUTSIDE the label so clicking it doesn't toggle the radio. */
.option-row {
  display: flex;
  align-items: flex-start;
}
.option-row > .option {
  flex: 1;
  min-width: 0;
}
/* Align the badge vertically with the option's title line (label padding-top 12px
   + radio's 2px nudge → title optical center ≈ 23px; 26px badge centered there). */
.option-row > .setting-icon {
  margin-top: 10px;
  margin-left: 12px;
  top: 0;
}
/* Small circular badge — a miniature of the matching top-row header icon
   (app.css .header-icon) so users connect the setting to the on-card control. */
.setting-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  flex-shrink: 0;
  cursor: help;
  /* Suppress the mobile long-press text-selection / callout menu so a press-and-hold
     shows the help bubble (wired in settings.js) instead. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.setting-icon-recall { border-color: #ff8c42; }          /* orange — matches recall-mode-toggle */
.setting-icon-recall .recall-code {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1;
}
/* Speaker glyph sitting inline in a helper sentence (manual mode) — sized to the
   surrounding 12px text and nudged onto the baseline. */
.helper-text .inline-icon {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
}
.option-label .helper-text {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.preview-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: background 0.15s ease;
  margin-left: 8px;
}
.preview-btn:hover { background: rgba(255,255,255,0.18); }
.preview-btn:active { transform: scale(0.96); }
.nav {
  width: 100%;
  max-width: 560px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.nav a {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.nav a:hover { border-bottom-color: var(--accent); }
.back-arrow-icon { width: 16px; height: 16px; flex-shrink: 0; }
.save-status {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  transition: opacity 0.4s ease;
  opacity: 0;
}
.save-status.visible { opacity: 1; }

/* Native (Capacitor): respect safe-area insets so the header doesn't sit under
   the status bar / notch and the bottom controls clear the home indicator.
   Mirrors memory.css and app.css; falls back to the original 24px/16px padding
   on devices/browsers without insets. */
html.native body {
  padding: max(env(safe-area-inset-top), 24px)
           max(env(safe-area-inset-right), 16px)
           max(env(safe-area-inset-bottom), 24px)
           max(env(safe-area-inset-left), 16px);
}

/* Styled help bubble for the .setting-icon badges (shown by setupSettingTooltips
   in settings.js). Mirrors the flashcards page's .ui-tooltip (app.css): a light
   Semantic-UI-like bubble with an arrow pointing at the trigger. */
.ui-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  padding: 0.55em 0.8em;
  background: #fff;
  color: rgba(0,0,0,0.87);
  border: 1px solid #d4d4d5;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(34,36,38,0.12), 0 2px 10px rgba(34,36,38,0.15);
  font-size: 13px;
  line-height: 1.3;
  max-width: 16rem;
  white-space: normal;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}
.ui-tooltip.visible { opacity: 1; visibility: visible; }
.ui-tooltip::after {
  content: "";
  position: absolute;
  left: var(--arrow-x, 50%);
  margin-left: -5px;
  width: 9px;
  height: 9px;
  background: #fff;
  transform: rotate(45deg);
}
.ui-tooltip[data-placement="bottom"]::after {
  top: -5px;
  border-left: 1px solid #d4d4d5;
  border-top: 1px solid #d4d4d5;
}
.ui-tooltip[data-placement="top"]::after {
  bottom: -5px;
  border-right: 1px solid #d4d4d5;
  border-bottom: 1px solid #d4d4d5;
}

/* ---------- tablet (native shell only) ----------
   Same gate and scoping as the block at the end of app.css - see the long comment
   there for why `min-width: 700px` (above the widest iPhone portrait viewport at
   440pt, below the iPad mini's 744pt), why `min-height: 600px` (a width-only gate
   also matches an iPhone in landscape, 852-956px wide but at most 440px tall; the
   shortest iPad viewport in either orientation is 744px), and why `html.compact`
   (set only by the native shell and mobile-web phones - here in settings.js init() -
   so the desktop site at swedishflashcards.app, built from this same stylesheet, is
   untouched).

   Width only, matching custom_cards.css so the column doesn't jump when navigating
   between the two pages. No vertical centring, unlike app.css: the panels overflow
   every tablet viewport (this page scrolls on a 13" iPad in both orientations), so
   `safe center` would degrade to flex-start anyway. It is a cap, not a floor - these
   three elements are already width:100%, so on an iPad mini in portrait (744px wide,
   712px content box) they stay at 712px and nothing overflows horizontally. */
@media (min-width: 700px) and (min-height: 600px) {
  html.compact header,
  html.compact .panel,
  html.compact .nav {
    max-width: 720px;
  }
}
