:root {
  --navy: #002040;
  --navy-deep: #001428;
  --gold: #C89B3C;
  --gold-press: #B4882D;
  --ink: #1A1A1A;
  --muted: #5B6573;
  --line: #E3E7EC;
  --surface: #FFFFFF;
  --bg: #F3F5F8;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
a { color: inherit; }
svg { display: block; }
.wrap { max-width: 560px; margin: 0 auto; }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 5;
  background: var(--navy); color: #fff;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
}
.bar .wrap { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.bar h1 { font-size: 18px; font-weight: 600; margin: 0; letter-spacing: -0.01em; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  color: #fff; flex: none;
}
.icon-btn:active { background: rgba(255,255,255,0.12); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.brand .word { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }

/* ---------- home ---------- */
.home-head { background: var(--navy); color: #fff; padding: calc(var(--safe-top) + 22px) 16px 26px; }
.home-head .brand .word { font-size: 28px; }
.home-head p { margin: 10px 0 0; color: rgba(255,255,255,0.78); font-size: 15px; line-height: 1.45; }
.home-body { padding: 16px 16px calc(var(--safe-bottom) + 24px); display: grid; gap: 14px; }
.tile {
  position: relative; display: block; width: 100%; text-align: left;
  min-height: min(34vh, 260px); border-radius: var(--radius); overflow: hidden;
  background: var(--navy-deep) center / cover no-repeat; color: #fff;
  box-shadow: 0 1px 2px rgba(0,32,64,0.12);
}
.tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,20,40,0.05) 20%, rgba(0,20,40,0.88) 100%); }
.tile:active { transform: scale(0.99); }
.tile .tile-text { position: absolute; left: 18px; right: 70px; bottom: 16px; z-index: 1; }
.tile .tile-title { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; display: block; }
.tile .tile-sub { font-size: 14px; color: rgba(255,255,255,0.85); display: block; margin-top: 4px; }
.tile .go {
  position: absolute; right: 16px; bottom: 16px; z-index: 1;
  width: 44px; height: 44px; border-radius: 50%; background: var(--gold); color: var(--navy);
  display: grid; place-items: center;
}
.offline {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.offline .txt { flex: 1; font-size: 14px; line-height: 1.4; color: var(--muted); }
.offline .txt strong { color: var(--ink); font-weight: 600; display: block; }
.offline .meter { height: 4px; background: var(--line); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.offline .meter i { display: block; height: 100%; width: 0; background: var(--navy); transition: width 0.3s; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 16px; border-radius: 10px; font-weight: 600; font-size: 15px; white-space: nowrap;
}
.btn-line { border: 1px solid var(--navy); color: var(--navy); background: #fff; }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:active { background: var(--gold-press); }
.btn-ghost { border: 1px solid rgba(255,255,255,0.55); color: #fff; background: transparent; padding: 0 12px; }
.btn-ghost:active { background: rgba(255,255,255,0.12); }
a.btn { text-decoration: none; }
.spacer { flex: 1; }
.offline .ok { flex: none; width: 36px; height: 36px; border-radius: 50%; background: #E6F4EA; color: #1E7B34; display: grid; place-items: center; }
.foot { text-align: center; font-size: 13px; color: var(--muted); padding-top: 4px; }
.foot a { color: var(--navy); font-weight: 500; text-decoration: none; }

/* ---------- lists ---------- */
.list { padding: 14px 16px calc(var(--safe-bottom) + 24px); display: grid; gap: 12px; }
.group-title { font-size: 15px; font-weight: 600; color: var(--muted); margin: 8px 2px 0; }
.row {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; align-items: center; gap: 12px; padding: 10px; min-height: 88px;
}
.row .open { flex: 1; display: flex; align-items: center; gap: 12px; text-align: left; min-width: 0; }
.thumb {
  position: relative; flex: none; width: 112px; height: 63px; border-radius: 8px; overflow: hidden;
  background: var(--navy) center / cover no-repeat;
}
.thumb.portrait { width: 52px; height: 72px; }
.thumb .play {
  position: absolute; inset: 0; margin: auto; width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.92); color: var(--navy); display: grid; place-items: center;
}
.row .meta { min-width: 0; }
.row .t { font-size: 16px; font-weight: 600; display: block; letter-spacing: -0.01em; }
.row .s { font-size: 13.5px; color: var(--muted); display: block; margin-top: 3px; }
.share-btn {
  flex: none; height: 44px; min-width: 44px; padding: 0 12px; border-radius: 10px;
  background: var(--gold); color: var(--navy); font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.share-btn:active { background: var(--gold-press); }
@media (max-width: 380px) {
  .share-btn .lbl { display: none; }
  .thumb { width: 96px; height: 54px; }
}

/* ---------- media screens (player and slides) ---------- */
.media-screen { position: fixed; inset: 0; background: #000; color: #fff; display: flex; flex-direction: column; }
.media-screen .bar { position: relative; background: var(--navy-deep); }
.media-screen .bar h1 { font-size: 16px; }
.stage { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; }

/* ---------- film player ---------- */
.pl-box { position: absolute; inset: 0; margin: auto; width: 100%; height: auto; aspect-ratio: 16 / 9; max-height: 100%; background: #000; }
.pl-box video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.pl-ui {
  position: absolute; inset: 0; display: grid; place-items: center; cursor: pointer;
  background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,0.55) 100%); transition: opacity 0.25s;
}
.pl-ui.hide { opacity: 0; cursor: none; }
.pl-ui.hide .pl-center, .pl-ui.hide .pl-bar { pointer-events: none; }
.pl-center {
  width: 72px; height: 72px; border-radius: 50%; background: var(--gold); color: var(--navy);
  display: grid; place-items: center; box-shadow: 0 6px 24px rgba(0,0,0,0.35);
}
.pl-center:active { background: var(--gold-press); }
.pl-ui.playing .pl-center { background: rgba(0,20,40,0.6); color: #fff; box-shadow: none; }
.pl-ui.wait .pl-center { position: relative; }
.pl-ui.wait .pl-center::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.25); border-top-color: #fff; animation: pl-spin 0.9s linear infinite;
}
@keyframes pl-spin { to { transform: rotate(360deg); } }
.pl-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 4px;
  padding: 4px 6px calc(4px + var(--pl-safe, 0px)); color: #fff; cursor: default;
}
.pl-btn { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none; }
.pl-btn:active { background: rgba(255,255,255,0.15); }
.pl-time { font-size: 13px; font-variant-numeric: tabular-nums; color: rgba(255,255,255,0.9); flex: none; min-width: 34px; text-align: center; }
.pl-seek {
  flex: 1; min-width: 0; height: 44px; margin: 0 6px; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer;
}
.pl-seek::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, #fff var(--p, 0%), rgba(255,255,255,0.3) var(--p, 0%));
}
.pl-seek::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.3); }
.pl-seek::-moz-range-progress { height: 4px; border-radius: 2px; background: #fff; }
.pl-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; margin-top: -6px; border: 0; }
.pl-seek::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 0; }
.media-screen.is-full .bar, .media-screen.is-full .media-foot, .media-screen.is-full .turn-hint { display: none; }
.media-screen.is-full { --pl-safe: env(safe-area-inset-bottom, 0px); }
.media-screen.is-full .pl-bar { padding-left: max(6px, env(safe-area-inset-left, 0px)); padding-right: max(6px, env(safe-area-inset-right, 0px)); }
.media-foot {
  background: var(--navy-deep); padding: 12px 16px calc(var(--safe-bottom) + 12px);
  display: flex; align-items: center; gap: 12px;
}
.media-foot .info { flex: 1; min-width: 0; font-size: 13.5px; color: rgba(255,255,255,0.75); line-height: 1.35; }
.media-foot .info strong { color: #fff; font-weight: 600; display: block; font-size: 15px; }
.media-foot .info a { color: #fff; }

.deck { flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; }
.deck::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; height: 100%; scroll-snap-align: center; scroll-snap-stop: always; display: grid; place-items: center; padding: 8px; }
.slide img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; background: #111; }
.count { font-variant-numeric: tabular-nums; font-size: 14px; color: rgba(255,255,255,0.8); white-space: nowrap; }
.turn-hint { font-size: 13px; color: rgba(255,255,255,0.65); text-align: center; padding: 0 16px 6px; }
@media (orientation: landscape) {
  .turn-hint { display: none; }
  .media-screen .bar { padding-top: 4px; padding-bottom: 4px; }
  .media-screen .bar .wrap { min-height: 36px; }
  .media-foot { padding-top: 6px; padding-bottom: calc(var(--safe-bottom) + 6px); }
  .media-foot .info { display: none; }
}

/* ---------- share sheet (fallback) ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; background: rgba(0,20,40,0.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; background: var(--surface); color: var(--ink); border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(var(--safe-bottom) + 16px); display: grid; gap: 10px;
}
.sheet-title { font-size: 17px; font-weight: 600; }
.sheet-link { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--muted); background: var(--bg); }
.sheet .btn { width: 100%; }
.sheet-close { color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 90px); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px;
  max-width: calc(100vw - 32px); z-index: 40; opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; }

@media (min-width: 700px) {
  .home-body, .list { padding-left: 0; padding-right: 0; }
}
