/* =====================================================================
   AniStorage — iOS-style theme for DLE 17.0
   Built on Bootstrap 5.3 utilities + Material Symbols icons.
   Author: design system (iOS / Human Interface inspired)
   ===================================================================== */

:root {
    /* iOS system palette (light) */
    --ios-blue: #0a84ff;
    --ios-indigo: #5e5ce6;
    --ios-purple: #bf5af2;
    --ios-pink: #ff375f;
    --ios-red: #ff453a;
    --ios-orange: #ff9f0a;
    --ios-yellow: #ffd60a;
    --ios-green: #30d158;
    --ios-teal: #40c8e0;

    --accent: var(--ios-blue);
    --accent-2: var(--ios-indigo);
    --accent-grad: linear-gradient(135deg, #0a84ff 0%, #5e5ce6 100%);
    --accent-grad-warm: linear-gradient(135deg, #ff375f 0%, #ff9f0a 100%);

    /* Surfaces */
    --bg: #f2f2f7;            /* iOS systemGroupedBackground */
    --bg-elevated: #ffffff;
    --card: rgba(255, 255, 255, 0.72);
    --card-solid: #ffffff;
    --card-2: #f7f7fb;
    --separator: rgba(60, 60, 67, 0.12);
    --separator-strong: rgba(60, 60, 67, 0.22);

    /* Text */
    --label: #1c1c1e;
    --label-2: rgba(60, 60, 67, 0.7);
    --label-3: rgba(60, 60, 67, 0.45);
    --on-accent: #ffffff;

    /* Glass blur */
    --blur: saturate(180%) blur(20px);

    /* Radii (iOS continuous corners) */
    --r-xs: 8px;
    --r-sm: 12px;
    --r-md: 16px;
    --r-lg: 22px;
    --r-xl: 28px;
    --r-pill: 999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.16);
    --shadow-accent: 0 8px 24px rgba(10, 132, 255, 0.35);

    --maxw: 1280px;
    --header-h: 60px;

    /* ---- Bridge variables expected by DLE engine.css / legacy popups ---- */
    --ui-bg: var(--card-solid);
    --ui-bg-darker: var(--card-2);
    --ui-bg-darkest: #e9e9ee;
    --ui-accent: var(--accent);
    --ui-bdc: var(--separator);
    --ui-tt-fade: var(--label-2);
    --ui-bsh: var(--shadow-lg);
    --ui-bsh-inset: inset 0 1px 2px rgba(0, 0, 0, 0.06);
    --ui-bdrs: var(--r-sm);
    --ui-red: var(--ios-red);
    --ui-green: var(--ios-green);
    --tt: var(--label);
    --bdrs: var(--r-md);
    --accent-red: var(--ios-pink);
    --bg-btn: var(--accent);
    --tt-btn: #fff;
    color-scheme: light;
}

/* ===== Dark mode (auto + manual .dark) ===== */
@media (prefers-color-scheme: dark) {
    :root:not(.light) {
        --bg: #000000;
        --bg-elevated: #1c1c1e;
        --card: rgba(28, 28, 30, 0.72);
        --card-solid: #1c1c1e;
        --card-2: #2c2c2e;
        --separator: rgba(84, 84, 88, 0.4);
        --separator-strong: rgba(84, 84, 88, 0.65);
        --label: #ffffff;
        --label-2: rgba(235, 235, 245, 0.6);
        --label-3: rgba(235, 235, 245, 0.35);
        --ui-bg-darkest: #3a3a3c;
        color-scheme: dark;
    }
}
:root.dark {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --card: rgba(28, 28, 30, 0.72);
    --card-solid: #1c1c1e;
    --card-2: #2c2c2e;
    --separator: rgba(84, 84, 88, 0.4);
    --separator-strong: rgba(84, 84, 88, 0.65);
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.35);
    --ui-bg-darkest: #3a3a3c;
    color-scheme: dark;
}

/* ===================== Base ===================== */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
        "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--label);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
    padding-top: var(--header-h);
}

