:root {
    --ink: #102433;
    --muted: #637684;
    --blue-950: #07334f;
    --blue-900: #0a4166;
    --blue-800: #0e567f;
    --blue-700: #13709f;
    --blue-500: #5bb8ee;
    --blue-100: #dff3ff;
    --blue-50: #f2faff;
    --red: #e93451;
    --cream: #fffaf0;
    --paper: #ffffff;
    --line: #dce7ed;
    --yellow: #ffd970;
    --green: #2b9a70;
    --shadow: 0 18px 45px rgba(9, 62, 96, .13);
    --shadow-soft: 0 8px 22px rgba(9, 62, 96, .09);
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 15px;
    --shell: 1160px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 12% 8%, rgba(91,184,238,.14), transparent 28%),
        linear-gradient(180deg, #f8fcff 0, #fff 32%, #f7fbfd 100%);
    font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }

.shell { width: min(calc(100% - 36px), var(--shell)); margin-inline: auto; }
.sr-only {
    position: absolute !important; width: 1px !important; height: 1px !important;
    padding: 0 !important; margin: -1px !important; overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important;
}
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 1000; background: #fff; padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }

.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(248,252,255,.86);
    border-bottom: 1px solid rgba(14,86,127,.09);
    backdrop-filter: blur(14px);
}
.header-inner { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: inline-flex; align-items: center; gap: 12px; padding: 0; border: 0; background: transparent; cursor: pointer; text-align: left; }
.brand-mark { width: 45px; height: 45px; border-radius: 14px; display: grid; place-items: center; background: var(--blue-900); overflow: hidden; box-shadow: var(--shadow-soft); }
.brand-mark img { width: 175%; height: 175%; object-fit: contain; transform: scale(1.25); }
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { color: var(--blue-950); letter-spacing: .08em; font-size: .96rem; }
.brand-copy small { color: var(--muted); margin-top: 5px; font-size: .72rem; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.text-button, .icon-button, .back-button { border: 0; background: transparent; cursor: pointer; font-weight: 800; }
.text-button { color: var(--blue-800); padding: 10px 12px; }
.pill-link { text-decoration: none; background: var(--blue-900); color: white; border-radius: 999px; padding: 11px 17px; font-size: .86rem; font-weight: 800; box-shadow: var(--shadow-soft); }

.view { display: none; min-height: calc(100vh - 146px); }
.view.is-active { display: block; animation: viewIn .28s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero-wrap { position: relative; overflow: hidden; background: linear-gradient(135deg, var(--blue-950), var(--blue-800)); color: white; }
.hero-wrap::before,
.hero-wrap::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.15); border-radius: 999px; }
.hero-wrap::before { width: 420px; height: 420px; right: -145px; top: -220px; }
.hero-wrap::after { width: 190px; height: 190px; left: 44%; bottom: -130px; }
.hero-grid { position: relative; z-index: 1; min-height: 405px; display: grid; grid-template-columns: 1.45fr .55fr; gap: 70px; align-items: center; padding-block: 70px; }
.eyebrow, .section-kicker { display: block; color: var(--blue-500); font-weight: 900; font-size: .76rem; letter-spacing: .16em; text-transform: uppercase; }
.hero-copy h1 { margin: 12px 0 18px; font-size: clamp(2.65rem, 6vw, 5.4rem); line-height: .97; letter-spacing: -.055em; }
.hero-copy h1 em { color: var(--yellow); font-style: normal; }
.hero-copy p { max-width: 650px; color: rgba(255,255,255,.83); font-size: clamp(.98rem, 1.4vw, 1.12rem); line-height: 1.9; margin: 0; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 25px; }
.hero-badges span { border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.09); padding: 8px 12px; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.today-card { justify-self: end; width: min(100%, 280px); padding: 28px; border-radius: var(--radius-xl); background: rgba(255,255,255,.96); color: var(--ink); box-shadow: 0 26px 60px rgba(0,0,0,.19); transform: rotate(2deg); }
.today-label { display: block; color: var(--blue-700); font-weight: 900; letter-spacing: .11em; }
.today-card strong { display: inline-block; margin: 7px 6px 0 0; color: var(--blue-950); font-size: 4.1rem; line-height: 1; }
.today-card > span:not(.today-label) { font-weight: 900; }
.mini-progress { height: 8px; margin: 22px 0 12px; border-radius: 999px; background: var(--blue-100); overflow: hidden; }
.mini-progress span { display: block; width: 0; height: 100%; background: var(--red); border-radius: inherit; transition: width .3s ease; }
.today-card small { display: block; color: var(--muted); line-height: 1.6; }

