/* Thẻ Học — giao diện theo bản thiết kế trong docs/mockups (Main.dc.html) */

/* ===== Token: sửa ở đây là đổi toàn app ===== */
:root {
  --bg: #F5F5FA; --sf: #FFFFFF; --sf2: #EEEEF7; --ln: rgba(20,20,43,.09);
  --ink: #14142B; --ink2: #5E5E7A; --new: #C9C9DA;
  --ac: #5B4FF0; --act: #4A3FD6; --acs: #ECEBFF;
  --grad: linear-gradient(135deg,#4F46E5,#7C4DF0 55%,#A245E6);
  --ok: #3DDC97; --oks: #DDF8EB; --okx: #0B7A53;
  --mid: #FFC53D; --mids: #FFF2CF; --midx: #8A5A00;
  --bad: #FF6B81; --bads: #FFE5E9; --badx: #C0263F;
  --pop: #D4F95F; --sky: #8FDBFF; --onf: #14142B;
  --sh: 0 1px 2px rgba(20,20,43,.04), 0 6px 20px rgba(20,20,43,.06);
  --sh2: 0 2px 6px rgba(20,20,43,.05), 0 28px 56px -16px rgba(70,56,200,.28);
  --font-ui: 'Be Vietnam Pro', 'Zen Maru Gothic', system-ui, sans-serif;
  --font-d: 'Bricolage Grotesque', 'Be Vietnam Pro', sans-serif;
  /* Chữ tiếng Nhật: Zen Maru Gothic theo thiết kế; các font hệ thống phía sau là dự phòng khi không tải được */
  --font-jp: 'Zen Maru Gothic', Osaka, "MS PGothic", "Hiragino Kaku Gothic Pro", Meiryo, 'Be Vietnam Pro', sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0C0C18; --sf: #16162A; --sf2: #22223C; --ln: rgba(255,255,255,.1);
  --ink: #F4F4FF; --ink2: #A9A9C6; --new: #4A4A6E;
  --ac: #6D5DF6; --act: #A9A2FF; --acs: #25224F;
  --oks: #10352A; --okx: #5BE3A9; --mids: #3A2E0C; --midx: #FFD166; --bads: #3D1620; --badx: #FF9BAA;
  --sh: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.28);
  --sh2: 0 28px 60px -16px rgba(109,93,246,.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box }
html, body { margin: 0 }
body { background: var(--bg); color: var(--ink); font: 500 15px/1.5 var(--font-ui); -webkit-text-size-adjust: 100% }
a { color: var(--act); text-decoration: none }
button, input, select, textarea { font: inherit; color: inherit }
button { cursor: pointer }
h1, h2, h3, p { margin: 0 }
h1, h2, h3 { overflow-wrap: anywhere }
[hidden] { display: none !important }
:focus-visible { outline: 3px solid var(--ac); outline-offset: 2px }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }
mark { background: var(--mid); color: var(--onf); padding: 0 6px; border-radius: 6px }
kbd { font: 700 11px/1 var(--font-ui); padding: 4px 7px; border-radius: 7px; background: color-mix(in srgb, currentColor 14%, transparent) }

.th { container-type: inline-size; position: relative; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg) }

/* ===== Chữ ===== */
.d { font-family: var(--font-d); font-weight: 800; letter-spacing: -.025em; line-height: 1.1 }
.jp { font-family: var(--font-jp); font-weight: 700 }
:lang(ja) { font-family: var(--font-jp) }
.lbl { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2) }
.mut { color: var(--ink2) }
.sm { font-size: 13px }
.pre, .txt { white-space: pre-wrap; overflow-wrap: anywhere }
.h-xl { font-size: clamp(32px, 6cqw, 52px) }
.h-lg { font-size: clamp(30px, 5cqw, 46px) }
.h-md { font-size: clamp(28px, 5cqw, 40px) }
.okx { color: var(--okx) } .badx { color: var(--badx) } .midx { color: var(--midx) }