a { color: var(--accent); text-decoration: none; transition: color .2s, opacity .2s; }
a:hover { opacity: .85; }
img { max-width: 100%; height: auto; display: block; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4, h5 { margin: 0 0 .5em; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
::selection { background: var(--accent); color: #fff; }

.container-ios { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* Material Symbols sizing helper */
.material-symbols-rounded {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
    line-height: 1;
    user-select: none;
}
.ms-fill { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.ms-18 { font-size: 18px; }
.ms-20 { font-size: 20px; }
.ms-22 { font-size: 22px; }
.ms-28 { font-size: 28px; }
.ms-40 { font-size: 40px; }

/* ===================== Header (frosted) ===================== */
.ios-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    z-index: 1000;
    background: var(--card);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border-bottom: 0.5px solid var(--separator);
}
.ios-header__inner {
    height: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.ios-logo {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--label);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0;
}
.ios-logo span {
    background: var(--accent-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.ios-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}
.ios-nav a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--r-pill);
    color: var(--label-2);
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
}
.ios-nav a:hover { background: var(--separator); color: var(--label); opacity: 1; }
.ios-nav a.is-active { background: var(--accent); color: #fff; }

.icon-btn {
    width: 40px; height: 40px;
    flex: 0 0 40px;
    display: inline-grid;
    place-items: center;
    border-radius: var(--r-pill);
    background: var(--separator);
    color: var(--label);
    border: 0;
    cursor: pointer;
    transition: background .2s, transform .1s;
}
.icon-btn:hover { background: var(--separator-strong); }
.icon-btn:active { transform: scale(0.92); }

.btn-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--r-pill);
    border: 0;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-accent);
    transition: transform .12s ease, filter .2s, box-shadow .2s;
    white-space: nowrap;
}
.btn-pill:hover { filter: brightness(1.05); color: #fff; opacity: 1; }
.btn-pill:active { transform: scale(0.96); }
.btn-pill--ghost { background: var(--separator); color: var(--label); box-shadow: none; }
.btn-pill--grad { background: var(--accent-grad); }
.btn-pill--warm { background: var(--accent-grad-warm); box-shadow: 0 8px 24px rgba(255,55,95,.35); }

/* Header search */
.ios-search { position: relative; flex: 1; max-width: 360px; }
.ios-search input {
    width: 100%;
    height: 40px;
    border: 0;
    border-radius: var(--r-pill);
    background: var(--separator);
    padding: 0 16px 0 42px;
    color: var(--label);
    font-size: 15px;
}
.ios-search input::placeholder { color: var(--label-3); }
.ios-search .material-symbols-rounded {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--label-2); font-size: 22px; pointer-events: none;
}

/* ===================== Layout ===================== */
.layout {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 20px 16px 90px;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 22px;
    align-items: start;
}
.layout__main { min-width: 0; }
.layout__side { position: sticky; top: calc(var(--header-h) + 16px); display: flex; flex-direction: column; gap: 18px; }

/* ===================== Cards / sections ===================== */
.surface {
    background: var(--card-solid);
    border: 0.5px solid var(--separator);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
}
.section { margin-bottom: 22px; }
.section__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.section__title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section__title .material-symbols-rounded { color: var(--accent); }
.section__more { font-size: 14px; font-weight: 600; color: var(--accent); }

/* Speedbar / breadcrumbs */
.speedbar {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--label-2);
    margin-bottom: 14px; flex-wrap: wrap;
}
.speedbar a { color: var(--label-2); font-weight: 600; }

/* ===================== Hero carousel ===================== */
.hero { margin-bottom: 24px; }
.hero__track {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scroll-padding: 4px;
    padding: 4px 4px 12px;
    -ms-overflow-style: none;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}
.hero__track::-webkit-scrollbar { display: none; }
.hero-card {
    position: relative;
    flex: 0 0 220px;
    aspect-ratio: 2/3;
    border-radius: var(--r-lg);
    overflow: hidden;
    scroll-snap-align: start;
    box-shadow: var(--shadow-md);
    transition: transform .25s ease;
}
.hero-card:hover { transform: translateY(-4px) scale(1.01); }
.hero-card img { width: 100%; height: 100%; object-fit: cover; }
.hero-card__overlay {
    position: absolute; inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.1) 55%, transparent 100%);
    display: flex; flex-direction: column; justify-content: flex-end;
    padding: 14px;
}
.hero-card__title { color: #fff; font-weight: 700; font-size: 16px; line-height: 1.25;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hero-card__rank {
    position: absolute; top: 10px; left: 10px;
    background: var(--accent-grad-warm); color: #fff;
    font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: var(--r-pill);
    box-shadow: var(--shadow-sm);
}

/* ===================== Grid of cards ===================== */
.view-toolbar { display: flex; gap: 4px; background: var(--separator); border-radius: var(--r-pill); padding: 3px; }
.view-toolbar button {
    width: 36px; height: 32px; border: 0; background: transparent; border-radius: var(--r-pill);
    color: var(--label-2); cursor: pointer; display: inline-grid; place-items: center;
}
.view-toolbar button.active { background: var(--card-solid); color: var(--accent); box-shadow: var(--shadow-sm); }

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 18px;
}
.cards-grid.grid-2 { grid-template-columns: repeat(2, 1fr); }
.cards-grid.list { grid-template-columns: 1fr; }
/* non-card children (pagination, profile, banners, system msgs) span the full row */
#dle-content > :not(.grid-item) { grid-column: 1 / -1; }