.content-shell { padding-block: 42px 70px; }
.toolbar { display: flex; gap: 16px; justify-content: space-between; align-items: center; margin-bottom: 42px; }
.search-box { min-width: min(100%, 420px); display: flex; align-items: center; gap: 10px; background: white; border: 1px solid var(--line); border-radius: 999px; padding: 0 16px; box-shadow: var(--shadow-soft); }
.search-box svg { width: 20px; fill: none; stroke: var(--blue-800); stroke-width: 2; stroke-linecap: round; }
.search-box input { width: 100%; height: 48px; border: 0; outline: 0; background: transparent; color: var(--ink); }
.filter-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.filter-chip { border: 1px solid var(--line); background: white; border-radius: 999px; padding: 9px 14px; cursor: pointer; color: var(--muted); font-weight: 800; box-shadow: 0 3px 10px rgba(9,62,96,.04); }
.filter-chip.is-active { background: var(--blue-900); color: white; border-color: var(--blue-900); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.section-heading h2, .conversion-band h2 { margin: 6px 0 0; color: var(--blue-950); font-size: clamp(1.65rem, 3vw, 2.35rem); letter-spacing: -.035em; }
.result-count { color: var(--muted); font-weight: 800; font-size: .86rem; }
.deck-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.deck-card { position: relative; min-height: 285px; display: flex; flex-direction: column; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-soft); transition: transform .2s ease, box-shadow .2s ease; }
.deck-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
.deck-accent { height: 9px; background: var(--deck-accent, var(--blue-700)); }
.deck-body { display: flex; flex-direction: column; flex: 1; padding: 22px; }
.deck-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.level-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 9px; border-radius: 999px; background: var(--blue-100); color: var(--blue-900); font-size: .73rem; font-weight: 900; }
.deck-count { color: var(--muted); font-size: .8rem; font-weight: 800; }
.deck-card h3 { margin: 18px 0 9px; color: var(--blue-950); font-size: 1.36rem; line-height: 1.35; }
.deck-card p { flex: 1; margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.75; }
.deck-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.deck-tags span { background: var(--blue-50); color: var(--blue-800); padding: 5px 8px; border-radius: 7px; font-size: .7rem; font-weight: 800; }
.deck-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.deck-progress { flex: 1; }
.deck-progress small { display: block; color: var(--muted); margin-bottom: 6px; }
.deck-progress-bar { height: 6px; background: #edf3f6; overflow: hidden; border-radius: 999px; }
.deck-progress-bar span { display: block; height: 100%; width: 0; background: var(--deck-accent, var(--blue-700)); border-radius: inherit; }
.study-button { flex: 0 0 auto; border: 0; border-radius: 999px; padding: 10px 15px; background: var(--blue-900); color: white; cursor: pointer; font-weight: 900; }
.empty-state { padding: 40px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius-lg); background: white; }

.conversion-band { margin-top: 55px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 28px; padding: 32px 35px; border-radius: var(--radius-xl); background: var(--cream); border: 1px solid #f0e4c9; box-shadow: var(--shadow-soft); }
.conversion-band p { margin: 10px 0 0; color: var(--muted); }
.conversion-band a { background: var(--red); color: white; text-decoration: none; font-weight: 900; border-radius: 999px; padding: 14px 20px; white-space: nowrap; }

.study-shell { max-width: 850px; padding-block: 30px 65px; }
.study-topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; }
.back-button { justify-self: start; color: var(--blue-800); padding: 8px 0; }
.study-title-wrap { min-width: 0; text-align: center; }
.study-title-wrap h1 { margin: 6px 0 0; color: var(--blue-950); font-size: clamp(1.1rem, 3vw, 1.55rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-button { justify-self: end; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: white; box-shadow: var(--shadow-soft); }
.study-progress-wrap { margin: 26px 0 22px; }
.study-progress-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; font-weight: 900; }
.study-progress { height: 9px; margin-top: 9px; background: #e7f0f4; border-radius: 999px; overflow: hidden; }
.study-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue-700), var(--blue-500)); transition: width .25s ease; }