/* ===== Bố cục ===== */
.row { display: flex; align-items: center; gap: 12px }
.col { display: flex; flex-direction: column; gap: 12px }
.wrap { flex-wrap: wrap }
.sp { flex: 1; min-width: 0 }
.between { justify-content: space-between }
.center { justify-content: center }
.end { justify-content: flex-end }
.start { align-items: flex-start }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)) }
.grid.fill { grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)) }
.grid.modes { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 12px }
.grid.opts { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 12px }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(min(150px, 30%), 1fr)); gap: 12px }
.page { width: 100%; max-width: 1080px; margin: 0 auto; padding: 32px 24px 72px; display: flex; flex-direction: column; gap: 28px; flex: 1 }
.page.nar { max-width: 720px; gap: 20px }
.page.mid { max-width: 920px }
.page.wide { max-width: 1000px }
.top { display: flex; align-items: center; gap: 8px 12px; padding: 10px 20px; background: color-mix(in srgb, var(--bg) 78%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-bottom: 1px solid var(--ln); position: sticky; top: 0; z-index: 5 }
.top.bottom { top: auto; bottom: 0; border-bottom: 0; border-top: 1px solid var(--ln); justify-content: flex-end }
.brand { gap: 10px; font-size: 21px; min-height: 48px; color: var(--ink) }
.brand svg { width: 38px; height: 38px }
.loading { text-align: center; padding: 48px 16px; color: var(--ink2) }

/* ===== Thành phần ===== */
.card { background: var(--sf); border: 1px solid var(--ln); border-radius: 24px; box-shadow: var(--sh); padding: 20px; text-align: left; color: var(--ink) }
a.card, button.card { transition: transform .2s cubic-bezier(.3,1.4,.5,1), box-shadow .2s }
a.card:hover, button.card:hover { transform: translateY(-4px); box-shadow: var(--sh2) }
a.card:active, button.card:active { transform: scale(.98) }
.card.hero { border-radius: 36px; box-shadow: var(--sh2) }
.card.flat { padding: 0; overflow: hidden }
.card.grad { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--sh2) }
.card.soft { background: var(--acs); border-color: transparent; box-shadow: none }
.card.due { background: var(--mids); border-color: transparent; box-shadow: none }
.card.done { align-items: center; text-align: center; padding: 48px 24px; gap: 16px; border-radius: 36px; box-shadow: var(--sh2); animation: pop .35s }
.card.empty { align-items: center; text-align: center; padding: 40px 24px; border: 1.5px dashed var(--new); box-shadow: none; background: transparent; grid-column: 1 / -1 }