/* Anime poster card */
.anime-card {
    background: var(--card-solid);
    border: 0.5px solid var(--separator);
    border-radius: var(--r-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease;
    display: flex;
    flex-direction: column;
}
.anime-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.anime-card__poster { position: relative; aspect-ratio: 2/3; overflow: hidden; background: var(--card-2); }
.anime-card__poster img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.anime-card:hover .anime-card__poster img { transform: scale(1.06); }
.anime-card__badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.anime-card__play {
    position: absolute; inset: 0; display: grid; place-items: center;
    opacity: 0; transition: opacity .2s; background: rgba(0,0,0,.25);
}
.anime-card:hover .anime-card__play { opacity: 1; }
.anime-card__play span {
    width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
    background: rgba(255,255,255,.9); color: #000; box-shadow: var(--shadow-md);
}
.anime-card__body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.anime-card__title {
    font-size: 15px; font-weight: 700; line-height: 1.25; color: var(--label);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.anime-card__meta { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--label-2); margin-top: auto; }
.anime-card__meta .mi { display: inline-flex; align-items: center; gap: 3px; }

/* badges */
.badge-ios {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: var(--r-pill);
    background: rgba(0,0,0,.55); color: #fff; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.badge-ios--accent { background: var(--accent); }
.badge-ios--green { background: var(--ios-green); }
.badge-ios--red { background: var(--ios-red); }
.badge-ios--orange { background: var(--ios-orange); }
.badge-ios--shiki { background: linear-gradient(135deg,#3b5bdb,#5e5ce6); }
.badge-ios--imdb { background: #f5c518; color: #000; }

/* list view variant */
.cards-grid.list .anime-card { flex-direction: row; }
.cards-grid.list .anime-card__poster { flex: 0 0 110px; aspect-ratio: 2/3; }
.cards-grid.list .anime-card__body { padding: 14px 16px; }

/* ===================== Sidebar widgets ===================== */
.widget { padding: 16px; }
.widget__title { font-size: 17px; font-weight: 800; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.widget__title .material-symbols-rounded { color: var(--accent); }
.genre-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.genre-chips a {
    font-size: 13px; font-weight: 600; padding: 7px 13px; border-radius: var(--r-pill);
    background: var(--separator); color: var(--label);
}
.genre-chips a:hover { background: var(--accent); color: #fff; opacity: 1; }

.mini-list { display: flex; flex-direction: column; gap: 12px; }
.mini-item { display: flex; gap: 12px; align-items: center; }
.mini-item__img { flex: 0 0 48px; width: 48px; height: 68px; border-radius: var(--r-xs); overflow: hidden; background: var(--card-2); }
.mini-item__img img { width: 100%; height: 100%; object-fit: cover; }
.mini-item__title { font-size: 14px; font-weight: 700; line-height: 1.25; color: var(--label);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mini-item__meta { font-size: 12px; color: var(--label-2); display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.mini-item__meta .material-symbols-rounded { font-size: 15px; color: var(--ios-orange); }

/* ===================== Full story (anime page) ===================== */
.detail {
    position: relative;
    border-radius: var(--r-xl);
    overflow: hidden;
    margin-bottom: 22px;
    box-shadow: var(--shadow-md);
    background: #0b0b12; /* fallback so white text is always readable */
    isolation: isolate;
}
.detail__backdrop { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.detail__backdrop img { width: 100%; height: 100%; object-fit: cover; filter: blur(26px) saturate(150%); transform: scale(1.25); opacity: .6; }
/* Always-dark scrim guarantees contrast for white text in BOTH themes */
.detail__backdrop::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(105deg, rgba(0,0,0,.82) 0%, rgba(0,0,0,.55) 45%, rgba(0,0,0,.35) 100%),
        linear-gradient(0deg, rgba(0,0,0,.65) 0%, rgba(0,0,0,.1) 60%);
}
.detail__inner { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 22px; padding: 28px; }
.detail__head { display: flex; gap: 26px; align-items: flex-start; }
.detail__poster { flex: 0 0 220px; max-width: 220px; }
.detail__poster img { width: 100%; border-radius: var(--r-lg); box-shadow: var(--shadow-lg); aspect-ratio: 2/3; object-fit: cover; display: block; }
.detail__info { flex: 1; min-width: 0; color: #fff; }
.detail__info .detail__title,
.detail__info a { color: #fff; }
.detail__info .detail__title { font-size: clamp(22px, 3vw, 32px); font-weight: 800; text-shadow: 0 2px 14px rgba(0,0,0,.55); margin-bottom: 6px; }
.detail__orig { color: rgba(255,255,255,.72); font-size: 15px; margin-bottom: 16px; }
.detail__chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.detail__stats { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 18px; }
.stat-pill { display: flex; align-items: center; gap: 7px; color: #fff; font-weight: 700; font-size: 15px; }
.stat-pill .material-symbols-rounded { font-size: 20px; }
.stat-pill--star .material-symbols-rounded { color: var(--ios-yellow); }
.detail__props { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 20px; margin-bottom: 22px; }
.prop { font-size: 14px; color: rgba(255,255,255,.95); line-height: 1.45; }
.prop b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: rgba(255,255,255,.6); font-weight: 700; margin-bottom: 3px; }
.prop a { color: #fff; font-weight: 600; text-decoration: underline; text-decoration-color: rgba(255,255,255,.35); text-underline-offset: 2px; }
.detail__actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* description */
.prose { color: var(--label); font-size: 16px; line-height: 1.7; }
.prose p { margin: 0 0 1em; }

/* ===================== Segmented control / player tabs ===================== */
.segmented {
    display: inline-flex;
    background: var(--separator);
    border-radius: var(--r-md);
    padding: 4px;
    gap: 4px;
}
.segmented button {
    border: 0; background: transparent; cursor: pointer;
    padding: 8px 18px; border-radius: calc(var(--r-md) - 4px);
    font-size: 14px; font-weight: 600; color: var(--label-2);
    transition: all .2s;
}
.segmented button.is-active { background: var(--card-solid); color: var(--label); box-shadow: var(--shadow-sm); }

.player-card { padding: 16px; margin-bottom: 22px; }
.player-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.player-stage { position: relative; border-radius: var(--r-md); overflow: hidden; background: #000; }
.video-responsive { position: relative; padding-top: 56.25%; }
.video-responsive iframe, .video-responsive video-player, .player-stage iframe {
    position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
video-player, #cdnvideohubvideoplayer { display: block; width: 100%; aspect-ratio: 16/9; }
.tab-pane { display: none; }
.tab-pane.is-active { display: block; }

/* click-to-play poster placeholder (so the player is never an empty black void) */
.player-poster {
    position: absolute; inset: 0; z-index: 2; cursor: pointer;
    background-size: cover; background-position: center;
    display: flex; align-items: flex-end; justify-content: center;
    border-radius: inherit; overflow: hidden;
}
.player-poster::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,.25) 0%, rgba(0,0,0,.55) 100%);
    -webkit-backdrop-filter: saturate(120%); backdrop-filter: saturate(120%);
}
.player-poster__btn {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
    width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer;
    background: rgba(255,255,255,.92); color: #000;
    display: grid; place-items: center; box-shadow: var(--shadow-lg);
    transition: transform .15s ease, background .2s;
}
.player-poster__btn .material-symbols-rounded { font-size: 40px; margin-left: 3px; }
.player-poster:hover .player-poster__btn { transform: translate(-50%,-50%) scale(1.08); background: #fff; }
.player-poster__label {
    position: relative; z-index: 1; color: #fff; font-weight: 700; font-size: 15px;
    padding: 0 16px 16px; text-align: center; text-shadow: 0 2px 8px rgba(0,0,0,.6);
    display: flex; align-items: center; gap: 8px;
}
.player-stage.is-playing .player-poster { display: none; }

/* episode navigation buttons */
.episode-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 18px 0; }
.episode-nav a { display: inline-flex; align-items: center; gap: 6px; }

.episodes-list { display: flex; flex-wrap: wrap; gap: 8px; }
.episodes-list a {
    padding: 9px 15px; border-radius: var(--r-sm); background: var(--separator);
    color: var(--label); font-size: 14px; font-weight: 600;
}
.episodes-list a:hover, .episodes-list a.is-active { background: var(--accent); color: #fff; opacity: 1; }

/* rating box */
.rate-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.rate-box__label { font-weight: 700; display: flex; align-items: center; gap: 6px; color: var(--label-2); }
.rate-btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
    border-radius: var(--r-pill); border: 0; cursor: pointer; font-weight: 700;
    background: var(--separator); color: var(--label);
}
.rate-btn--like:hover { background: var(--ios-green); color: #fff; }
.rate-btn--dislike:hover { background: var(--ios-red); color: #fff; }

.complaint-link { display: inline-flex; align-items: center; gap: 6px; color: var(--label-2); font-size: 14px; font-weight: 600; }

/* ===================== Countdown ===================== */
.countdown { padding: 18px; margin-bottom: 22px; text-align: center; }
.countdown__title { font-weight: 700; color: var(--label-2); margin-bottom: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.countdown__blocks { display: flex; align-items: center; justify-content: center; gap: 10px; }
.countdown__block { background: var(--card-2); border-radius: var(--r-md); padding: 12px 4px; min-width: 70px; }
.countdown__num { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.countdown__lbl { font-size: 12px; color: var(--label-2); text-transform: uppercase; letter-spacing: .04em; }
.countdown__sep { font-size: 26px; font-weight: 800; color: var(--label-3); }

/* ===================== Comments ===================== */
.comments-wrap { padding: 18px; }
.comment { display: flex; gap: 12px; padding: 14px 0; border-bottom: 0.5px solid var(--separator); }
.comment:last-child { border-bottom: 0; }
.comment__avatar { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: var(--card-2); }
.comment__avatar img { width: 100%; height: 100%; object-fit: cover; }
.comment__body { flex: 1; min-width: 0; }
.comment__head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.comment__author { font-weight: 700; }
.comment__date { font-size: 13px; color: var(--label-3); }
.comment__text { font-size: 15px; line-height: 1.6; }
.comment__actions { display: flex; gap: 14px; margin-top: 8px; font-size: 13px; color: var(--label-2); }
.comment__actions a, .comment__actions span { color: var(--label-2); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }

.cform { display: flex; flex-direction: column; gap: 12px; }
.cform__row { display: flex; gap: 12px; flex-wrap: wrap; }
.field {
    width: 100%; height: 44px; border: 0.5px solid var(--separator); border-radius: var(--r-sm);
    background: var(--bg-elevated); color: var(--label); padding: 0 14px; font-size: 15px;
}
.field:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea.field { height: auto; min-height: 100px; padding: 12px 14px; resize: vertical; }

.info-banner {
    display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--label-2);
    background: var(--card-2); border-radius: var(--r-sm); padding: 10px 14px;
}

/* ===================== SEO text block ===================== */
.seo-block { padding: 22px; margin-top: 22px; }
.seo-block h1, .seo-block h2 { color: var(--label); }
.seo-block h1 { font-size: 24px; }
.seo-block h2 { font-size: 20px; margin-top: 1em; }
.seo-block p { color: var(--label-2); line-height: 1.75; margin: 0 0 1em; }
.seo-block ul { display: flex; flex-direction: column; gap: 10px; margin: 0 0 1em; }
.seo-block ul li { position: relative; padding-left: 28px; color: var(--label-2); line-height: 1.6; }
.seo-block ul li::before {
    content: 'check_circle'; font-family: 'Material Symbols Rounded'; position: absolute; left: 0; top: 1px;
    color: var(--ios-green); font-size: 20px;
}
.seo-block ul li strong { color: var(--label); }

/* ===================== Profile page ===================== */
.profile { width: 100%; max-width: 100%; margin: 0; }
.profile-hero {
    position: relative;
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    margin-bottom: 18px;
    background: var(--card-solid);
    border: 0.5px solid var(--separator);
}
.profile-hero__cover { height: 140px; background: var(--accent-grad); position: relative; }
.profile-hero__cover::after { content: ''; position: absolute; inset: 0; background: radial-gradient(120% 120% at 80% 0%, rgba(255,255,255,.25), transparent 60%); }
.profile-hero__body { padding: 0 24px 22px; margin-top: -52px; position: relative; }
.profile-hero__avatar {
    width: 104px; height: 104px; border-radius: 50%; overflow: hidden;
    border: 4px solid var(--card-solid); box-shadow: var(--shadow-md); background: var(--card-2);
}
.profile-hero__avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-hero__name { font-size: 24px; font-weight: 800; margin: 12px 0 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--label-2); }
.profile-status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--label-3); }
.profile-status.on .dot { background: var(--ios-green); box-shadow: 0 0 0 3px rgba(48,209,88,.25); }
.profile-status.on { color: var(--ios-green); }
.profile-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: var(--r-pill); background: var(--separator); color: var(--label); }
.profile-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.profile-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.profile-stat { background: var(--card-solid); border: 0.5px solid var(--separator); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.profile-stat__num { font-size: 26px; font-weight: 800; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.profile-stat__lbl { font-size: 13px; color: var(--label-2); font-weight: 600; }

.info-list { display: flex; flex-direction: column; }
.info-list li { display: flex; gap: 12px; padding: 13px 0; border-bottom: 0.5px solid var(--separator); font-size: 15px; align-items: flex-start; }
.info-list li:last-child { border-bottom: 0; }
.info-list li > span:first-child { flex: 0 0 150px; color: var(--label-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.info-list li .material-symbols-rounded { color: var(--accent); font-size: 20px; }

/* Auth pages (registration / lost password) */
.auth-page { max-width: 620px; margin: 0 auto; }
.auth-page__title { font-size: clamp(24px, 4vw, 30px); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 14px; }
.ios-row__field { display: flex; gap: 10px; flex: 1; min-width: 0; flex-wrap: wrap; }
.ios-row__field .field { flex: 1; min-width: 0; }
.ios-row__field .btn-pill { flex: 0 0 auto; height: 44px; }

/* Search page */
.search-page { max-width: 760px; margin: 0 auto; }
.search-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; }
.search-bar__field { flex: 1; min-width: 140px; }
.search-bar__field input, .search-bar__field select, .searchtable input[type="text"], .searchtable select { width: 100%; }
.search-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.has-radiobox label, .checkbox { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 560px) {
    .search-bar { flex-direction: column; align-items: stretch; }
    .search-bar .btn-pill { width: 100%; justify-content: center; height: 48px; }
    .search-actions .btn-pill { flex: 1 1 100%; justify-content: center; height: 48px; }
}
.auth-social { display: flex; flex-wrap: wrap; gap: 10px; }
#result-registration:not(:empty) { font-size: 13px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--card-2); color: var(--label-2); }

/* iOS grouped form sections (profile edit) */
.ios-group { background: var(--card-solid); border: 0.5px solid var(--separator); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 6px 16px; margin-bottom: 16px; }
.ios-group__title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--label-2); margin: 14px 4px 8px; }
.ios-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 0.5px solid var(--separator); flex-wrap: wrap; }
.ios-row:last-child { border-bottom: 0; }
.ios-row > label, .ios-row > .form__label, .ios-row .form__caption { flex: 0 0 180px; font-weight: 600; color: var(--label); }
.ios-row input[type="text"], .ios-row input[type="password"], .ios-row input[type="email"],
.ios-row select, .ios-row textarea, .ios-row .form__content { flex: 1; min-width: 200px; }

/* ===================== Calendar / Ongoings ===================== */
.content__title { margin-bottom: 18px; }
.content__title h1 {
    font-size: clamp(22px, 3vw, 28px); font-weight: 800; letter-spacing: -0.02em;
    display: flex; align-items: center; gap: 10px; margin: 0;
}
.content__title h1::before {
    content: 'calendar_month'; font-family: 'Material Symbols Rounded';
    font-variation-settings: 'FILL' 1; color: var(--accent); font-size: 30px;
}

.next-series { margin-bottom: 26px; }
.next-series__title {
    font-size: 19px; font-weight: 800; letter-spacing: -0.02em;
    margin: 0 0 14px; display: flex; align-items: center; gap: 10px;
    text-transform: capitalize; color: var(--label);
}
.next-series__title::before {
    content: ''; width: 5px; height: 20px; border-radius: 3px;
    background: var(--accent-grad); flex: 0 0 auto;
}

.next-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}
.next-card {
    background: var(--card-solid);
    border: 0.5px solid var(--separator);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease;
}
.next-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.next-card__link { display: flex; align-items: center; gap: 14px; padding: 10px; color: var(--label); }
.next-card__cover {
    position: relative; flex: 0 0 70px; width: 70px; height: 94px;
    border-radius: var(--r-sm); overflow: hidden; background: var(--card-2);
}
.next-card__cover img { width: 100%; height: 100%; object-fit: cover; }
.next-card__content { display: flex; flex-direction: column; gap: 7px; min-width: 0; flex: 1; }
.next-card__title {
    font-weight: 700; font-size: 15px; line-height: 1.3; color: var(--label);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.next-card__episode {
    align-self: flex-start; display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 700; padding: 4px 11px; border-radius: var(--r-pill);
    background: var(--accent); color: #fff; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.next-card__episode::before {
    content: 'play_circle'; font-family: 'Material Symbols Rounded'; font-size: 15px; line-height: 1;
}
.next-card__watched { display: none; }

/* "release" (overdue) section gets a warm accent bar */
.next-series[aria-label="Уже должно выйти"] .next-series__title::before { background: var(--accent-grad-warm); }
.next-series[aria-label="Сегодня"] .next-card__episode { background: var(--ios-green); }

.message-info__title { font-weight: 800; font-size: 16px; color: var(--label); margin-bottom: 4px; }
.message-info__content { color: var(--label-2); }

@media (max-width: 600px) {
    .next-list { grid-template-columns: 1fr; gap: 10px; }
    .next-series__title { font-size: 17px; }
}

/* ===================== Footer ===================== */
.ios-footer {
    border-top: 0.5px solid var(--separator);
    padding: 26px 16px;
    text-align: center;
    color: var(--label-2);
    font-size: 14px;
}
.ios-footer a { font-weight: 600; }

/* ===================== Mobile bottom tab bar ===================== */
.tabbar { display: none; }

/* ===================== Pagination ===================== */
.pagination {
    display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
    margin: 24px 0;
}
.pagination span, .pagination a, .pagination .nav_block {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 40px; height: 40px; padding: 0 12px; border-radius: var(--r-pill);
    background: var(--separator); color: var(--label); font-weight: 700; font-size: 15px;
    flex: 0 0 auto;
}
.pagination a:hover { background: var(--accent); color: #fff; opacity: 1; }
.pagination .thisclass, .pagination b { background: var(--accent); color: #fff; }

@media (max-width: 560px) {
    /* horizontal scroll strip so many pages never overflow / wrap messily */
    .pagination {
        flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto;
        gap: 8px; padding: 4px 2px 10px; margin: 18px 0;
        -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
        scrollbar-width: none; scroll-snap-type: x proximity;
        -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
        mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
    }
    .pagination::-webkit-scrollbar { display: none; }
    .pagination span, .pagination a, .pagination .nav_block {
        min-width: 44px; height: 44px; font-size: 16px; scroll-snap-align: center;
    }
    .pagination .thisclass, .pagination b { scroll-snap-align: center; }
}

/* ===================== Search overlay ===================== */
.search-overlay {
    position: fixed; inset: 0; z-index: 1100; display: none;
    background: rgba(0,0,0,.4); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.search-overlay.is-open { display: block; }
.search-overlay__panel {
    max-width: 640px; margin: 80px auto 0; padding: 0 16px;
}
.search-overlay__box { display: flex; align-items: center; gap: 10px; background: var(--card-solid); border-radius: var(--r-md); padding: 8px 14px; box-shadow: var(--shadow-lg); }
.search-overlay__box input { flex: 1; height: 48px; border: 0; background: transparent; font-size: 18px; color: var(--label); }
#search-suggest { margin-top: 12px; }

/* ===================== Login sheet ===================== */
.sheet-backdrop { position: fixed; inset: 0; z-index: 1100; background: rgba(0,0,0,.4); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); display: none; }
.sheet-backdrop.is-open { display: block; }
.sheet {
    position: fixed; z-index: 1101; left: 50%; top: 50%; transform: translate(-50%,-50%) scale(.96);
    width: min(420px, calc(100vw - 32px)); background: var(--card-solid); border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg); padding: 24px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.sheet.is-open { opacity: 1; pointer-events: auto; transform: translate(-50%,-50%) scale(1); }
.sheet__title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.sheet__sub { color: var(--label-2); font-size: 14px; margin-bottom: 18px; }
.sheet__close { position: absolute; top: 16px; right: 16px; }
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--label-2); }

/* user dropdown in header */
.user-menu { position: relative; }
.user-menu__avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; cursor: pointer; border: 2px solid var(--separator); }
.user-menu__avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-menu__panel {
    position: absolute; right: 0; top: 52px; width: 260px; background: var(--card-solid);
    border-radius: var(--r-md); box-shadow: var(--shadow-lg); border: 0.5px solid var(--separator);
    padding: 8px; display: none; z-index: 1200;
}
.user-menu__panel.is-open { display: block; }
.user-menu__panel a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); color: var(--label); font-weight: 600; font-size: 14px; }
.user-menu__panel a:hover { background: var(--separator); opacity: 1; }
.user-menu__panel .material-symbols-rounded { color: var(--label-2); font-size: 20px; }
.user-menu__hr { height: 0.5px; background: var(--separator); margin: 6px 8px; }

/* related carousel */
.related-track { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.related-track::-webkit-scrollbar { display: none; }
.related-track > * { flex: 0 0 150px; }
.episodes-list { -webkit-overflow-scrolling: touch; }

/* utility */
.d-none { display: none !important; }
.js-mobile-only { display: none; }
.flex-grow-1 { flex: 1; }
.text-fade { color: var(--label-2); }
.mt-auto { margin-top: auto; }

/* ===================== Responsive ===================== */
@media (max-width: 1024px) {
    .layout { grid-template-columns: 1fr; }
    .layout__side { position: static; order: 3; }
}
@media (max-width: 900px) {
    .layout { padding: 16px 14px 90px; gap: 18px; }
}

@media (max-width: 768px) {
    :root { --header-h: 56px; }
    body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
    .container-ios { padding: 0 14px; }
    .ios-header__inner { gap: 10px; padding: 0 14px; }
    .ios-logo { font-size: 19px; margin-right: auto; } /* push action buttons to the right */
    .ios-nav, .ios-search.desktop-only { display: none; }
    .js-mobile-only { display: inline-grid; }
    .ios-header .btn-pill { display: none; } /* guest "Войти" -> use tab bar */

    /* Mobile dropdown menu (solid slide-down sheet) */
    .ios-nav.mobile-open {
        display: flex; flex-direction: column; align-items: stretch; gap: 2px;
        position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 999;
        background: var(--bg-elevated);
        border-bottom: 0.5px solid var(--separator);
        padding: 8px calc(8px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
        box-shadow: var(--shadow-lg); max-height: calc(100dvh - var(--header-h)); overflow-y: auto;
        animation: slideDown .22s ease;
    }
    .ios-nav.mobile-open a {
        font-size: 16px; font-weight: 600; padding: 14px 16px; border-radius: var(--r-md);
        color: var(--label); display: flex; align-items: center; gap: 12px;
    }
    .ios-nav.mobile-open a .material-symbols-rounded { color: var(--accent); font-size: 22px; }
    .ios-nav.mobile-open a:active { background: var(--separator); }

    /* Detail hero: poster + title side by side, meta below */
    .detail__inner { padding: 16px; gap: 16px; }
    .detail { margin-bottom: 16px; }
    .detail__head { gap: 14px; }
    .detail__poster { flex: 0 0 120px; max-width: 120px; margin: 0; }
    .detail__info { text-align: left; }
    .detail__info .detail__title { font-size: 19px; }
    .detail__chips { margin-bottom: 10px; }
    .detail__stats { gap: 14px 18px; margin-bottom: 0; }
    .detail__props { grid-template-columns: 1fr 1fr; gap: 12px 16px; }
    .detail__actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
    .detail__actions .btn-pill { width: 100%; justify-content: center; height: 48px; }

    .hero-card { flex-basis: 132px; }
    .cards-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .section__title { font-size: 20px; }

    /* full-width surfaces feel more native on phones */
    .player-card, .surface.section, .comments-wrap, .seo-block, .countdown { border-radius: var(--r-md); }
    .segmented { width: 100%; }
    .segmented button { flex: 1; }
    .player-head { gap: 10px; }

    /* sheets become bottom sheets on mobile */
    .sheet {
        top: auto; bottom: 0; left: 0; transform: translateY(20px);
        width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0;
        padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
    }
    .sheet.is-open { transform: translateY(0); }
    .search-overlay__panel { margin-top: 12px; padding: 0 12px; }

    /* Profile page mobile adaptation */
    .profile-hero__cover { height: 110px; }
    .profile-hero__body { padding: 0 16px 18px; margin-top: -46px; }
    .profile-hero__avatar { width: 86px; height: 86px; }
    .profile-hero__name { font-size: 20px; }
    .info-list li { flex-direction: column; gap: 2px; }
    .info-list li > span:first-child { flex: none; }
    .ios-row { flex-direction: column; align-items: stretch; gap: 8px; }
    .ios-row > label, .ios-row > .form__label, .ios-row .form__caption { flex: none; }
    .ios-row input[type="text"], .ios-row input[type="password"], .ios-row input[type="email"],
    .ios-row select, .ios-row textarea, .ios-row .form__content { min-width: 0; }
    .profile-stat__num { font-size: 22px; }

    /* iOS bottom tab bar */
    .tabbar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
        background: var(--card); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
        border-top: 0.5px solid var(--separator); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        justify-content: space-around;
    }
    .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; font-weight: 600; color: var(--label-2); padding: 4px 8px; flex: 1; }
    .tabbar a.is-active { color: var(--accent); }
    .tabbar a .material-symbols-rounded { font-size: 24px; }
    .tabbar a:active { opacity: .6; }
}

@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 420px) {
    .cards-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .anime-card__title { font-size: 14px; }
    .section__title { font-size: 18px; }
    .detail__poster { flex-basis: 104px; max-width: 104px; }
    .profile-stats { gap: 8px; }
}