.study-stage { perspective: 1600px; }
.flashcard { position: relative; min-height: 485px; outline: none; cursor: pointer; }
.flashcard:focus-visible { outline: 4px solid rgba(91,184,238,.38); outline-offset: 8px; border-radius: var(--radius-xl); }
.card-inner { position: relative; width: 100%; min-height: inherit; transform-style: preserve-3d; transition: transform .56s cubic-bezier(.2,.75,.2,1); }
.flashcard.is-flipped .card-inner { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; display: flex; flex-direction: column; border-radius: var(--radius-xl); backface-visibility: hidden; overflow: hidden; box-shadow: var(--shadow); border: 1px solid rgba(14,86,127,.14); }
.card-front { background: linear-gradient(145deg, #fff, #f5fbff); }
.card-back { background: linear-gradient(145deg, var(--blue-950), var(--blue-800)); color: white; transform: rotateY(180deg); }
.card-topline { display: flex; justify-content: space-between; align-items: center; padding: 22px 25px 0; color: var(--muted); font-size: .76rem; font-weight: 900; }
.card-back .card-topline { color: rgba(255,255,255,.7); }
.round-action { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: white; cursor: pointer; box-shadow: var(--shadow-soft); }
.card-back .round-action { background: rgba(255,255,255,.12); color: white; border-color: rgba(255,255,255,.2); }
.card-center { flex: 1; display: grid; align-content: center; justify-items: center; text-align: center; padding: 30px; }
.card-prompt, .answer-label { color: var(--blue-700); font-family: Georgia, serif; font-style: italic; font-weight: 700; }
.card-center h2, .card-answer h2 { margin: 12px 0; letter-spacing: -.04em; }
.card-center h2 { color: var(--blue-950); font-size: clamp(2.65rem, 8vw, 5.5rem); line-height: 1.05; }
.card-hint { color: var(--muted); margin: 4px 0 0; }
.flip-hint { padding: 17px; text-align: center; background: rgba(14,86,127,.05); color: var(--muted); font-size: .78rem; font-weight: 800; }
.card-back .flip-hint { color: rgba(255,255,255,.7); background: rgba(0,0,0,.08); }
.card-answer { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px 38px 28px; text-align: center; overflow-y: auto; }
.card-back .answer-label { color: var(--yellow); }
.card-answer h2 { font-size: clamp(1.9rem, 6vw, 3.6rem); }
.card-reading { margin: -3px 0 20px; color: rgba(255,255,255,.72); }
.example-box { width: min(100%, 620px); display: grid; gap: 7px; padding: 18px 20px; background: rgba(255,255,255,.11); border: 1px solid rgba(255,255,255,.17); border-radius: var(--radius-md); }
.example-box strong { font-size: 1.05rem; line-height: 1.6; }
.example-box span { color: rgba(255,255,255,.74); font-size: .88rem; }
.card-note { width: min(100%, 620px); color: rgba(255,255,255,.8); font-size: .82rem; line-height: 1.7; margin: 16px 0 0; }
.resource-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.resource-links a { display: inline-flex; align-items: center; gap: 6px; color: white; text-decoration: none; padding: 8px 11px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); border-radius: 999px; font-size: .75rem; font-weight: 900; }
.resource-links a:hover { background: rgba(255,255,255,.2); }

.reveal-area { display: grid; justify-items: center; gap: 8px; margin-top: 22px; }
.primary-button, .secondary-button, .danger-button { border-radius: 999px; padding: 13px 22px; cursor: pointer; font-weight: 900; }
.primary-button { border: 0; background: var(--blue-900); color: white; box-shadow: var(--shadow-soft); }
.secondary-button { border: 1px solid var(--line); background: white; color: var(--blue-900); }
.danger-button { border: 1px solid #f2bdc6; background: #fff3f5; color: #b71e37; }
.reveal-area small, .keyboard-help { color: var(--muted); }
.rating-area { margin-top: 21px; text-align: center; }
.rating-area > p { margin: 0 0 11px; color: var(--muted); font-weight: 800; }
.rating-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.rating { border: 1px solid var(--line); border-radius: var(--radius-md); background: white; min-height: 73px; display: grid; align-content: center; gap: 4px; cursor: pointer; box-shadow: 0 4px 12px rgba(9,62,96,.06); transition: transform .15s ease, border-color .15s ease; }
.rating:hover { transform: translateY(-2px); border-color: var(--blue-500); }
.rating strong { font-size: .86rem; }
.rating span { color: var(--muted); font-size: .7rem; }
.rating.again strong { color: #c62942; }
.rating.hard strong { color: #b06710; }
.rating.good strong { color: var(--blue-700); }
.rating.easy strong { color: var(--green); }
.keyboard-help { display: block; margin-top: 10px; font-size: .72rem; }

.complete-shell { max-width: 850px; padding-block: 55px 75px; }
.complete-card { background: white; border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow); padding: clamp(30px, 7vw, 65px); text-align: center; }
.complete-icon { width: 75px; height: 75px; display: grid; place-items: center; margin: 0 auto 20px; border-radius: 50%; background: #e2f7ef; color: var(--green); font-size: 2.3rem; font-weight: 900; }
.complete-card h1 { color: var(--blue-950); margin: 12px 0; font-size: clamp(2rem, 5vw, 3.4rem); }
.complete-card > p { color: var(--muted); line-height: 1.8; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 32px 0; }
.stats-grid div { padding: 18px; border-radius: var(--radius-md); background: var(--blue-50); }
.stats-grid strong { display: block; color: var(--blue-900); font-size: 1.9rem; }
.stats-grid span { color: var(--muted); font-size: .76rem; font-weight: 800; }
.complete-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.complete-resources { margin-top: 28px; display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; }
.complete-resources a { text-decoration: none; color: var(--blue-900); font-weight: 900; border-bottom: 2px solid var(--blue-100); padding-bottom: 2px; }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3,30,46,.58); backdrop-filter: blur(5px); }
.modal-panel { position: relative; width: min(100%, 540px); max-height: calc(100vh - 36px); overflow-y: auto; background: white; border-radius: var(--radius-xl); box-shadow: 0 30px 80px rgba(0,0,0,.3); padding: 32px; }
.modal-close { position: absolute; top: 18px; right: 18px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--blue-50); color: var(--blue-900); cursor: pointer; font-size: 1.4rem; }
.modal-panel h2 { margin: 7px 0 22px; color: var(--blue-950); }
.setting-row { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; padding: 16px 0; border-top: 1px solid var(--line); }
.setting-row span { display: grid; gap: 4px; }
.setting-row small { color: var(--muted); line-height: 1.45; }
.setting-row input { width: 22px; height: 22px; accent-color: var(--blue-800); }
.data-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.data-actions .secondary-button, .data-actions .danger-button { font-size: .78rem; padding: 10px 13px; }
.file-button { display: inline-flex; align-items: center; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.privacy-note { margin: 18px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.65; }

.site-footer { border-top: 1px solid var(--line); background: white; }
.footer-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 18px; color: var(--muted); font-size: .74rem; }
.footer-inner nav { display: flex; gap: 15px; }
.footer-inner a { text-decoration: none; font-weight: 800; color: var(--blue-800); }

@media (max-width: 900px) {
    .hero-grid { grid-template-columns: 1fr .6fr; gap: 30px; }
    .deck-grid { grid-template-columns: repeat(2, 1fr); }
    .toolbar { align-items: stretch; flex-direction: column; }
    .filter-chips { justify-content: flex-start; }
}
@media (max-width: 650px) {
    .shell { width: min(calc(100% - 24px), var(--shell)); }
    .header-inner { min-height: 64px; }
    .brand-copy small, .text-button { display: none; }
    .brand-mark { width: 40px; height: 40px; }
    .pill-link { padding: 9px 12px; font-size: .72rem; }
    .hero-grid { min-height: auto; grid-template-columns: 1fr; gap: 30px; padding-block: 50px; }
    .hero-copy h1 { font-size: clamp(2.45rem, 13vw, 4rem); }
    .today-card { justify-self: stretch; width: 100%; transform: none; display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; column-gap: 8px; padding: 22px; }
    .today-label, .mini-progress, .today-card small { grid-column: 1 / -1; }
    .today-card strong { font-size: 3rem; }
    .deck-grid { grid-template-columns: 1fr; }
    .conversion-band { grid-template-columns: 1fr; padding: 27px 23px; }
    .conversion-band a { text-align: center; }
    .study-shell { padding-top: 20px; }
    .study-topbar { grid-template-columns: auto 1fr auto; }
    .back-button { font-size: 0; }
    .back-button span { font-size: 1.4rem; }
    .flashcard { min-height: 455px; }
    .card-center { padding: 25px 18px; }
    .card-center h2 { font-size: clamp(2.4rem, 15vw, 4.4rem); }
    .card-answer { padding: 15px 20px 22px; }
    .rating-grid { grid-template-columns: repeat(2, 1fr); }
    .keyboard-help { display: none; }
    .stats-grid { gap: 7px; }
    .stats-grid div { padding: 15px 7px; }
    .stats-grid strong { font-size: 1.45rem; }
    .footer-inner { padding-block: 20px; flex-direction: column; justify-content: center; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
