:root {
  color-scheme: light;
  --bg: #fff9ec;
  --paper: #fffefa;
  --ink: #19364b;
  --muted: #61727a;
  --line: #e6dfd3;
  --line-strong: #c9bdad;
  --surface-muted: #f3f0e8;
  --surface-hover: #f5f0e6;
  --danger-soft: #fff0e8;
  --danger-line: #efc2b5;
  --danger-ink: #783d33;
  --placeholder: #89959a;
  --accent: #19364b;
  --accent-soft: #e8eff1;
  --primary: #19364b;
  --primary-hover: #102b3d;
  --primary-ink: #fff9ec;
  --brand-coral: #f25d45;
  --brand-tile: #fff9ec;
  --green: #356a53;
  --red: #a34437;
  --shadow: 0 14px 42px #19364b16;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--brand-coral); outline-offset: 3px; }
[hidden] { display: none !important; }
.topbar { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 26px; padding: 12px clamp(18px, 4vw, 60px); background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; flex: 0 0 auto; }
.brand-mark { width: 48px; height: 48px; display: block; flex: 0 0 auto; border-radius: 12px; background: var(--brand-tile); object-fit: contain; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: -.01em; }
.brand small { margin-top: 3px; font-size: 11px; color: var(--muted); }
.main-nav { display: flex; gap: 6px; align-items: center; }
.nav-button { border: 0; background: transparent; color: var(--muted); border-radius: 10px; padding: 11px 15px; font-size: 13px; }
.nav-button:hover { background: var(--bg); color: var(--ink); }
.nav-button.active { color: var(--accent); background: var(--accent-soft); }
.account-menu { display: flex; align-items: center; gap: 16px; font-size: 12px; }
.mobile-menu-account { display: none; }
.local-badge { color: var(--muted); white-space: nowrap; }
.local-badge i { width: 7px; height: 7px; display: inline-block; margin-right: 5px; border-radius: 50%; background: var(--green); }
.account-name { color: var(--ink); font-weight: 600; }
.quiet-button { padding: 8px 10px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; }
.quiet-button:hover { background: var(--bg); color: var(--ink); }
.page-content { width: min(1170px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 26px; }
.mobile-menu-toggle, .mobile-menu { display: none; }
.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 0 0 26px; }
.offline-banner { margin-bottom: 18px; padding: 11px 14px; border: 1px solid var(--danger-line); border-radius: 10px; background: var(--danger-soft); color: var(--danger-ink); font-size: 12px; }
.dictionary-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-intro h1 { margin: 0; font-size: clamp(25px, 3vw, 34px); font-weight: 620; letter-spacing: -.035em; }
.page-intro p { margin: 8px 0 0; max-width: 620px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.learn-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(255px, .8fr); gap: 22px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 17px; background: var(--paper); box-shadow: var(--shadow); }
.learn-panel { padding: clamp(16px, 3vw, 27px); }
.learn-controls { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.segments { display: inline-flex; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); }
.segments button { border: 0; border-radius: 8px; background: transparent; color: var(--muted); padding: 9px 12px; font-size: 12px; }
.segments button.active { background: var(--paper); color: var(--accent); box-shadow: 0 1px 4px #19364b14; }
.toggle-line { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.switch { position: relative; width: 36px; height: 21px; border: 0; border-radius: 99px; background: #c9cdcc; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: white; transition: transform .16s ease; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(15px); }
.area-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 19px; }
.area-label { margin-right: 3px; color: var(--muted); font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 99px; background: var(--paper); padding: 7px 11px; color: var(--muted); font-size: 12px; }
.chip.active { border-color: var(--line-strong); color: var(--accent); background: var(--accent-soft); }
.chip .mark { font-size: 13px; line-height: 1; }
.flash-card { position: relative; min-height: 330px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; padding: 20px 22px 18px; border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(147deg, var(--paper), #f8f2e7); text-align: center; touch-action: pan-y; user-select: none; cursor: pointer; transition: transform .16s ease, border-color .16s ease; }
.flash-card.is-swiping { transition: none; }
.flash-card.swiping-again { border-color: var(--red); box-shadow: inset 0 0 0 2px #f25d4533; }
.flash-card.swiping-known { border-color: var(--green); box-shadow: inset 0 0 0 2px #356a5333; }
.flash-card[data-swipe-direction="left"][data-swipe-step="1"] { transform: translateX(-20px) rotate(-1deg); }
.flash-card[data-swipe-direction="left"][data-swipe-step="2"] { transform: translateX(-40px) rotate(-2deg); }
.flash-card[data-swipe-direction="left"][data-swipe-step="3"] { transform: translateX(-60px) rotate(-3deg); }
.flash-card[data-swipe-direction="left"][data-swipe-step="4"] { transform: translateX(-80px) rotate(-4deg); }
.flash-card[data-swipe-direction="left"][data-swipe-step="5"] { transform: translateX(-100px) rotate(-5deg); }
.flash-card[data-swipe-direction="right"][data-swipe-step="1"] { transform: translateX(20px) rotate(1deg); }
.flash-card[data-swipe-direction="right"][data-swipe-step="2"] { transform: translateX(40px) rotate(2deg); }
.flash-card[data-swipe-direction="right"][data-swipe-step="3"] { transform: translateX(60px) rotate(3deg); }
.flash-card[data-swipe-direction="right"][data-swipe-step="4"] { transform: translateX(80px) rotate(4deg); }
.flash-card[data-swipe-direction="right"][data-swipe-step="5"] { transform: translateX(100px) rotate(5deg); }
.swipe-feedback { position: absolute; z-index: 1; top: 50%; left: 50%; padding: 9px 13px; border: 2px solid currentColor; border-radius: 9px; background: #fffefaed; font-size: 17px; font-weight: 750; letter-spacing: .03em; opacity: 0; pointer-events: none; transform: translate(-50%, -50%) rotate(-8deg); white-space: nowrap; }
.flash-card[data-swipe-step="1"] .swipe-feedback { opacity: .2; }
.flash-card[data-swipe-step="2"] .swipe-feedback { opacity: .4; }
.flash-card[data-swipe-step="3"] .swipe-feedback { opacity: .6; }
.flash-card[data-swipe-step="4"] .swipe-feedback { opacity: .8; }
.flash-card[data-swipe-step="5"] .swipe-feedback { opacity: 1; }
.flash-card.swiping-again .swipe-feedback { color: var(--red); }
.flash-card.swiping-known .swipe-feedback { color: var(--green); transform: translate(-50%, -50%) rotate(8deg); }
.flash-card:hover { border-color: var(--line-strong); }
.card-top, .card-bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; }
.card-label { display: inline-flex; align-items: center; gap: 7px; }
.card-status { color: var(--accent); background: var(--accent-soft); border-radius: 99px; padding: 5px 9px; }
.card-content { min-height: 205px; display: grid; align-content: center; justify-items: center; gap: 8px; }
.card-prompt { color: var(--ink); font-size: clamp(22px, 4vw, 31px); line-height: 1.35; }
.card-prompt.japanese { font-family: "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif; }
.card-roman { color: var(--muted); font-size: 15px; letter-spacing: .025em; }
.card-kana { color: var(--ink); font-size: clamp(42px, 7vw, 63px); font-weight: 450; line-height: 1.2; }
.card-kanji { color: var(--muted); font-size: clamp(22px, 4vw, 30px); }
.card-answer { color: var(--accent); font-size: clamp(24px, 4vw, 36px); font-weight: 560; }
.card-answer.small { font-size: 23px; }
.card-example { max-width: 430px; margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.rating-row { display: grid; grid-template-columns: 52px 1fr 1fr 52px; align-items: center; gap: 10px; margin-top: 18px; }
.undo-button, .rating-button, .speak-button { height: 47px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--muted); }
.undo-button:disabled, .rating-button:disabled { cursor: default; opacity: .43; }
.rating-button { display: flex; justify-content: center; gap: 8px; font-weight: 580; }
.rating-button.again { color: var(--red); }
.rating-button.known { color: var(--green); }
.speak-button { font-size: 17px; }
.rating-button:not(:disabled):hover, .undo-button:not(:disabled):hover { background: var(--surface-hover); border-color: var(--line-strong); }
.key-hint { margin-top: 13px; color: var(--muted); font-size: 11px; text-align: center; }
kbd { display: inline-block; margin: 0 2px; padding: 2px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--muted); font: inherit; }
.aside-panel { overflow: hidden; }
.aside-heading { padding: 19px 20px 16px; border-bottom: 1px solid var(--line); font-weight: 620; font-size: 14px; }
.aside-body { padding: 19px 20px; }
.stat-list { display: grid; gap: 14px; }
.stat-row { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.stat-row strong { color: var(--ink); font-size: 13px; }
.progress-bar { height: 7px; margin-top: 16px; overflow: hidden; border-radius: 99px; background: var(--surface-muted); }
.progress-bar svg { display: block; width: 100%; height: 7px; }
.progress-bar rect { fill: var(--brand-coral); }
.aside-divider { height: 1px; margin: 20px 0; background: var(--line); }
.starter-note { padding: 14px; border-radius: 12px; background: var(--surface-muted); color: var(--muted); font-size: 12px; line-height: 1.55; }
.starter-note strong { display: block; margin-bottom: 5px; color: var(--ink); }
.auth-submit { width: 100%; margin-top: 4px; }
.import-section-title, .local-data-title { margin: 0 0 8px; font-size: 17px; }
.import-section-description { font-size: 13px; line-height: 1.55; }
.import-result-note { margin-top: 16px; }
.import-review-panel { margin-top: 16px; }
.import-review-panel h2 { margin: 0; font-size: 18px; }
.import-review-panel > .muted { margin: 8px 0 14px; font-size: 13px; line-height: 1.5; }
.translation-status { margin: 18px 0; }
.backup-description { font-size: 13px; line-height: 1.6; }
.backup-restore-form { margin-top: 18px; }
.users-section-heading { margin-bottom: 16px; }
.account-management { margin-top: 24px; }
.users-section-title { margin: 0; font-size: 18px; }
.share-requests { margin-top: 18px; }
.share-requests h2 { margin: 0 0 12px; font-size: 18px; }
.share-request-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.share-request-row strong, .share-request-row small { display: block; }
.share-request-row small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.empty-state { min-height: 280px; display: grid; place-items: center; padding: 30px; text-align: center; }
.empty-state h2 { margin: 0 0 8px; font-size: 21px; font-weight: 610; }
.empty-state p { max-width: 440px; margin: 0 auto 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.primary, .secondary, .danger-button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 41px; border-radius: 10px; padding: 9px 15px; font-size: 13px; font-weight: 580; }
.primary { border: 1px solid var(--primary); background: var(--primary); color: var(--primary-ink); }
.primary:hover { background: var(--primary-hover); }
.secondary { border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.secondary:hover { background: var(--surface-hover); }
.danger-button { border: 1px solid var(--danger-line); background: var(--danger-soft); color: var(--danger-ink); }
.page-panel { padding: clamp(18px, 3vw, 28px); }
.kana-tabs { margin-bottom: 24px; }
.kana-group + .kana-group { margin-top: 28px; }
.kana-group h2 { margin: 0 0 12px; color: var(--muted); font-size: 13px; font-weight: 620; }
.kana-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; max-width: 640px; }
.kana-item { display: grid; justify-items: center; gap: 3px; padding: 12px 8px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); }
.kana-item strong { font-family: "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif; font-size: 27px; font-weight: 480; line-height: 1.2; }
.kana-item span { color: var(--muted); font-size: 11px; }
.search-row { display: flex; gap: 10px; margin-bottom: 18px; }
.field { width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--ink); }
.field::placeholder { color: var(--placeholder); }
.field-group { display: grid; gap: 7px; margin-bottom: 15px; }
.import-option { display: flex; align-items: start; gap: 8px; }
.import-option input { flex: 0 0 auto; margin-top: 3px; }
.field-group label { color: var(--muted); font-size: 12px; font-weight: 570; }
.field-help { color: var(--muted); font-size: 11px; line-height: 1.5; }
.word-list { display: grid; gap: 9px; }
.word-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(170px, 1.1fr) auto; align-items: center; gap: 16px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.word-jp { font-size: 22px; font-weight: 520; }
.word-jp small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.word-meaning { font-size: 14px; }
.word-meaning small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.word-actions { display: flex; gap: 7px; justify-content: flex-end; }
.role-tag { display: inline-block; border-radius: 99px; background: var(--accent-soft); padding: 4px 8px; color: var(--accent); font-size: 10px; }
.account-list { display: grid; gap: 8px; margin-top: 14px; }
.account-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.account-row strong { display: block; font-size: 13px; }
.account-row small { color: var(--muted); font-size: 11px; }
.account-row.inactive { opacity: .55; }
.split-content { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, .7fr); gap: 20px; align-items: start; }
.import-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.media-summary { margin-top: 15px; }
.media-review { display: grid; gap: 12px; margin-top: 18px; }
.media-review h3 { margin: 0; font-size: 15px; }
.media-review-row { display: grid; gap: 8px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); }
.media-review-row strong { font-size: 13px; }
.media-review-row small { color: var(--muted); font-size: 11px; }
.media-review-row .field-group { margin: 0; }
.import-grid textarea.field { min-height: 150px; resize: vertical; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.inline-form .wide { grid-column: 1 / -1; }
.muted { color: var(--muted); }
.footer-note { padding: 10px 24px 24px; color: var(--muted); font-size: 11px; text-align: center; }
.build-version { position: fixed; right: max(12px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); z-index: 5; padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--muted); font-size: 10px; line-height: 1.2; font-variant-numeric: tabular-nums; pointer-events: none; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.auth-card { width: min(440px, 100%); padding: clamp(24px, 5vw, 40px); border: 1px solid var(--line); border-radius: 19px; background: var(--paper); box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 29px; }
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand strong { font-size: 15px; letter-spacing: -.01em; }
.auth-brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.auth-card h1 { margin: 0; font-size: 25px; font-weight: 620; letter-spacing: -.03em; }
.auth-card > p { margin: 9px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.mfa-card { text-align: center; }
.mfa-qr { display: block; width: min(220px, 100%); margin: 16px auto 20px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.mfa-secret-group { text-align: left; }
.mfa-secret { display: block; overflow-wrap: anywhere; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink); font-size: 13px; letter-spacing: .08em; }
.recovery-code-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 18px 0 22px; padding: 0; list-style: none; text-align: center; }
.recovery-code-list code { display: block; padding: 9px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-variant-numeric: tabular-nums; }
.mfa-status button { margin-top: 10px; }
.notice { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: min(420px, calc(100% - 40px)); padding: 12px 16px; transform: translateY(20px); opacity: 0; pointer-events: none; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); box-shadow: var(--shadow); color: var(--ink); font-size: 13px; transition: opacity .16s ease, transform .16s ease; }
.notice.visible { transform: translateY(0); opacity: 1; }
.dialog { width: min(520px, calc(100% - 28px)); max-height: min(85vh, 720px); overflow: auto; padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px #20293630; }
.dialog::backdrop { background: #1c253488; backdrop-filter: blur(2px); }
.dialog-inner { padding: 23px; }
.dialog-title-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 19px; }
.dialog-title-row h2 { margin: 0; font-size: 20px; font-weight: 620; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.dialog-error { margin: 12px 0; color: var(--red); font-size: 12px; }
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #151d23;
    --paper: #202b33;
    --ink: #fff9ec;
    --muted: #b4c0c4;
    --line: #3c4a50;
    --line-strong: #53636a;
    --surface-muted: #26343b;
    --surface-hover: #303b42;
    --danger-soft: #332923;
    --danger-line: #7e5a45;
    --danger-ink: #f1c7a0;
    --placeholder: #8d9ba0;
    --accent: #f4b09f;
    --accent-soft: #3b2e2d;
    --primary: #f25d45;
    --primary-hover: #ff755d;
    --primary-ink: #0b2638;
    --brand-coral: #f25d45;
    --brand-tile: #fff9ec;
    --green: #8cc6a3;
    --red: #f08e7b;
    --shadow: 0 14px 42px #00000040;
  }
  .topbar, .flash-card, .word-row, .field, .chip, .undo-button, .rating-button, .speak-button, kbd,
  .secondary, .segments button.active, .notice, .media-review-row { background-color: var(--paper); }
  .topbar { border-bottom-color: var(--line); }
  .main-nav { border-top-color: var(--line); }
  .nav-button { color: var(--muted); }
  .nav-button:hover, .quiet-button:hover, .secondary:hover, .rating-button:not(:disabled):hover, .undo-button:not(:disabled):hover { background: var(--surface-hover); }
  .account-name, .card-prompt, .card-kana, .card-kanji { color: var(--ink); }
  .segments, .starter-note, .progress-bar { background-color: var(--surface-muted); }
  .segments { border-color: var(--line); }
  .segments button, .toggle-line, .field-group label, .card-top, .card-bottom, .stat-row, .field-help { color: var(--muted); }
  .chip { border-color: var(--line); color: var(--muted); }
  .chip.active { border-color: var(--line-strong); color: var(--accent); background: var(--accent-soft); }
  .flash-card { border-color: var(--line); background: linear-gradient(147deg, #26343b, var(--paper)); }
  .swipe-feedback { background: #1b252aee; }
  .card-status { color: var(--accent); background: var(--accent-soft); }
  .undo-button, .rating-button, .speak-button, kbd, .secondary { border-color: var(--line); color: var(--muted); }
  .rating-button.again { color: var(--red); }
  .rating-button.known { color: var(--green); }
  .starter-note { color: var(--muted); }
  .starter-note strong, .word-meaning, .word-jp { color: var(--ink); }
  .field { border-color: var(--line); color: var(--ink); }
  .mfa-qr { border-color: #fff; background: #fff; }
  .word-row, .account-row, .kana-item { border-color: var(--line); background: var(--paper); }
  .offline-banner { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger-ink); }
  .danger-button { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger-ink); }
  .dialog::backdrop { background: #080a0ecc; }
}
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px 18px; }
  .main-nav { order: 3; width: 100%; justify-content: center; border-top: 1px solid var(--line); padding-top: 8px; }
  .account-menu { margin-left: auto; }
  .page-intro { align-items: flex-start; flex-direction: column; }
  .learn-grid, .split-content, .import-grid { grid-template-columns: 1fr; }
  .aside-panel { display: grid; grid-template-columns: 1fr 1fr; }
  .aside-heading { grid-column: 1 / -1; }
  .aside-body + .aside-body { border-left: 1px solid var(--line); }
}
@media (max-width: 600px) {
  .topbar { position: sticky; top: 0; z-index: 20; flex-wrap: nowrap; gap: 8px; min-height: 54px; padding: max(6px, env(safe-area-inset-top)) 12px 6px; }
  .brand-mark { width: 48px; height: 48px; border-radius: 12px; }
  .brand small, .local-badge, .account-name { display: none; }
  .brand strong { font-size: 13px; }
  .main-nav { display: none; }
  .mobile-menu-toggle { flex: 0 0 auto; display: inline-grid; place-items: center; width: 44px; min-height: 44px; margin-left: auto; padding: 0; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); color: var(--ink); }
  .mobile-menu-toggle[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
  .account-menu { display: none; }
  .mobile-menu-account { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; padding: 9px 4px 2px 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
  .mobile-menu-account .quiet-button { min-height: 40px; padding: 8px 10px; color: var(--ink); font-size: 12px; }
  .mobile-menu:not([hidden]) { position: fixed; top: calc(env(safe-area-inset-top) + 63px); right: max(12px, env(safe-area-inset-right)); z-index: 40; display: grid; gap: 4px; width: min(250px, calc(100vw - 24px)); padding: 8px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); box-shadow: 0 16px 42px #20293626; }
  .mobile-menu .nav-button { width: 100%; min-height: 44px; padding: 12px; text-align: left; font-size: 13px; }
  .mobile-menu-toggle svg { flex: 0 0 auto; }
  .page-content { width: calc(100% - 24px); min-width: 0; padding-top: 22px; }
  .page-content > *, .split-content > *, .import-grid > *, .panel { min-width: 0; }
  .panel p, .starter-note, .field-help, .field-group, .account-row, .share-request-row { overflow-wrap: anywhere; }
  .page-intro { align-items: stretch; flex-direction: column; gap: 12px; margin-bottom: 18px; }
  .page-intro h1 { font-size: 26px; }
  .page-intro p { font-size: 12px; }
  .dictionary-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 8px; }
  .dictionary-actions button, .page-content .primary, .page-content .secondary, .page-content .danger-button { min-width: 0; white-space: normal; overflow-wrap: anywhere; line-height: 1.25; }
  .dictionary-actions button { width: 100%; min-height: 50px; padding: 9px 10px; }
  .page-panel, .panel, .split-content, .import-grid, .word-list, .kana-grid { min-width: 0; max-width: 100%; }
  .kana-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; max-width: 100%; }
  .kana-item { min-width: 0; min-height: 64px; padding: 9px 3px; }
  .kana-item strong { font-size: clamp(18px, 6vw, 26px); }
  .kana-item span { font-size: 10px; }
  .kana-placeholder { visibility: hidden; }
  .learn-controls { align-items: flex-start; flex-direction: column; }
  .segments { width: 100%; }
  .segments button { flex: 1; padding: 9px 6px; font-size: 10px; }
  .flash-card { min-height: 300px; padding: 17px 14px 15px; }
  .card-content { min-height: 182px; }
  .rating-row { grid-template-columns: 42px 1fr 1fr 42px; gap: 7px; }
  .undo-button, .rating-button, .speak-button { height: 44px; }
  .rating-button { gap: 5px; font-size: 12px; }
  .aside-panel { display: block; }
  .share-request-row { align-items: flex-start; flex-direction: column; }
  .aside-body + .aside-body { border-top: 1px solid var(--line); border-left: 0; }
  .word-row { grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 9px; }
  .word-jp, .word-meaning, .word-row > div { min-width: 0; overflow-wrap: anywhere; }
  .word-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; justify-content: initial; gap: 7px; }
  .word-actions button { min-width: 0; min-height: 44px; width: 100%; padding: 8px; white-space: normal; overflow-wrap: anywhere; line-height: 1.2; }
  .users-section-heading { align-items: stretch; flex-direction: column; }
  .users-section-heading > button { width: 100%; }
  .account-row { align-items: flex-start; flex-wrap: wrap; min-width: 0; }
  .account-row > div { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
  .account-row > button { flex: 0 1 auto; max-width: 100%; }
  .field { min-width: 0; max-width: 100%; }
  .field[type="file"] { display: block; min-height: 46px; padding: 6px; font-size: 12px; }
  .field[type="file"]::file-selector-button { min-height: 32px; margin-right: 8px; padding: 6px 10px; border: 0; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font: inherit; }
  .inline-form { grid-template-columns: 1fr; }
  .inline-form .wide { grid-column: auto; }
  #settings-form > .primary { width: 100%; }
  .build-version { display: none; }
  .footer-note { padding-bottom: 16px; }
}

.learn-options > summary { list-style: none; }
.learn-options > summary::-webkit-details-marker { display: none; }
.learn-control-top { display: flex; flex: 1; justify-content: space-between; align-items: center; gap: 16px; }
.study-meta, .learn-options-current, .learn-options-chevron, .mobile-swipe-hint, .mobile-study-stats { display: none; }
.undo-icon { display: block; width: 20px; height: 20px; }
.undo-button.is-pending { background: var(--accent-soft); color: var(--accent); }
.undo-button.is-pending .undo-icon { animation: undo-tap .36s ease-in-out; }
.flash-card.card-returning { animation: card-return .24s cubic-bezier(.2,.7,.2,1); }
@keyframes undo-tap { 50% { transform: rotate(-32deg) scale(.86); } }
@keyframes card-return { from { opacity: .58; transform: translate3d(-18px, 0, 0) rotate(-2deg) scale(.98); } to { opacity: 1; transform: none; } }
.card-stack { min-width: 0; }
.flash-card.is-swiping[data-swipe-step] { transform: translate3d(var(--swipe-x, 0px), 0, 0) rotate(var(--swipe-rotation, 0deg)); }
.flash-card.swipe-away-left[data-swipe-direction] { transition: transform .21s cubic-bezier(.2,.75,.25,1); transform: translate3d(-130vw, 0, 0) rotate(-14deg); }
.flash-card.swipe-away-right[data-swipe-direction] { transition: transform .21s cubic-bezier(.2,.75,.25,1); transform: translate3d(130vw, 0, 0) rotate(14deg); }

@media (max-width: 600px) {
  body.study-screen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    overscroll-behavior: none;
  }
  body.study-screen #app-view {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  body.study-screen .topbar {
    position: relative;
    z-index: 20;
    flex: 0 0 auto;
  }
  body.study-screen .page-content {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 6px 10px max(7px, env(safe-area-inset-bottom));
    overflow: hidden;
  }
  body.study-screen .offline-banner { flex: 0 0 auto; margin: 0 0 6px; padding: 7px 10px; font-size: 11px; }
  body.study-screen .page-intro, body.study-screen .footer-note, body.study-screen .build-version { display: none; }
  body.study-screen .learn-grid {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    align-items: stretch;
    gap: 0;
  }
  body.study-screen .learn-panel {
    display: flex;
    flex: 1 1 auto;
    align-self: stretch;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  body.study-screen .aside-panel { display: none; }
  body.study-screen .study-meta {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    min-height: 27px;
    padding: 0 3px 5px;
    color: var(--muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
  }
  body.study-screen .study-meta strong { color: var(--ink); font-size: 12px; }
  body.study-screen .learn-options { position: relative; z-index: 12; flex: 0 0 auto; margin-bottom: 5px; }
  body.study-screen .learn-options > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 37px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--paper);
    color: var(--ink);
    cursor: pointer;
    list-style: none;
  }
  body.study-screen .learn-options-title { flex: 0 0 auto; font-size: 11px; font-weight: 650; }
  body.study-screen .learn-options-current {
    display: block;
    flex: 1 1 auto;
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body.study-screen .learn-options-chevron { display: grid; flex: 0 0 18px; place-items: center; align-self: center; width: 18px; height: 18px; color: var(--muted); transition: transform .18s ease; }
  body.study-screen .learn-options[open] .learn-options-chevron { transform: rotate(180deg); }
  body.study-screen .learn-controls {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    display: grid;
    gap: 13px;
    width: min(calc(100vw - 20px), 420px);
    max-height: calc(100dvh - 125px);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--paper);
    box-shadow: 0 16px 42px #20293626;
  }
  body.study-screen .learn-control-top { display: grid; gap: 12px; }
  body.study-screen .segments { width: 100%; }
  body.study-screen .segments button { flex: 1; min-height: 40px; padding: 10px 6px; font-size: 11px; }
  body.study-screen .toggle-line { justify-content: space-between; padding: 0 2px; font-size: 13px; }
  body.study-screen .area-row { gap: 6px; margin: 0; }
  body.study-screen .area-label { width: 100%; margin: 0 0 2px; font-size: 11px; }
  body.study-screen .chip { min-height: 40px; padding: 8px 10px; font-size: 11px; }
  body.study-screen .mobile-study-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }
  body.study-screen .mobile-study-stats div { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
  body.study-screen .mobile-study-stats strong { color: var(--ink); font-variant-numeric: tabular-nums; }
  body.study-screen .card-stack {
    position: relative;
    display: flex;
    flex: 1 1 0;
    min-height: 0;
    padding: 5px 7px 7px;
    isolation: isolate;
  }
  body.study-screen .card-stack::before, body.study-screen .card-stack::after {
    position: absolute;
    right: 15px;
    left: 15px;
    z-index: -1;
    height: 18px;
    border: 1px solid var(--line);
    border-radius: 23px 23px 15px 15px;
    background: var(--paper);
    content: "";
  }
  body.study-screen .card-stack::before { bottom: 1px; opacity: .48; transform: translateY(8px) scale(.94); }
  body.study-screen .card-stack::after { bottom: 1px; opacity: .72; transform: translateY(4px) scale(.97); }
  body.study-screen .flash-card {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    padding: 18px 16px 16px;
    border-radius: 24px;
    box-shadow: 0 18px 38px #29354816;
    touch-action: pan-y;
    transition: transform .21s cubic-bezier(.2,.75,.25,1), border-color .16s ease, box-shadow .16s ease;
  }
  body.study-screen .flash-card.is-swiping { transition: none; }
  body.study-screen .flash-card.swipe-away-left { transition: transform .21s cubic-bezier(.2,.75,.25,1); transform: translate3d(-130vw, 0, 0) rotate(-14deg); }
  body.study-screen .flash-card.swipe-away-right { transition: transform .21s cubic-bezier(.2,.75,.25,1); transform: translate3d(130vw, 0, 0) rotate(14deg); }
  body.study-screen .card-top, body.study-screen .card-bottom { font-size: 11px; }
  body.study-screen .card-bottom { justify-content: center; min-height: 25px; color: var(--muted); }
  body.study-screen .card-bottom > span:last-child { display: none; }
  body.study-screen .card-content { flex: 1 1 auto; min-height: 0; width: 100%; align-content: center; overflow: hidden; padding: 8px 0; }
  body.study-screen .card-prompt { font-size: clamp(26px, 8vw, 38px); }
  body.study-screen .card-kana { font-size: clamp(60px, 18vw, 100px); }
  body.study-screen .card-kanji { font-size: clamp(26px, 7vw, 38px); }
  body.study-screen .card-answer { font-size: clamp(27px, 7vw, 40px); overflow-wrap: anywhere; }
  body.study-screen .card-roman { font-size: 14px; }
  body.study-screen .card-example {
    display: -webkit-box;
    overflow: hidden;
    font-size: 12px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }
  body.study-screen .swipe-feedback { padding: 10px 15px; border-radius: 11px; font-size: 16px; }
  body.study-screen .rating-row { display: flex; flex: 0 0 auto; justify-content: space-between; gap: 10px; margin: 3px 4px 0; }
  body.study-screen .rating-button { display: none; }
  body.study-screen .undo-button, body.study-screen .speak-button { width: 46px; height: 42px; border-radius: 13px; }
  body.study-screen .key-hint { flex: 0 0 auto; min-height: 22px; margin: 2px 0 0; color: var(--muted); font-size: 11px; }
  body.study-screen .desktop-key-hint { display: none; }
  body.study-screen .mobile-swipe-hint { display: inline; }
  body.study-screen .empty-state { flex: 1 1 auto; min-height: 0; padding: 16px; }
  body.study-screen .empty-state h2 { font-size: 20px; }
  body.study-screen .empty-state p { font-size: 12px; }
  body.study-screen .notice { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .flash-card.swipe-away-left, .flash-card.swipe-away-right { transition-duration: .01ms; }
  .undo-button.is-pending .undo-icon, .flash-card.card-returning { animation-duration: .01ms; }
}