.btn { min-height: 48px; padding: 0 20px; border: 1px solid var(--ln); border-radius: 99px; background: var(--sf); color: var(--ink); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: var(--sh); transition: transform .15s cubic-bezier(.3,1.4,.5,1), box-shadow .15s, filter .15s; white-space: nowrap }
.btn:hover { transform: translateY(-1px); filter: brightness(1.04) }
.btn:active { transform: scale(.96) }
.btn:disabled { opacity: .5; cursor: default; transform: none }
.btn.p { background: var(--ac); color: #fff; border-color: transparent; box-shadow: 0 10px 24px -8px var(--ac) }
.btn.ok { background: var(--ok); color: var(--onf); border-color: transparent; box-shadow: 0 10px 24px -10px var(--ok) }
.btn.mid { background: var(--mid); color: var(--onf); border-color: transparent; box-shadow: 0 10px 24px -10px var(--mid) }
.btn.bad { background: var(--bads); color: var(--badx); border-color: transparent; box-shadow: none }
.btn.pop { background: var(--ink); color: var(--bg); border-color: transparent }
.btn.g { border-color: transparent; box-shadow: none; background: transparent; color: var(--ink2) }
.btn.g:hover { background: var(--sf2); transform: none }
.btn.ic { width: 48px; padding: 0; flex: none }
.btn.ic.s { width: 40px }
.btn.big { min-height: 60px; font-size: 17px; font-weight: 700; flex: 1 }
.btn.dash { min-height: 64px; border: 1.5px dashed var(--new); border-radius: 24px; background: transparent; box-shadow: none; color: var(--act); width: 100% }
.nv { min-height: 44px; padding: 0 16px; border: 0; border-radius: 99px; background: transparent; font-weight: 600; color: var(--ink2); transition: background .15s; display: inline-flex; align-items: center; gap: 6px }
.nv.on { background: var(--acs); color: var(--act) }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--sf2); color: var(--ink); white-space: nowrap }
.chip.ok { background: var(--oks); color: var(--okx) }
.chip.mid { background: var(--mids); color: var(--midx) }
.chip.bad { background: var(--bads); color: var(--badx) }
.chip.pop { background: var(--acs); color: var(--act) }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block }
.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 99px; background: var(--sf2) }
.seg > * { min-height: 40px; padding: 0 14px; border: 0; border-radius: 99px; background: transparent; font-weight: 600; color: var(--ink2); display: inline-flex; align-items: center; gap: 6px; transition: background .15s; white-space: nowrap }
.seg > .on { background: var(--sf); color: var(--ink); box-shadow: var(--sh) }
.seg.inv { background: var(--sf) }
.seg.inv > .on { background: var(--ink); color: var(--bg) }
.sw { width: 52px; height: 30px; padding: 3px; border: 0; border-radius: 99px; background: var(--new); display: flex; flex: none; transition: background .2s }
.sw::after { content: ""; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .25s cubic-bezier(.3,1.5,.5,1) }
.sw.on { background: var(--ac) }
.sw.on::after { transform: translateX(22px) }
.sw:disabled { opacity: .45; cursor: default }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; font-weight: 600 }
.opt-row.sep { border-top: 1px solid var(--ln); margin-top: 6px; padding-top: 6px }
.opt-row input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--ac); flex: none }
.inp { min-height: 48px; padding: 0 16px; border: 1.5px solid transparent; border-radius: 16px; background: var(--sf2); width: 100%; transition: border-color .15s, background .15s }
.inp:focus { outline: 0; border-color: var(--ac); background: var(--sf); box-shadow: 0 0 0 4px var(--acs) }
.inp.on-soft { background: var(--sf) }
.inp.pill { border-radius: 99px; background: var(--sf) }
textarea.inp { padding: 12px 16px; line-height: 1.7; resize: vertical; display: block }
select.inp { padding-right: 8px }
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; flex: 1 1 220px }
.fld.rev { font-size: 12px; color: var(--ink2) }
.fld.rev > .inp { color: var(--ink) }
.search { flex: 1 1 200px; position: relative }
.search > svg { position: absolute; left: 16px; color: var(--ink2) }
.search > .inp { padding-left: 46px }
input[type=range] { accent-color: var(--ac); min-height: 44px; width: 100% }
.bar { display: flex; gap: 3px; height: 10px; border-radius: 99px; overflow: hidden; background: var(--sf2) }
.bar i { display: block; border-radius: 99px; transition: flex .5s, width .5s }
.line { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 20px; min-height: 60px; border-top: 1px solid var(--ln) }
.line:first-child { border-top: 0 }
.line.sm-line { min-height: 46px; padding: 6px 16px }
.line .t { flex: 1; font-size: 20px; font-weight: 700; min-width: 0 }
.line .dd { flex: 1.3; color: var(--ink2); min-width: 0 }
.menu-wrap { position: relative }
.menu { position: absolute; top: 56px; right: 0; z-index: 4; width: 236px; padding: 8px; display: flex; flex-direction: column; box-shadow: var(--sh2); animation: pop .18s }
.menu > * { min-height: 44px; padding: 0 12px; border: 0; border-radius: 12px; background: transparent; text-align: left; font-weight: 500; color: var(--ink); display: flex; align-items: center }
.menu > *:hover { background: var(--sf2) }
.menu > .danger { color: var(--badx); font-weight: 600 }
.stk { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 99px; font-weight: 700; color: var(--onf) }
.ico { width: 48px; height: 48px; border-radius: 16px; display: flex; align-items: center; justify-content: center; flex: none; color: var(--onf) }
.ico.lg { width: 72px; height: 72px; border-radius: 24px }
.ico.lg svg { width: 32px; height: 32px }
.bob { animation: bob 2.5s ease-in-out infinite }
.num-xl { font-size: 72px }

