@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&display=swap');

:root { color-scheme: dark; --bg: #08090e; --line: rgba(255,255,255,.11); --muted: #858792; --blue: #6f85ff; --purple: #b05ce4; --ease-out: cubic-bezier(.23,1,.32,1); }
* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; }
body { margin: 0; min-height: 100svh; overflow: hidden; color: #f5f5f7; font-family: 'Manrope', sans-serif; background: var(--bg); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.backdrop { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle at 80% 4%, rgba(76,84,145,.16), transparent 36%), radial-gradient(circle at 20% 100%, rgba(97,47,122,.12), transparent 34%); }
.backdrop::after { content: ''; position: absolute; inset: 0; opacity: .025; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

.app { position: relative; display: flex; flex-direction: column; gap: 14px; width: calc(100% - 28px); height: 100svh; margin: 0 auto; padding: 14px 0; }
.header { position: relative; z-index: 5; display: grid; grid-template-columns: 132px minmax(260px,1fr) auto; align-items: center; gap: 17px; min-height: 64px; }
.logo { display: block; width: 124px; height: 58px; object-fit: contain; }
.search { position: relative; }
.search-field { display: flex; align-items: center; gap: 14px; height: 64px; padding: 0 21px; border: 1px solid var(--line); border-radius: 16px; background: rgba(15,16,23,.94); box-shadow: inset 0 1px rgba(255,255,255,.025); }
.search-field:focus-within { border-color: rgba(126,139,255,.7); }
.search-field svg { width: 22px; fill: none; stroke: #898b96; stroke-width: 1.9; stroke-linecap: round; }
.search-field input { width: 100%; border: 0; outline: 0; color: white; font: 600 18px 'Manrope', sans-serif; background: transparent; }
.search-field input::placeholder { color: #6f717b; }
.search-field input::-webkit-search-cancel-button { appearance: none; }
.search-results { position: absolute; inset: calc(100% + 7px) 0 auto; display: none; max-height: min(430px,70vh); overflow: auto; padding: 7px; border: 1px solid var(--line); border-radius: 15px; background: #101119; box-shadow: 0 20px 55px rgba(0,0,0,.6); }
.search-results.open { display: block; }
.search-result { display: grid; grid-template-columns: 44px minmax(0,1fr) auto; align-items: center; gap: 13px; width: 100%; padding: 9px; border: 0; border-radius: 10px; color: white; text-align: left; background: transparent; cursor: pointer; touch-action: manipulation; transition: background-color 140ms ease, transform 140ms var(--ease-out); }
.search-result:hover, .search-result:focus-visible { outline: 0; background: rgba(255,255,255,.065); }
.search-result:active { transform: scale(.985); }
.search-result img { width: 44px; height: 60px; border-radius: 6px; object-fit: cover; background: #20212a; }
.search-result strong, .search-result small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result strong { font-size: 14px; }
.search-result small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.result-score { color: #a991ff; font-size: 15px; font-weight: 800; text-shadow: 0 0 16px rgba(111,133,255,.35); }
.search-message { margin: 0; padding: 15px; color: var(--muted); font-size: 12px; text-align: center; }
.library-link { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 19px; border: 1px solid rgba(255,255,255,.16); border-radius: 13px; color: #e3e4e8; font-size: 15px; font-weight: 800; text-decoration: none; white-space: nowrap; background: rgba(255,255,255,.045); transition: color 140ms ease, border-color 140ms ease, transform 140ms var(--ease-out); }
.library-link span { display: grid; min-width: 25px; height: 25px; padding: 0 6px; place-items: center; border-radius: 99px; color: #0b0c11; font-size: 11px; background: #e7e8ed; }
.library-link:hover { color: #fff; border-color: rgba(255,255,255,.24); }
.library-link:active { transform: scale(.97); }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.header-actions .back-link { white-space: nowrap; }

.selected { display: grid; grid-template-columns: 90px minmax(0,1fr); align-items: center; gap: 20px; min-height: 152px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 17px; background: rgba(12,13,19,.86); }
.selected[hidden] { display: none; }
.poster { width: 90px; height: 132px; border-radius: 9px; object-fit: cover; background: #20212a; }
.title-block { min-width: 0; }
.title-block h1 { overflow: hidden; margin: 0; font-size: clamp(24px,2.8vw,34px); line-height: 1.08; text-overflow: ellipsis; white-space: nowrap; }
.title-block > p { overflow: hidden; margin: 5px 0 10px; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; gap: 5px; }
.meta span { padding: 4px 8px; border: 1px solid var(--line); border-radius: 5px; color: #9a9ca6; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }
.title-block .description { display: -webkit-box; max-width: 1100px; margin: 9px 0 0; overflow: hidden; color: #898b95; font-size: 13px; line-height: 1.5; white-space: normal; text-overflow: ellipsis; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.episode-picker { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(15,16,23,.82); }
.episode-picker[hidden] { display: none; }
.episode-picker label { color: #a4a6af; font-size: 14px; font-weight: 800; }
.episode-picker select { min-width: 82px; height: 38px; padding: 0 30px 0 12px; border: 1px solid rgba(255,255,255,.13); border-radius: 9px; color: #fff; font: 800 13px 'Manrope', sans-serif; background-color: #20212a; cursor: pointer; }
.episode-picker span { overflow: hidden; color: #73757f; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.episode-picker .range-separator { color: #777984; }
.season-button { height: 38px; padding: 0 16px; border: 1px solid rgba(255,255,255,.13); border-radius: 9px; color: #a5a7b0; font: 800 12px 'Manrope', sans-serif; background: rgba(255,255,255,.03); cursor: pointer; }
.season-button:hover, .season-button.active { color: #fff; border-color: rgba(111,133,255,.65); background: rgba(111,133,255,.14); }
.shiki, .simero-score { --card-color: #b5a0ff; display: grid; grid-template-columns: auto auto; align-items: end; width: 150px; min-width: 150px; min-height: 70px; margin-right: 14px; padding: 11px 14px; border: 1px solid color-mix(in srgb, var(--card-color), transparent 52%); border-radius: 13px; color: inherit; text-decoration: none; background: linear-gradient(135deg, color-mix(in srgb, var(--card-color), transparent 84%), rgba(16,17,24,.88)); box-shadow: inset 0 1px rgba(255,255,255,.04), 0 0 22px color-mix(in srgb, var(--card-color), transparent 88%); transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, filter 180ms ease; }
.shiki span, .simero-score span { grid-column: 1/-1; margin-bottom: 4px; color: #858792; font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.shiki strong, .simero-score strong { color: var(--card-color); font-size: 29px; line-height: 1; text-shadow: 0 0 18px color-mix(in srgb, var(--card-color), transparent 62%); transition: color 180ms ease, text-shadow 180ms ease; }
.shiki small, .simero-score small { margin: 0 0 2px 5px; color: #92949e; font-size: 11px; }

.rating-area { display: grid; flex: 1; grid-template-rows: auto 1fr auto; gap: 12px; min-height: 0; }
.ratings-grid { display: grid; grid-template-columns: 1fr; gap: 11px; }
.rating-area.locked .rating-panel { border-color: rgba(255,255,255,.09); background: linear-gradient(105deg, rgba(37,38,45,.58), rgba(23,24,30,.52)); }
.rating-area.locked .criterion { opacity: .55; }
.rating-area.locked input[type='range'] { --accent: #777983; background-image: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(255,255,255,.14) calc(10% - 1px) 10%), linear-gradient(90deg, rgba(119,121,131,.48), rgba(119,121,131,.48)); }
.rating-area.locked .simero-score { filter: grayscale(1); opacity: .42; }
.rating-area.locked .shiki { pointer-events: none; filter: grayscale(1); opacity: .42; }
.rating-area.locked button { opacity: .35; }
.rating-panel { --accent: var(--blue); display: grid; align-items: center; min-height: 74px; padding: 8px 20px; border: 1px solid color-mix(in srgb, var(--accent), transparent 45%); border-radius: 13px; background: linear-gradient(145deg, color-mix(in srgb, var(--accent), transparent 78%), rgba(24,25,34,.82)); box-shadow: inset 0 1px rgba(255,255,255,.04), 0 9px 20px rgba(0,0,0,.11); transition: border-color 180ms ease, background-color 180ms ease, opacity 180ms ease; }
.rating-panel.story input { --accent: var(--blue); }
.rating-panel.art { --accent: #e7b84b; }
.rating-panel.art input { --accent: #e7b84b; }
.rating-panel.vibe { --accent: var(--purple); }
.rating-panel.vibe input { --accent: var(--purple); }
.criterion { min-width: 0; }
.criterion-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.criterion label { font-size: 17px; font-weight: 800; }
.criterion output { color: #fff; font-size: 26px; font-weight: 800; }
input[type='range'] { --value: 0%; width: 100%; height: 32px; margin: 0; border: 0; border-radius: 99px; appearance: none; cursor: pointer; touch-action: manipulation; background-color: transparent; background-image: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(255,255,255,.2) calc(10% - 1px) 10%), linear-gradient(90deg, var(--accent) var(--value), rgba(255,255,255,.11) var(--value)); background-position: center; background-repeat: no-repeat; background-size: calc(100% - 28px) 9px; }
input[type='range']::-webkit-slider-runnable-track { height: 9px; border: 0; border-radius: 99px; background: transparent; }
input[type='range']::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -9.5px; border: 6px solid #e1e1e5; border-radius: 50%; appearance: none; background: #848690; box-shadow: 0 2px 9px rgba(0,0,0,.55); }
input[type='range']::-moz-range-track { height: 9px; border: 0; border-radius: 99px; background: transparent; }
input[type='range']::-moz-range-thumb { width: 16px; height: 16px; border: 6px solid #e1e1e5; border-radius: 50%; background: #848690; box-shadow: 0 2px 9px rgba(0,0,0,.55); }
input[type='range']:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.total { display: flex; align-self: end; align-items: center; width: 100%; min-height: 90px; padding: 6px 4px; }
.simero-score { --score-hue: 0; --card-color: hsl(var(--score-hue) 78% 60%); }
.total #resetButton { margin-left: auto; }
.total button { min-height: 46px; margin-left: 12px; padding: 0 19px; border: 1px solid var(--line); border-radius: 10px; color: #b5b6bd; font: 800 13px 'Manrope', sans-serif; background: rgba(255,255,255,.025); cursor: pointer; touch-action: manipulation; transition: border-color 140ms ease, color 140ms ease, transform 140ms var(--ease-out); }
.total button:hover { color: #fff; border-color: rgba(255,255,255,.25); }
.total button:active { transform: scale(.97); }
.total button:disabled { cursor: default; }
.confirm-button { display: flex; align-items: center; gap: 7px; color: #101117 !important; border-color: #f0f0f2 !important; background: #f0f0f2 !important; }
.confirm-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.confirm-button:disabled { opacity: .35; }
.save-status { min-height: 16px; margin: -8px 4px 0; color: #8ee0ab; font-size: 12px; text-align: right; }

/* Watched ratings */
.library-page { overflow-y: auto; }
.library-page .app { height: auto; min-height: 100svh; }
.library-header { display: grid; grid-template-columns: 120px minmax(0,1fr) auto; align-items: center; gap: 18px; min-height: 70px; }
.back-link { color: #aeb0ba; font-size: 12px; font-weight: 800; text-decoration: none; }
.library-title { margin: 0; font-size: clamp(26px,4vw,46px); line-height: 1; }
.library-summary { margin: 18px 0 16px; color: var(--muted); font-size: 12px; }
.table-shell { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: rgba(14,15,22,.9); }
.watched-table { width: 100%; min-width: 900px; border-collapse: collapse; }
.watched-table th { height: 48px; padding: 0 16px; color: #777984; font-size: 10px; letter-spacing: .1em; text-align: left; text-transform: uppercase; background: rgba(255,255,255,.018); }
.watched-table td { height: 112px; padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.07); color: #d0d1d6; font-size: 14px; }
.watched-table tbody tr { transition: background-color 140ms ease; }
.watched-table tbody tr:hover { background: rgba(255,255,255,.025); }
.cover-cell { width: 82px; }
.table-cover { display: block; width: 54px; height: 78px; border-radius: 7px; object-fit: cover; background: #20212a; }
.title-cell { min-width: 230px; }
.title-cell a { display: block; overflow: hidden; max-width: 420px; color: #fff; font-size: 17px; font-weight: 800; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.title-cell small { display: block; overflow: hidden; max-width: 420px; margin-top: 5px; color: #858792; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.episodes-cell strong, .score-cell strong { color: #fff; font-size: 22px; }
.episodes-cell small, .score-cell small { color: #777984; font-size: 11px; }
.score-cell.shiki-table strong { color: #a991ff; }
.score-cell.simero-table strong { color: #f3f3f5; }
.score-popover { position: relative; display: inline-flex; align-items: baseline; cursor: help; outline: none; }
.score-popover:focus-visible { border-radius: 5px; outline: 2px solid #fff; outline-offset: 4px; }
.score-tooltip { position: absolute; z-index: 4; top: 50%; right: calc(100% + 12px); width: 220px; padding: 11px 14px; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; color: #d4d5da; background: rgba(17,18,25,.98); box-shadow: 0 14px 35px rgba(0,0,0,.48); opacity: 0; pointer-events: none; transform: translate(4px,-50%); transition: opacity 140ms ease, transform 140ms var(--ease-out); }
.score-tooltip::before { content: ''; position: absolute; top: 50%; left: 100%; border: 6px solid transparent; border-left-color: rgba(255,255,255,.14); transform: translateY(-50%); }
.score-popover:hover .score-tooltip, .score-popover:focus .score-tooltip { opacity: 1; transform: translate(0,-50%); }
.score-tooltip span { display: flex; justify-content: space-between; gap: 20px; font-size: 14px; line-height: 1.45; }
.score-tooltip span:first-child { margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,.08); color: #fff; font-weight: 800; }
.score-tooltip i { font-style: normal; }
.score-tooltip b { color: #fff; font-size: 14px; }
.vip-soon { color: #777984; font-size: 12px; font-weight: 700; }
.actions-cell { width: 68px; text-align: right; }
.delete-rating { display: inline-grid; width: 36px; height: 36px; padding: 0; place-items: center; border: 1px solid rgba(238,104,115,.28); border-radius: 9px; color: #d98c95; background: rgba(238,104,115,.06); cursor: pointer; }
.delete-rating svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.delete-rating:hover { color: #fff; border-color: rgba(238,104,115,.6); background: rgba(238,104,115,.16); }
.empty-row td { height: 180px; color: #777984; text-align: center; }

@media (max-width: 640px) {
  .app { width: min(100% - 20px,520px); gap: 10px; padding: 10px 0; }
  .header { grid-template-columns: 70px minmax(0,1fr) auto; gap: 8px; min-height: 46px; }
  .logo { width: 74px; height: 42px; }
  .search-field { height: 48px; padding: 0 13px; border-radius: 12px; }
  .search-field input { font-size: 13px; }
  .library-link { height: 42px; padding: 0 9px; justify-content: center; font-size: 9px; }
  .library-link span { min-width: 20px; }
  .header-actions { gap: 5px; }
  .header-actions .back-link { max-width: 72px; line-height: 1.15; text-align: right; white-space: normal; }
  .selected { grid-template-columns: 72px minmax(0,1fr); min-height: 116px; gap: 11px; padding: 8px; border-radius: 14px; }
  .poster { width: 72px; height: 104px; border-radius: 7px; }
  .title-block h1 { font-size: 18px; }
  .title-block > p { margin: 3px 0 6px; font-size: 10px; }
  .meta span { padding: 3px 5px; font-size: 8px; }
  .meta span:last-child { display: none; }
  .title-block .description { margin-top: 6px; font-size: 10px; line-height: 1.4; -webkit-line-clamp: 2; }
  .episode-picker { min-height: 38px; padding: 4px 8px; }
  .episode-picker { gap: 5px; }
  .episode-picker label { font-size: 9px; }
  .episode-picker select { min-width: 58px; width: 58px; padding: 0 18px 0 8px; }
  .season-button { padding: 0 8px; font-size: 8px; }
  .episode-picker #episodeHint { display: none; }
  .shiki, .simero-score { width: 72px; min-width: 72px; min-height: 54px; margin-right: 6px; padding: 8px; }
  .shiki strong, .simero-score strong { font-size: 20px; }
  .shiki small, .simero-score small { font-size: 7px; }
  .ratings-grid { gap: 7px; }
  .rating-panel { min-height: 62px; padding: 7px 11px; border-radius: 11px; }
  .criterion label { font-size: 13px; }
  .criterion output { font-size: 18px; }
  .total { min-height: 64px; padding: 4px 2px; }
  .total button { padding: 8px 9px; }
  .confirm-button span { display: none; }
  .confirm-button { width: 48px; min-width: 48px; justify-content: center; }
  .confirm-button[data-mode="link"] { width: auto; min-width: 48px; }
  .confirm-button[data-mode="link"] span { display: inline; }
  .save-status { margin-top: -7px; }
  .library-header { grid-template-columns: 70px minmax(0,1fr) auto; gap: 9px; }
  .library-title { font-size: 22px; }
  .back-link { font-size: 9px; }
}

.library-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.telegram-login { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 18px; border: 1px solid rgba(255,255,255,.24); border-radius: 14px; color: #fff; background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 1px rgba(255,255,255,.025); font-size: 12px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.telegram-login:hover { border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.11); }
.telegram-login.primary { background: #fff; color: #101116; }
.login-card { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; width: min(460px, calc(100% - 32px)); margin: 12vh auto 0; padding: 38px; border: 1px solid rgba(255,255,255,.12); border-radius: 28px; background: rgba(15,16,23,.86); box-shadow: 0 24px 80px rgba(0,0,0,.4); text-align: center; }
.login-card h1 { margin: 18px 0 8px; font-size: 27px; }
.login-card p { margin: 0 0 26px; color: #aeb0ba; line-height: 1.6; }
.quiet-link { margin-top: 18px; color: #8f929e; font-size: 12px; text-decoration: none; }
.share-result { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 4px; padding: 14px; border: 1px solid rgba(116,224,156,.22); border-radius: 16px; background: rgba(79,186,119,.08); }
.share-result[hidden] { display: none; }
.share-result strong { width: 100%; color: #8ee0ab; }
.share-result a { min-width: 0; overflow: hidden; color: #fff; text-overflow: ellipsis; white-space: nowrap; }
.share-result button { margin-left: auto; }
@media (max-width: 700px) {
  .library-header { grid-template-columns: 70px minmax(0,1fr); grid-template-areas: "logo actions" "title title"; row-gap: 8px; }
  .library-header .logo { grid-area: logo; }
  .library-title { grid-area: title; }
  .library-actions { grid-area: actions; flex-direction: row; align-items: center; justify-self: end; gap: 5px; }
  .telegram-login { min-height: 34px; padding: 0 10px; font-size: 10px; }
}

@media (max-height: 610px) {
  .app { gap: 8px; padding: 7px 0; }
  .header { min-height: 44px; }
  .logo { height: 44px; }
  .search-field { height: 44px; }
  .rating-panel { min-height: 57px; padding-top: 6px; padding-bottom: 6px; }
  .total { min-height: 54px; }
  .simero-score { padding-top: 7px; padding-bottom: 7px; }
}
