
:root { --ink: #f8f8ff; --muted: #a5a6c1; --purple: #db42ff; --blue: #29d9ff; }
* { box-sizing: border-box; }
html { background: #05050b; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at 15% 9%, #281033 0, transparent 28rem), radial-gradient(circle at 89% 12%, #062f42 0, transparent 30rem), #05050b; font-family: Arial, Helvetica, sans-serif; }
button { font: inherit; }
main { min-height: 100vh; overflow: hidden; }
.hero { position: relative; width: min(1240px, calc(100% - 32px)); margin: 24px auto 0; }
.hero img { position: relative; z-index: 1; display: block; width: 100%; border-radius: 18px; box-shadow: 0 22px 80px #000, 0 0 35px #9938ff22; }
.hero-glow { position: absolute; inset: 18% 10% -8%; filter: blur(90px); background: linear-gradient(90deg, #ff26eb44, #263eff33, #00e5ff44); }
.lesson-shell { position: relative; width: min(1040px, calc(100% - 32px)); margin: -1px auto 100px; padding-top: 68px; }
.lesson-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 40px; }
.eyebrow { color: #65ddff; font-size: 12px; font-weight: 800; letter-spacing: .24em; }
h1 { margin: 12px 0 10px; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(40px, 6vw, 72px); line-height: .98; letter-spacing: -.04em; }
.lead { max-width: 590px; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.8; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; padding: 7px; border: 1px solid #262637; border-radius: 18px; background: #0b0b13; }
.tabs button { display: flex; align-items: baseline; gap: 9px; min-height: 76px; padding: 0 28px; color: #6f7187; text-align: left; border: 1px solid transparent; border-radius: 13px; background: transparent; cursor: pointer; transition: .2s ease; font-family: Georgia, serif; font-size: 28px; }
.tabs button > span { font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.tabs button small { margin-left: auto; font-family: Arial, sans-serif; font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.tabs button.active { color: white; border-color: #9d48ff77; background: linear-gradient(110deg, #391352, #102e4e); box-shadow: 0 0 24px #a733ff1f; }
.tabs button.active > span { color: #ee65ff; }
.guide { display: flex; align-items: center; gap: 14px; margin: 22px 0 28px; padding: 14px 18px; color: #aeb1c9; border-left: 2px solid #b941ef; background: linear-gradient(90deg, #221126, transparent); font-size: 12px; }
.guide p { margin: 0; }
.guide strong { color: #f1e7ff; }
.guide-icon { color: #ec4fff; font-size: 18px; }
.sentence-list { display: grid; gap: 12px; }
.sentence-card { position: relative; display: grid; grid-template-columns: 50px 1fr; gap: 12px; min-height: 178px; padding: 27px 30px 23px 22px; border: 1px solid #222334; border-radius: 17px; background: linear-gradient(130deg, #11111c 40%, #0b0d17); transition: border-color .2s, transform .2s; overflow: hidden; }
.sentence-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 2px; opacity: 0; background: linear-gradient(#f52dee, #2ddfff); box-shadow: 0 0 15px #dd45ff; transition: opacity .2s; }
.sentence-card:hover { border-color: #393a52; transform: translateY(-1px); }
.sentence-card.is-revealed { border-color: #9437cf88; background: linear-gradient(130deg, #1d1026, #0a1420); }
.sentence-card.is-revealed::before { opacity: 1; }
.card-number { padding-top: 4px; color: #585a72; font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.sentence-main { min-width: 0; }
.sentence-text { width: 100%; margin: 0; padding: 0; color: #f7f5ff; text-align: left; border: 0; background: transparent; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(22px, 3vw, 30px); line-height: 1.35; }
.linking-enabled .sentence-text { cursor: pointer; }
.link-mark { color: #e854ff; font-weight: 900; text-shadow: 0 0 12px #ed43ff; animation: mark-in .28s ease both; }
@keyframes mark-in { from { opacity: 0; } to { opacity: 1; } }
.ipa { margin: 8px 0 18px; color: #8c8fa8; font-size: 13px; letter-spacing: .025em; }
.ipa span { margin-right: 10px; color: #43d9fa; font-size: 8px; font-weight: 900; letter-spacing: .15em; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.reveal-button, .translate-button { display: inline-flex; align-items: center; gap: 9px; height: 38px; padding: 0 15px; color: #c3c4d7; border: 1px solid #303144; border-radius: 999px; background: #161722; font-size: 11px; font-weight: 700; cursor: pointer; transition: .2s; }
.reveal-button:hover, .reveal-button[aria-pressed='true'] { color: white; border-color: #c642ec; background: #29102f; }
.reveal-button span { display: grid; place-items: center; width: 17px; height: 17px; color: #e058ff; border: 1px solid #d648ff; border-radius: 50%; font-size: 10px; }
.translation { margin: -4px 0 18px; padding: 12px 14px; color: #effaff; border-left: 2px solid #4bdcff; border-radius: 0 9px 9px 0; background: #12304499; font-size: 14px; line-height: 1.7; }
.translation span { display: block; margin-bottom: 3px; color: #64e5ff; font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.linking-note { margin: -4px 0 18px; padding: 12px 14px; color: #f7e9cc; border-left: 2px solid #eda84f; border-radius: 0 9px 9px 0; background: #3b281699; font-size: 12px; line-height: 1.7; }
.linking-note span { display: block; margin-bottom: 3px; color: #ffc76f; font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.translate-button:hover, .translate-button[aria-pressed='true'] { color: white; border-color: #49cdea; background: #102d38; }
.translate-button span { display: grid; place-items: center; width: 17px; height: 17px; color: #69e7ff; border: 1px solid #53d9f6; border-radius: 50%; font-size: 9px; }
.audio-player { margin-top: 14px; padding: 12px; border: 1px solid #34364b; border-radius: 13px; background: #0b0c16cc; color-scheme: dark; }
.audio-player audio { display: block; width: 100%; height: 40px; }
.speed-controls { display: grid; grid-template-columns: auto repeat(3, minmax(55px, 64px)); justify-content: end; align-items: center; gap: 6px; margin-top: 10px; }
.speed-label { margin-right: 4px; color: #777b98; font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.speed-controls button { width: 100%; height: 34px; padding: 0 7px; color: #aeb2ca; border: 1px solid #3e4158; border-radius: 9px; background: #181a28; font-size: 10px; font-weight: 800; cursor: pointer; }
.speed-controls button.active { color: #081118; border-color: #6be6ff; background: linear-gradient(135deg, #70e8ff, #b9f4ff); box-shadow: 0 0 14px #4bdfff33; }
.lesson-chip { position: absolute; top: 18px; right: 20px; color: #45465c; font-family: Georgia, serif; font-size: 12px; }
.back-to-top { position: fixed; z-index: 60; right: max(14px, calc((100vw - 480px) / 2 + 14px)); bottom: calc(max(10px, env(safe-area-inset-bottom)) + 80px); display: grid; place-items: center; width: 46px; height: 46px; padding: 0; color: #ffffff; border: 1px solid #ffffff2b; border-radius: 50%; background: linear-gradient(135deg, #8b2bb2, #156e9c); box-shadow: 0 9px 25px #000a, inset 0 1px #ffffff35; font-size: 24px; line-height: 1; cursor: pointer; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.back-to-top:hover { transform: translateY(-2px); }
.back-to-top:focus-visible { outline: 2px solid #75e7ff; outline-offset: 3px; }
footer { display: flex; justify-content: center; align-items: center; gap: 20px; margin-top: 62px; color: #54566e; }
footer span { color: #a441d5; font-size: 10px; }
footer p { font-family: Georgia, serif; font-size: 14px; font-style: italic; letter-spacing: .08em; }
.mobile-only { display: none; }
@media (max-width: 640px) {
  .hero { width: calc(100% - 20px); margin-top: 10px; }
  .hero img { border-radius: 10px; }
  .lesson-shell { width: calc(100% - 24px); padding-top: 42px; }
  .lesson-header { align-items: flex-start; margin-bottom: 28px; }
  h1 { font-size: 40px; }
  .lead { font-size: 13px; }
  .mobile-only { display: block; }
  .tabs button { min-height: 65px; padding: 0 15px; font-size: 23px; }
  .tabs button small { display: none; }
  .sentence-card { grid-template-columns: 34px 1fr; min-height: 0; padding: 22px 16px 20px 14px; }
  .sentence-text { padding-right: 12px; font-size: 21px; }
  .ipa { padding-right: 5px; font-size: 12px; line-height: 1.55; }
  .lesson-chip { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Smartphone-fixed edition */
html { background: #020205; }
body {
  min-width: 320px;
  background: #020205;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", Arial, sans-serif;
}
main {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: radial-gradient(circle at 18% 7%, #351241 0, transparent 23rem), radial-gradient(circle at 88% 13%, #073c50 0, transparent 25rem), #070710;
  box-shadow: 0 0 90px #000;
}
.hero { width: calc(100% - 20px); margin-top: 10px; }
.hero img { border-radius: 11px; box-shadow: 0 14px 45px #000, 0 0 26px #9d3aff33; }
.lesson-shell { width: calc(100% - 24px); margin-bottom: 0; padding: 42px 0 116px; }
.lesson-header { align-items: flex-start; gap: 14px; margin-bottom: 30px; }
.eyebrow { margin-top: 0; color: #7de8ff; font-size: 10px; letter-spacing: .18em; }
h1 { margin-top: 9px; color: #ffffff; font-size: 40px; line-height: 1.08; text-shadow: 0 2px 20px #a83aff22; }
.lead { color: #d4d5e5; font-size: 14px; line-height: 1.85; }
.mobile-only { display: block; }
.tabs {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  width: min(calc(100% - 20px), 460px);
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
  padding: 6px;
  gap: 6px;
  transform: translateX(-50%);
  border: 1px solid #ffffff20;
  border-radius: 22px;
  background: #10101be8;
  box-shadow: 0 18px 50px #000c, inset 0 1px #ffffff12;
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
}
.tabs button {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-width: 0;
  min-height: 60px;
  padding: 0 8px;
  gap: 2px;
  color: #979ab3;
  border-radius: 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .02em;
}
.tabs button .tab-label { color: #8d90a8; font-size: 8px; font-weight: 800; line-height: 1; letter-spacing: .18em; }
.tabs button strong { font-family: Georgia, "Times New Roman", serif; font-size: 21px; font-weight: 600; line-height: 1.05; }
.tabs button.active {
  color: #ffffff;
  border-color: #ffffff1a;
  background: linear-gradient(115deg, #7a26a8 0%, #284fa7 58%, #087e9e 100%);
  box-shadow: 0 7px 22px #682fb055, inset 0 1px #ffffff2b;
}
.tabs button.active .tab-label { color: #f4d9ff; }
.guide { margin: 19px 0 22px; padding: 13px 14px; color: #d4d5e4; border-left-color: #e35cff; font-size: 12px; line-height: 1.65; }
.guide strong { color: #ffffff; }
.sentence-list { gap: 11px; }
.sentence-card { grid-template-columns: 34px 1fr; min-height: 0; padding: 22px 16px 20px 14px; border-color: #393a51; background: linear-gradient(135deg, #171725, #0e1220); }
.sentence-card.is-revealed { border-color: #ca55f6aa; background: linear-gradient(135deg, #2b1433, #0d1c2a); }
.card-number { color: #aeb1cd; font-size: 11px; }
.sentence-text { padding-right: 12px; color: #ffffff; font-size: 22px; font-weight: 600; line-height: 1.48; letter-spacing: .005em; }
.ipa { padding-right: 5px; color: #c8e9ff; font-size: 13px; line-height: 1.65; }
.ipa span { color: #5fe6ff; font-size: 9px; }
.link-mark { color: #ff70ff; text-shadow: 0 0 13px #f34dff; }
.reveal-button, .translate-button { min-height: 42px; height: auto; padding: 0 14px; color: #f0f1ff; border-color: #55576f; background: #202131; font-size: 12px; }
.reveal-button span { color: #ff88ff; border-color: #ef71ff; }
.lesson-chip { display: none; }

/* Special story page */
.sp-theme { background: #120904; }
.sp-theme main {
  background: radial-gradient(circle at 18% 6%, #623014 0, transparent 22rem), radial-gradient(circle at 86% 17%, #4a180b 0, transparent 25rem), #170c07;
  box-shadow: 0 0 90px #000, inset 0 0 80px #8b3f0c12;
}
.sp-theme .hero img { box-shadow: 0 14px 48px #000, 0 0 30px #ff942b3d; }
.sp-theme .hero-glow { background: linear-gradient(90deg, #ff541d55, #ffb72e55, #6e9b2c33); }
.sp-theme .eyebrow { color: #ffc867; }
.sp-theme h1 { color: #fff4dc; text-shadow: 0 2px 22px #ff791f38; }
.sp-theme .lead { color: #eadbc8; }
.sp-theme .guide { color: #ead9c1; border-left-color: #ff9d43; background: linear-gradient(90deg, #432312, transparent); }
.sp-theme .guide-icon { color: #ffb550; }
.sp-theme .sentence-card { border-color: #5b3b29; background: linear-gradient(135deg, #25160f, #15100d); }
.sp-theme .sentence-card.is-revealed { border-color: #e3853a; background: linear-gradient(135deg, #3d2013, #1d1510); }
.sp-theme .sentence-card::before { background: linear-gradient(#ffcf53, #e54a25); box-shadow: 0 0 15px #ff772d; }
.sp-theme .card-number { color: #c6a98f; }
.sp-theme .link-mark { color: #ffb63e; text-shadow: 0 0 13px #ff792e; }
.sp-theme .ipa { color: #ffe0a9; }
.sp-theme .ipa span { color: #ffb94e; }
.sp-theme .reveal-button[aria-pressed='true'] { border-color: #ef9b4b; background: #422516; }
.sp-theme .reveal-button span { color: #ffbd5d; border-color: #eea14f; }
.sp-theme .translation { color: #f5f2dc; border-left-color: #83b95b; background: #26321d99; }
.sp-theme .translation span { color: #a7d67b; }
.sp-theme .translate-button[aria-pressed='true'] { border-color: #84b966; background: #22311d; }
.sp-theme .translate-button span { color: #a8da82; border-color: #88bd68; }
.sp-theme .audio-player { border-color: #664631; background: #130e0bcc; }
.sp-theme .speed-controls button.active { color: #231205; border-color: #ffc75f; background: linear-gradient(135deg, #ffd271, #ff9d3d); box-shadow: 0 0 14px #ff9d3d44; }
.sp-theme .back-to-top { background: linear-gradient(135deg, #bd4526, #d6952d); }
.sp-theme .tabs button.active { border-color: #ffd78626; background: linear-gradient(115deg, #a93922 0%, #cf7124 52%, #d79a2e 100%); box-shadow: 0 7px 22px #b84a2455, inset 0 1px #fff0c840; }
.sp-theme .tabs button.active .tab-label { color: #fff0cd; }

/* EPT page */
.ept-theme { color: #0b2146; background: #ece8df; }
.ept-theme main { background: radial-gradient(circle at 14% 7%, #e7c36f40 0, transparent 22rem), radial-gradient(circle at 88% 16%, #8ba5c43a 0, transparent 24rem), #f7f4ed; box-shadow: 0 0 70px #1a294b26; }
.ept-theme .hero img { border: 1px solid #d9a634; box-shadow: 0 14px 42px #1827462b, 0 0 24px #cf9c2936; }
.ept-theme .hero-glow { background: linear-gradient(90deg, #d69f2d40, #f7f2e830, #294b7d30); }
.ept-theme .eyebrow { color: #9a6909; }
.ept-theme .lead { color: #40516b; }
.ept-theme .guide { color: #263d60; border-left-color: #c38a17; background: linear-gradient(90deg, #ead9af, transparent); }
.ept-theme .guide strong { color: #0b2146; }
.ept-theme .guide-icon { color: #b67a09; }
.ept-theme .sentence-card { border-color: #d7ccb8; background: linear-gradient(135deg, #fffefa, #f4f0e7); box-shadow: 0 7px 22px #2337560b; }
.ept-theme .sentence-card.is-revealed { border-color: #c58c1d; background: linear-gradient(135deg, #fff9e9, #f4eee2); }
.ept-theme .sentence-card::before { background: linear-gradient(#d9a52e, #173b6c); box-shadow: 0 0 14px #bd871e66; }
.ept-theme .card-number { color: #8d7545; }
.ept-theme .sentence-text { color: #0a2148; }
.ept-theme .link-mark { color: #b17608; text-shadow: 0 0 10px #e0b44755; }
.ept-theme .ipa { color: #4b607d; }
.ept-theme .ipa span { color: #9f6a08; }
.ept-theme .translation { color: #19395f; border-left-color: #315c8e; background: #e8eef5; }
.ept-theme .translation span { color: #315c8e; }
.ept-theme .linking-note { color: #5e4615; border-left-color: #c58d1d; background: #f5ead0; }
.ept-theme .linking-note span { color: #9d6805; }
.ept-theme .reveal-button, .ept-theme .translate-button { color: #243c5f; border-color: #b8b4aa; background: #ffffff; }
.ept-theme .reveal-button[aria-pressed='true'] { color: #ffffff; border-color: #173a68; background: #173a68; }
.ept-theme .translate-button[aria-pressed='true'] { color: #ffffff; border-color: #85600e; background: #9c710f; }
.ept-theme .audio-player { border-color: #c2a660; background: #0b1e3c; color-scheme: dark; }
.ept-theme .speed-label { color: #d8c89f; }
.ept-theme .speed-controls button { color: #e8edf5; border-color: #52627d; background: #172c4d; }
.ept-theme .speed-controls button.active { color: #102344; border-color: #e2b84f; background: linear-gradient(135deg, #f7d77e, #d7a333); box-shadow: 0 0 14px #d9ad3f66; }
.ept-theme .tabs { border-color: #c7b783; background: #fffdf8e8; box-shadow: 0 18px 45px #1a294738, inset 0 1px #ffffff; }
.ept-theme .tabs button { color: #52617a; }
.ept-theme .tabs button .tab-label { color: #80765e; }
.ept-theme .tabs button.active { color: #ffffff; border-color: #d5a63e; background: linear-gradient(115deg, #0a2148 0%, #173d70 66%, #a87613 100%); box-shadow: 0 7px 22px #17345b55, inset 0 1px #fff5cc47; }
.ept-theme .tabs button.active .tab-label { color: #f3d98e; }
.ept-theme .back-to-top { color: #ffffff; border-color: #d6ac49; background: linear-gradient(135deg, #0b2853, #b17a10); }

@media (max-width: 360px) {
  .tabs {
    width: calc(100vw - 12px);
    padding: 4px;
    gap: 3px;
    border-radius: 18px;
  }
  .tabs button {
    min-width: 0;
    min-height: 56px;
    padding: 0 2px;
    gap: 1px;
    overflow: hidden;
    border-radius: 14px;
  }
  .tabs button .tab-label {
    max-width: 100%;
    font-size: 7px;
    letter-spacing: .08em;
    white-space: nowrap;
  }
  .tabs button strong {
    max-width: 100%;
    font-size: 18px;
    white-space: nowrap;
  }
  .back-to-top {
    right: 10px;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 69px);
    width: 42px;
    height: 42px;
  }
}