/* ===== Hộp thoại · toast ===== */
dialog.sheet { border: 1px solid var(--ln); background: var(--sf); color: var(--ink); width: calc(100% - 32px); max-width: 460px; max-height: 90vh; overflow: auto; padding: 0; border-radius: 28px; box-shadow: var(--sh2) }
dialog.sheet.wide { max-width: 560px }
dialog.sheet[open] { animation: pop .25s cubic-bezier(.3,1.4,.5,1) }
dialog.sheet::backdrop { background: rgba(12,12,24,.5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px) }
.sheet > header { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 4px 24px }
.sheet > header strong { font-size: 22px }
.sheet-body { padding: 8px 24px 24px; display: flex; flex-direction: column; gap: 10px }
.sheet-body form { display: flex; flex-direction: column; gap: 10px }
.check-list { max-height: 45vh; overflow: auto; display: flex; flex-direction: column }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 30; background: var(--ink); color: var(--bg); font-weight: 600; padding: 12px 20px; border-radius: 99px; display: flex; gap: 8px; align-items: center; box-shadow: var(--sh2); animation: toast-in .2s; max-width: calc(100vw - 32px) }

/* ===== Thẻ lật ===== */
.fc { position: relative; height: min(52vh, 440px); min-height: 280px; perspective: 1600px; touch-action: pan-y; user-select: none }
.fci { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .6s cubic-bezier(.3,1.3,.5,1) }
.fc.on .fci { transform: rotateY(180deg) }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 56px 24px 24px; text-align: center; border-radius: 36px; box-shadow: var(--sh2) }
.face.bk { transform: rotateY(180deg); background: var(--grad); color: #fff; border-color: transparent }
.face > .lbl { position: absolute; top: 22px; left: 24px }
.face.bk > .lbl { color: #fff }
.face .side-content { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; overflow: hidden }
.face .txt { font-weight: 900; line-height: 1.15; max-width: 100%; overflow-wrap: normal; font-size: 48px }
.face.bk .txt { font-family: var(--font-d); font-weight: 800 }
.face .txt:lang(ja) { font-family: var(--font-jp); font-weight: 900 }
.flip { position: absolute; inset: 0; border: 0; background: transparent; border-radius: 36px; z-index: 1 }
.fc-tools { position: absolute; top: 14px; right: 14px; z-index: 2; gap: 2px }
.fc.on .fc-tools .btn { color: #fff }
.card-img { max-height: 42%; max-width: 100%; border-radius: 16px; flex: none }
.star-on { color: var(--mid) !important }
.star-on svg { fill: var(--mid) }

/* ===== Câu hỏi / phản hồi ===== */
.q-term { font-size: clamp(40px, 14cqw, 96px); font-weight: 900; line-height: 1.15; text-align: center; padding: 8px 0 16px }
.q-term .side-content { display: flex; flex-direction: column; align-items: center; gap: 12px }
.q-term.long { font-size: clamp(22px, 5cqw, 36px); font-weight: 700 }
.q-term .card-img { max-height: 180px }
.q-small { font-size: clamp(24px, 6cqw, 40px); font-weight: 700 }
.q-small .side-content { display: flex; flex-direction: column; gap: 8px; align-items: flex-start }
.q-small .card-img { max-height: 120px }
.opt { min-height: 60px; padding: 8px 18px; border: 1.5px solid var(--ln); border-radius: 20px; background: var(--sf); font-weight: 600; font-size: 17px; display: flex; align-items: center; gap: 12px; text-align: left; box-shadow: var(--sh); transition: transform .15s, border-color .15s; cursor: pointer; overflow-wrap: anywhere }
.opt:hover { border-color: var(--ac); transform: translateY(-1px) }
.opt.ok { background: var(--oks); border-color: var(--okx); color: var(--okx); animation: pop .3s }
.opt.bad { background: var(--bads); border-color: var(--badx); color: var(--badx); animation: shake .35s }
.opt:disabled, .opt.locked { cursor: default; transform: none }
.opt > input { position: absolute; opacity: 0; pointer-events: none }
.opt:has(input:checked) { border-color: var(--ac); background: var(--acs); color: var(--act) }
.opt:has(input:focus-visible) { outline: 3px solid var(--ac); outline-offset: 2px }
/* After grading, right/wrong colours win over the "selected" colour */
label.opt.ok { background: var(--oks); border-color: var(--okx); color: var(--okx) }
label.opt.bad { background: var(--bads); border-color: var(--badx); color: var(--badx) }
.shown { padding: 20px; border-radius: 20px; background: var(--sf2); text-align: center; font-size: 28px; font-weight: 700; overflow-wrap: anywhere }
.shown.grad { background: var(--grad); color: #fff; animation: pop .25s }
.shown .side-content { display: flex; flex-direction: column; align-items: center; gap: 10px }
.fb { padding: 16px 18px; border-radius: 20px; font-weight: 500; animation: pop .25s; display: flex; flex-direction: column; gap: 2px }
.fb.ok { background: var(--oks); color: var(--okx) }
.fb.bad { background: var(--bads); color: var(--badx) }
.fb strong.d { font-size: 20px }
.tile { min-height: 96px; padding: 8px; border: 1.5px solid var(--ln); border-radius: 22px; background: var(--sf); font-weight: 600; font-size: 17px; box-shadow: var(--sh); transition: transform .2s cubic-bezier(.3,1.4,.5,1), opacity .25s, background .15s; overflow-wrap: anywhere }
.tile:hover { transform: translateY(-2px) }
.tile.sel { background: var(--ac); border-color: transparent; color: #fff; transform: scale(1.04); box-shadow: var(--sh2) }
.tile.miss { background: var(--bads); border-color: var(--badx); color: var(--badx); animation: shake .4s }
.tile.gone { opacity: 0; transform: scale(.6); pointer-events: none }
.tile img { max-height: 80px; max-width: 100%; border-radius: 10px }
.timer { font-size: 44px; font-variant-numeric: tabular-nums }
.timer small { font-size: 18px }
.score { font-size: 96px }
.score-xl { font-size: clamp(72px, 20cqw, 128px) }
.result { padding: 28px; gap: 20px; border-radius: 36px; animation: pop .35s; border-color: transparent }
.result.ok { background: var(--oks) } .result.ok .score { color: var(--okx) }
.result.mid { background: var(--mids) } .result.mid .score { color: var(--midx) }
.result.bad { background: var(--bads) } .result.bad .score { color: var(--badx) }
.tq.right { border-color: var(--okx) }
.tq.wrong { border-color: var(--badx) }
.match-item.right select { border-color: var(--okx) }
.match-item.wrong select { border-color: var(--badx) }

/* ===== Thanh điều hướng điện thoại ===== */
.tabbar { display: none; position: sticky; bottom: 12px; z-index: 5; margin: 0 16px 12px; padding: 6px; gap: 4px; border-radius: 99px; background: color-mix(in srgb, var(--sf) 88%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border: 1px solid var(--ln); box-shadow: var(--sh2) }
.tabbar > * { flex: 1; min-height: 48px; justify-content: center; font-size: 13px; padding: 0 8px }
.tabbar > .make { background: var(--ac); color: #fff }

/* ===== Trình soạn thẻ ===== */
.ed-row { padding: 12px 8px 12px 4px; gap: 8px; align-items: flex-start }
.ed-row.dragging { opacity: .7; transform: rotate(-1.5deg) translateX(10px); box-shadow: var(--sh2) }
.ed-row.drag-over { box-shadow: 0 -4px 0 var(--ac), var(--sh) }
.ed-grip { gap: 0; height: 48px }
.handle { width: 32px; height: 48px; border: 0; background: transparent; cursor: grab; color: var(--ink2); display: flex; align-items: center; justify-content: center }
.ed-num { width: 22px; text-align: center; color: var(--ink2); font-weight: 700 }
.ed-term { font-size: 19px; font-weight: 700 }
.ed-row textarea.inp { min-height: 48px; line-height: 1.5; padding: 11px 16px; resize: none; overflow: hidden }
.thumb { position: relative; height: 48px; flex: none }
.thumb img { height: 48px; max-width: 96px; border-radius: 14px; display: block; object-fit: cover }
.thumb button { position: absolute; top: -10px; right: -10px; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: var(--ink); color: var(--bg); font-weight: 700; line-height: 1 }
.fmt-b { font-weight: 800 } .fmt-i { font-style: italic } .fmt-u { text-decoration: underline }
.row-img { height: 44px; max-width: 72px; border-radius: 10px; object-fit: cover; flex: none }

/* ===== Tìm ảnh ===== */
.img-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px }
.img-results > .loading, .img-results > .mut { grid-column: 1 / -1; padding: 20px 8px; text-align: center }
.img-hit { padding: 0; height: 100px; overflow: hidden; border: 2px solid var(--ln); border-radius: 16px; background: var(--sf2); transition: transform .15s, border-color .15s }
.img-hit:hover { border-color: var(--ac); transform: translateY(-2px) }
.img-hit img { width: 100%; height: 100%; object-fit: cover; display: block }
.img-hit.picking { opacity: .5; border-color: var(--ac) }
.paste-box { padding: 12px 14px; border: 1.5px dashed var(--new); border-radius: 16px; color: var(--ink2); font-size: 13px }

/* ===== Biểu đồ · in ===== */
.spark { flex: 1; min-height: 96px; display: flex; align-items: flex-end; gap: 4px }
.spark i { flex: 1; min-height: 6px; border-radius: 99px; background: var(--acs) }
.spark i.today { background: var(--ac) }
.paper { background: #fff; color: #14142B; border-radius: 8px; padding: 40px; box-shadow: var(--sh2); gap: 16px }
.paper h1 { font-size: 24px; font-weight: 700 }
.p-head, .p-row { display: flex; gap: 12px; align-items: center; border-bottom: 1px solid #14142B; padding: 10px 0 }
.p-head { border-bottom-width: 2px; font-weight: 700; font-size: 13px; padding: 8px 0 }
.p-row > :nth-child(1), .p-head > :nth-child(1) { width: 32px; flex: none }
.p-row > :nth-child(2), .p-head > :nth-child(2) { flex: 1; min-width: 0 }
.p-row > :nth-child(3), .p-head > :nth-child(3) { flex: 1.4; min-width: 0 }
.p-row > :nth-child(2) { font-size: 18px; font-weight: 700 }
.p-row img, .p-cut img { max-height: 80px; display: block; margin-bottom: 4px }
.p-cuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)) }
.p-cut { border: 1.5px dashed #14142B; margin: -.75px; padding: 20px 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; break-inside: avoid }
.p-cut > :first-child { font-size: 28px; font-weight: 700 }

@keyframes pop { 0% { transform: scale(.92); opacity: 0 } 100% { transform: scale(1); opacity: 1 } }
@keyframes toast-in { 0% { transform: translateX(-50%) scale(.92); opacity: 0 } 100% { transform: translateX(-50%) scale(1); opacity: 1 } }
@keyframes shake { 20% { transform: translateX(-6px) } 40% { transform: translateX(6px) } 60% { transform: translateX(-4px) } 80% { transform: translateX(4px) } }
@keyframes bob { 50% { transform: translateY(-5px) } }

@container (max-width: 640px) {
  .hm { display: none !important }
  .page { padding: 20px 16px 40px; gap: 22px }
  .top { padding: 8px 12px }
  .tabbar { display: flex }
  .face, .flip { border-radius: 28px }
  .paper { padding: 20px }
  .num-xl { font-size: 56px }
  .line { padding-left: 14px }
  .line .t { font-size: 18px }
}
body[data-page="edit"] .tabbar, body[data-page="study"] .tabbar, body[data-page="bare"] .tabbar { display: none }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important }
}

@media print {
  .top, .tabbar, .no-print, .toast { display: none !important }
  body, .th { background: #fff }
  .page { max-width: none; padding: 0 }
  .paper { box-shadow: none; padding: 0; border-radius: 0 }
}
