:root { color-scheme: light; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: #253c36; background: #f4f6f1; }
* { box-sizing: border-box; }
body { margin: 0; }
button, .file-button, select, summary { min-height: 44px; }
button { touch-action: manipulation; }
summary { cursor: pointer; padding-block: 10px; overflow-wrap: anywhere; }
input:not([type="checkbox"]), textarea, select { font-size: 16px; }
h2, h3, p, label, .badge, .toolbar > * { overflow-wrap: anywhere; }
.deck, .study, .migration, .toolbar > *, .study-top > * { min-width: 0; }
header { display: flex; justify-content: space-between; align-items: center; padding: 24px 6vw; border-bottom: 1px solid #d9e2d8; }
header a { color: inherit; font-weight: 800; letter-spacing: .08em; text-decoration: none; }
header a span { font-size: .8rem; font-weight: 400; letter-spacing: 0; margin-left: 12px; }
.badge { font-size: .75rem; border: 1px solid #a1b8ab; border-radius: 30px; padding: 6px 12px; }
main { max-width: 1080px; margin: auto; padding: 42px 24px 72px; }
.eyebrow { font-size: .8rem; letter-spacing: .1em; color: #5b796a; }
h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 600; margin: 12px 0; }
.intro > p:last-child, .note, footer { color: #566c61; }
#status { min-height: 28px; padding: 12px 0; }
#status.error { color: #a02c36; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: #d9e2d8; border: 1px solid #d9e2d8; border-radius: 12px; overflow: hidden; margin-bottom: 24px; }
.stats > div { display: flex; flex-direction: column; padding: 24px; background: #fffdf8; gap: 8px; }
.stats strong { font-size: 2rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.stats span { font-size: .85rem; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
button, .file-button, select { font: inherit; padding: 11px 16px; border-radius: 8px; border: 1px solid #a5b8aa; background: #fffdf8; color: #253c36; }
button, .file-button { cursor: pointer; }
button:hover:not(:disabled), .file-button:has(input:enabled):hover { background: #e7eee3; }
button:disabled { cursor: default; opacity: .5; }
button.primary, #submit { background: #285746; color: white; border-color: #285746; }
button.primary:hover:not(:disabled), #submit:hover:not(:disabled) { background: #1e4235; }
.file-button { position: relative; }
.file-button input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.file-button:has(input:disabled) { opacity: .5; }
.file-button:focus-within, :focus-visible { outline: 3px solid #c38432; outline-offset: 3px; }
.note { font-size: .8rem; line-height: 1.8; margin: 16px 0 28px; }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 18px; }
.migration { border: 1px solid #d9e2d8; border-radius: 12px; padding: 24px; margin-bottom: 28px; background: #fffdf8; }
.migration h2 { font-size: 1.1rem; margin-top: 0; }
.migration .note { margin-bottom: 16px; }
.migration li { font-size: .85rem; line-height: 1.8; overflow-wrap: anywhere; }
.ack { display: block; margin: 18px 0; line-height: 1.8; }
.unresolved-rows { display: grid; gap: 12px; max-height: 540px; overflow: auto; margin: 14px 0; }
.unresolved-record { padding: 16px; border: 1px solid #d9e2d8; border-radius: 8px; min-width: 0; }
.unresolved-record p { margin: 6px 0; font-size: .85rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.unresolved-record .record-meta { color: #566c61; font-size: .75rem; }
.unresolved-record select { width: 100%; margin-top: 8px; }
.deck { background: #fffdf8; border: 1px solid #d9e2d8; border-radius: 12px; padding: 24px; }
.deck h2 { font-size: 1.2rem; margin: 0 0 16px; }
.deck p { font-size: .85rem; color: #566c61; }
.deck label { display: block; margin-top: 14px; font-size: .85rem; }
.deck select { display: block; width: 100%; margin: 6px 0 12px; }
.deck button { width: 100%; margin-top: 10px; }
.study { background: #fffdf8; border: 1px solid #d9e2d8; border-radius: 12px; padding: 32px; max-width: 800px; margin: auto; }
.study-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.study-top h2 { font-size: 1.1rem; }
.study-direction { font-size: .85rem; color: #566c61; margin: 4px 0 12px; }
#position { white-space: nowrap; }
.question { font-size: 2rem; line-height: 1.5; min-height: 70px; white-space: pre-wrap; overflow-wrap: anywhere; }
#answerHelp { margin: 0 0 12px; }
#answerForm label { display: block; margin-bottom: 12px; }
#answer { font: inherit; font-size: 1.5rem; padding: 12px; width: 100%; border: 1px solid #a5b8aa; border-radius: 8px; margin-bottom: 12px; }
#feedback { white-space: pre-wrap; min-height: 55px; line-height: 1.7; }
.choices { display: grid; gap: 10px; }
footer { padding: 24px; text-align: center; font-size: .75rem; border-top: 1px solid #d9e2d8; }
[hidden] { display: none !important; }
#cardBrowser { width: min(1000px, 94vw); max-height: 90vh; border: 1px solid #a5b8aa; border-radius: 12px; padding: 24px; color: #253c36; background: #fffdf8; }
#cardBrowser::backdrop { background: rgb(20 40 30 / 45%); }
.card-browser-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.card-browser-top h2 { font-size: 1.2rem; margin: 0; }
#cardSearch { display: block; width: 100%; margin: 8px 0 14px; padding: 10px; font: inherit; border: 1px solid #a5b8aa; border-radius: 8px; }
.card-table-wrap { overflow: auto; max-height: 52vh; }
.card-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.card-table th, .card-table td { text-align: left; vertical-align: top; border-bottom: 1px solid #d9e2d8; padding: 14px 10px; }
.card-table thead th { position: sticky; top: 0; background: #e7eee3; }
.card-table th:first-child { width: 64px; }
.card-face-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.card-language, .card-id { display: block; font-size: .7rem; color: #566c61; overflow-wrap: anywhere; }
.card-language { margin-bottom: 6px; }
.card-id { margin-top: 10px; }
.card-mobile-label, .review-mobile-label { display: none; }
.lab-replicas { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 20px; margin: 24px 0; }
.lab-device input, #failureMode { font: inherit; width: 100%; padding: 10px; border: 1px solid #a5b8aa; border-radius: 8px; margin-top: 8px; }
.lab-conflict { border: 1px solid #c38432; padding: 14px; border-radius: 8px; margin-top: 18px; }
.lab-conflict h3 { font-size: 1rem; }
.lab-log { line-height: 1.9; font-size: .85rem; }
#cardHistory, #cardEditor, #copyConfirmation { width: min(900px, 94vw); max-height: 90vh; overflow: auto; border: 1px solid #a5b8aa; border-radius: 12px; padding: 24px; color: #253c36; background: #fffdf8; }
#cardHistory::backdrop, #cardEditor::backdrop { background: rgb(20 40 30 / 45%); }
#editorForm label, #syncSettings label { display: block; margin-top: 14px; }
#editorForm input, #editorForm textarea, #remoteName { width: 100%; padding: 10px; font: inherit; border: 1px solid #a5b8aa; border-radius: 8px; margin: 8px 0; }
#editorForm textarea { min-height: 90px; resize: vertical; }
.card-table td:last-child button { display: block; margin: 8px 0; padding: 8px 10px; }
.card-table td:last-child { width: 150px; }
#historySummary, #historyRows { overflow-wrap: anywhere; }
#dropboxConfirmation { width: min(760px, 94vw); max-height: 90vh; border: 1px solid #a5b8aa; border-radius: 12px; padding: 24px; background: #fffdf8; }
#dropboxConfirmDetails { white-space: pre-wrap; overflow-wrap: anywhere; }
#dropboxSettings input, #syncTransport { width: 100%; font: inherit; padding: 10px; margin: 8px 0; border: 1px solid #a5b8aa; border-radius: 8px; }
#dropboxRedirect { overflow-wrap: anywhere; }
#status { white-space: pre-line; overflow-wrap: anywhere; }
#sharedImportConfirmation { width: min(800px, 94vw); max-height: 90vh; overflow: auto; padding: 24px; border: 1px solid #a5b8aa; border-radius: 12px; background: #fffdf8; }
#sharedImportDetails { white-space: pre-wrap; overflow-wrap: anywhere; }
#sharedArchiveRows p { overflow-wrap: anywhere; line-height: 1.7; }
.setup-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 16px; }
.setup-options article { padding: 16px; background: #f4f6f1; border: 1px solid #d9e2d8; border-radius: 8px; }
.setup-options h3 { margin-top: 0; font-size: 1rem; }
.setup-options p { line-height: 1.7; font-size: .85rem; }
#dataActions { margin-bottom: 24px; }
#decks:not(:empty) { margin-bottom: 28px; }
#connectionSettings { margin-bottom: 18px; }
#legacyTools[open] > section { margin-top: 20px; }
#verificationTools { margin-top: 28px; }
#verificationHandoff { width: min(800px, 94vw); max-height: 90vh; overflow: auto; padding: 24px; border: 1px solid #a5b8aa; border-radius: 12px; background: #fffdf8; color: #253c36; }
#verificationHandoff::backdrop { background: rgb(20 40 30 / 45%); }
#handoffDetails, #handoffStatus { white-space: pre-wrap; overflow-wrap: anywhere; }
#syncReview { width: min(1000px, 94vw); max-height: 90vh; overflow: auto; padding: 24px; border: 1px solid #a5b8aa; border-radius: 12px; background: #fffdf8; color: #253c36; }
#syncReview::backdrop { background: rgb(20 40 30 / 45%); }
.review-connection, .review-effective p, #syncReview [role="alert"] { white-space: pre-wrap; overflow-wrap: anywhere; }
.review-initial, .review-group { padding: 16px; margin: 16px 0; border: 1px solid #a5b8aa; border-radius: 8px; }
.review-initial { background: #eef4e9; }
.review-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 14px 0; }
.review-table th, .review-table td { border-bottom: 1px solid #d9e2d8; padding: 8px; text-align: left; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
.review-table th:first-child { width: 22%; }
.review-group li { overflow-wrap: anywhere; white-space: pre-wrap; }
#syncReview select { width: 100%; padding: 10px; margin-top: 10px; font: inherit; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin-block: 10px; }
.dialog-heading button { flex: 0 0 auto; }
.dialog-heading button, .card-browser-top button { white-space: nowrap; }
.card-browser-top form { flex: 0 0 auto; }
.ack { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; cursor: pointer; }
.ack input { width: 22px; height: 22px; margin: 3px 0 0; flex: 0 0 auto; accent-color: #285746; }
@media (max-width: 600px) { header { padding: 18px; } main { padding: 24px 16px 48px; } .stats > div { padding: 16px 10px; } .stats span { font-size: .7rem; } .study { padding: 20px; } .toolbar > * { flex: 1 1 auto; text-align: center; } }
@media (max-width: 600px) {
  header { gap: 12px; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); }
  header a span { display: block; margin-left: 0; margin-top: 3px; }
  main { padding: 20px max(12px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  footer { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .is-studying .intro { display: none; }
  .is-studying #status { margin: 0; padding: 4px 0 12px; font-size: .85rem; min-height: 0; }
  .is-studying main { padding-top: 12px; }
  .migration, .deck, .study { padding: 16px; }
  .deck-grid { grid-template-columns: minmax(0, 1fr); }
  .study-top { align-items: flex-start; }
  .study-top h2 { margin-top: 0; }
  .question { font-size: clamp(1.35rem, 6vw, 1.75rem); min-height: 42px; margin: 12px 0 18px; }
  #answer { font-size: 20px; min-height: 48px; }
  #submit { width: 100%; min-height: 48px; }
  #feedback { min-height: 0; font-size: .9rem; }
  .choices button { min-height: 48px; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }
  #study .toolbar button { min-height: 48px; }
  #next { flex-basis: 100%; background: #285746; color: white; }
  .stats strong { font-size: 1.6rem; }
  #dataActions > * { flex-basis: 100%; }
  dialog#cardBrowser, dialog#cardHistory, dialog#cardEditor, dialog#copyConfirmation, dialog#sharedImportConfirmation, dialog#verificationHandoff, dialog#syncReview {
    position: fixed; top: calc(var(--visual-top, 0px) + env(safe-area-inset-top, 0px) + 8px); bottom: auto;
    width: calc(100% - 16px); max-width: 600px; margin: 0 auto;
    max-height: calc(var(--visual-height, 100dvh) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px);
    padding: 16px; overflow: auto; overscroll-behavior: contain;
  }
  .dialog-heading, .card-browser-top { position: sticky; top: -16px; background: #fffdf8; z-index: 2; padding-block: 8px; }
  .dialog-heading h2, .card-browser-top h2 { font-size: 1.1rem; }
  #cardBrowser .note { margin-block: 8px 14px; }
  .card-table-wrap { max-height: none; overflow: visible; }
  .card-table, .card-table tbody { display: block; }
  .card-table thead { display: none; }
  .card-table tbody tr { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 8px; border: 1px solid #d9e2d8; border-radius: 8px; margin-bottom: 12px; padding: 12px; }
  .card-table tbody th:first-child { grid-column: 1; grid-row: 1 / 4; width: auto; padding: 0; border: 0; }
  .card-table tbody td, .card-table td:last-child { display: block; grid-column: 2; width: auto; padding: 0 0 8px; min-width: 0; }
  .card-table td:last-child { border-bottom: 0; }
  .card-table td:last-child button { display: inline-flex; align-items: center; margin: 8px 6px 0 0; }
  .card-mobile-label, .review-mobile-label { display: block; color: #566c61; font-size: .8rem; font-weight: 600; margin-bottom: 4px; }
  .review-group, .review-initial { padding: 12px; }
  .review-table, .review-table tbody, .review-table tr, .review-table th, .review-table td { display: block; width: 100%; }
  .review-table tr:first-child { display: none; }
  .review-table th:first-child { width: 100%; background: #eef4e9; }
  .review-table td { padding: 10px 8px; }
  .review-group details ul { padding-left: 20px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
