:root {
    color-scheme: dark;
    --ink: #121212;
    --night: #171719;
    --paper: #f2eedf;
    --paper-deep: #ded7c2;
    --red: #ef4b3f;
    --blue: #244c78;
    --muted: #8f8c83;
    --line: rgba(242, 238, 223, .2);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--night); }
body { margin: 0; min-height: 100vh; overflow-x: hidden; color: var(--paper); font-family: Arial, "Helvetica Neue", sans-serif; background: var(--night); }
body::before { content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .24; background-image: radial-gradient(rgba(255,255,255,.25) .55px, transparent .7px); background-size: 5px 5px; }
button, input { font: inherit; }
button, a { color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.topbar { position: relative; z-index: 20; max-width: 1540px; height: 82px; margin: auto; padding: 0 38px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid var(--line); }
.brand { justify-self: start; display: flex; align-items: center; gap: 13px; color: var(--paper); text-decoration: none; font: 800 20px/1 Arial, sans-serif; letter-spacing: -.04em; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; color: var(--paper); background: var(--red); font-family: "Yu Mincho", "MS Mincho", serif; font-size: 24px; }
.brand small { display: block; margin-top: 5px; color: #99978f; font: 500 9px/1 Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase; }
nav { display: flex; gap: 30px; }
.nav-button { position: relative; padding: 11px 0; border: 0; background: none; color: #8d8b84; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.nav-button.active { color: var(--paper); }
.nav-button.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: 3px; height: 2px; background: var(--red); }
.profile-pill { justify-self: end; display: flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; color: #aaa79d; font-size: 12px; }
.profile-pill span { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid #77746d; border-radius: 50%; color: var(--paper); font-weight: 700; }

main { position: relative; z-index: 1; max-width: 1540px; margin: auto; padding: 40px 38px 60px; }

.onboarding { position: relative; min-height: calc(100vh - 165px); display: grid; grid-template-columns: 118px minmax(380px, 1.25fr) minmax(350px, .75fr); align-items: center; gap: clamp(34px, 5vw, 90px); overflow: hidden; border-bottom: 1px solid var(--line); }
.edition-rail { align-self: stretch; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; border-right: 1px solid var(--line); }
.edition-rail span { writing-mode: vertical-rl; color: var(--paper); font: 400 72px/1 "Yu Mincho", "MS Mincho", serif; letter-spacing: .12em; }
.edition-rail small { writing-mode: vertical-rl; color: #737169; font-size: 8px; font-weight: 700; letter-spacing: .28em; }
.intro-copy { position: relative; z-index: 2; padding: 40px 0; }
.kicker, .section-label { color: var(--red); font-size: 9px; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; }
.kicker { display: flex; align-items: center; gap: 13px; margin: 0 0 34px; }
.kicker i { display: block; width: 34px; height: 1px; background: var(--red); }
h1, h2, h3 { margin: 0; }
.intro-copy h1 { max-width: 760px; font: 400 clamp(64px, 7.3vw, 118px)/.82 Georgia, "Times New Roman", serif; letter-spacing: -.075em; }
.intro-copy h1 em { color: var(--red); font-weight: 400; }
.lead { max-width: 580px; margin: 36px 0 0 8px; color: #aaa79f; font: 400 16px/1.7 Georgia, serif; }
.margin-notes { display: flex; flex-wrap: wrap; gap: 10px 24px; margin: 48px 0 0 8px; color: #85827b; font: italic 12px Georgia, serif; }
.margin-notes span { display: flex; gap: 8px; align-items: center; }
.margin-notes b { color: var(--paper); font: 700 9px Arial, sans-serif; }

.connect-card { position: relative; z-index: 3; align-self: center; padding: 34px; color: var(--ink); background: var(--paper); box-shadow: 14px 14px 0 #080808; transform: rotate(.6deg); }
.connect-card::before { content: ''; position: absolute; inset: 10px; pointer-events: none; border: 1px solid rgba(18,18,18,.16); }
.card-index { position: relative; display: flex; justify-content: space-between; align-items: center; padding-bottom: 18px; border-bottom: 1px solid #aaa697; color: #777268; font-size: 8px; font-weight: 800; letter-spacing: .18em; }
.card-index b { color: var(--red); font: 400 28px/1 Georgia, serif; }
.connect-card h2 { position: relative; max-width: 340px; margin-top: 34px; font: 400 40px/1.02 Georgia, serif; letter-spacing: -.045em; }
.connect-card > p:not(.privacy) { position: relative; margin: 16px 0 26px; color: #6d685e; font: 14px/1.55 Georgia, serif; }
.local-account-form { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; }
.local-account-form label { color: #6d685f; font-size: 8px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.local-account-form input { min-width: 0; height: 40px; padding: 0 3px; border: 0; border-bottom: 1px solid #8f8a7e; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }
.local-account-form input:focus { border-bottom-color: var(--red); }
.account-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1.4fr .6fr; gap: 8px; margin-top: 8px; }
.account-actions button { min-height: 44px; border: 1px solid var(--ink); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.local-create { color: var(--paper); background: var(--ink); }
.local-create:hover { background: var(--red); border-color: var(--red); }
.local-login { color: var(--ink); background: transparent; }
.local-login:hover { color: var(--red); border-color: var(--red); }
.form-error { grid-column: 1 / -1; min-height: 13px; margin: 0 !important; color: var(--red) !important; font: 9px/1.3 Arial, sans-serif !important; }
.anilist-button { position: relative; display: flex; justify-content: space-between; align-items: center; min-height: 54px; padding: 0 18px; color: var(--paper); background: var(--ink); text-decoration: none; font-size: 12px; font-weight: 800; letter-spacing: .05em; }
.anilist-button:hover { background: var(--red); }
.anilist-button span { font-size: 19px; }
.or { position: relative; display: flex; align-items: center; gap: 10px; margin: 24px 0 18px; color: #8b877c; font-size: 9px; text-transform: uppercase; letter-spacing: .13em; }
.or::before, .or::after { content: ''; height: 1px; flex: 1; background: #c7c1af; }
.connect-form { position: relative; }
.connect-form label { display: block; margin-bottom: 7px; color: #6d685f; font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.input-row { display: flex; align-items: center; min-height: 52px; border-bottom: 2px solid var(--ink); }
.input-row > span { color: var(--red); font-weight: 700; }
.input-row input { flex: 1; min-width: 100px; padding: 0 10px; border: 0; outline: 0; color: var(--ink); background: transparent; }
.input-row button { align-self: stretch; width: 48px; border: 0; color: var(--paper); background: var(--red); font-size: 22px; }
.privacy { position: relative; margin: 20px 0 0 !important; color: #979286 !important; font: 10px/1.4 Arial, sans-serif !important; }
.red-sun { position: absolute; right: -170px; top: -170px; width: 430px; height: 430px; display: grid; place-items: center; border-radius: 50%; color: rgba(18,18,18,.2); background: var(--red); font: 400 150px/1 "Yu Mincho", "MS Mincho", serif; }

.app-shell { display: grid; grid-template-columns: minmax(230px, 280px) minmax(520px, 1fr) minmax(230px, 280px); gap: clamp(22px, 2.6vw, 42px); align-items: start; }
.sheet { color: var(--ink); background-color: var(--paper); background-image: repeating-linear-gradient(0deg, transparent 0 27px, rgba(18,18,18,.055) 28px); box-shadow: 9px 9px 0 #080808; }
.mood-panel, .pulse-panel { position: sticky; top: 20px; min-height: 610px; padding: 27px; }
.section-label { display: flex; align-items: center; justify-content: space-between; }
.section-label b { color: #89857a; font-size: 8px; letter-spacing: .08em; }
.mood-panel h2, .pulse-panel h2 { margin-top: 25px; font: 400 31px/1.05 Georgia, serif; letter-spacing: -.04em; }
.mood-panel > p, .pulse-panel > p { margin: 14px 0 30px; color: #6f6b62; font: italic 12px/1.5 Georgia, serif; }
.mood-control { margin: 25px 0; }
.mood-control > div { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; color: #8b877d; font: italic 9px Georgia, serif; }
.mood-control span:last-child { text-align: right; }
.mood-control strong { color: var(--ink); font: 800 9px Arial, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
input[type='range'] { appearance: none; width: 100%; height: 2px; margin-top: 14px; outline: 0; background: #aaa697; }
input[type='range']::-webkit-slider-thumb { appearance: none; width: 13px; height: 13px; border: 2px solid var(--paper); border-radius: 50%; background: var(--red); box-shadow: 0 0 0 1px var(--ink); }
.primary { border: 0; color: var(--paper); background: var(--ink); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.primary:hover { background: var(--red); }
.full { width: 100%; min-height: 48px; margin-top: 8px; }
.learn-card { display: flex; align-items: center; gap: 12px; margin-top: 20px; padding-top: 18px; border-top: 1px solid #aaa697; }
.learn-card > span { display: grid; place-items: center; width: 34px; height: 34px; color: var(--paper); background: var(--red); font-family: "Yu Mincho", serif; }
.learn-card b, .learn-card small { display: block; }
.learn-card b { font: 400 15px Georgia, serif; }
.learn-card small { margin-top: 3px; color: #817d73; font-size: 8px; line-height: 1.4; }

.deck-column { min-width: 0; }
.deck-heading { min-height: 74px; display: flex; align-items: start; justify-content: space-between; padding: 0 3px 16px; }
.deck-heading h2 { margin-top: 8px; font: italic 400 30px/1 Georgia, serif; letter-spacing: -.03em; }
.counter { display: flex; align-items: baseline; gap: 5px; color: #66645e; font: italic 11px Georgia, serif; }
.counter b { color: var(--paper); font: 400 34px/1 Georgia, serif; }
.card-stage { position: relative; height: min(67vh, 680px); min-height: 570px; perspective: 1200px; }
.anime-card, .loading-card, .empty-card { position: absolute; inset: 0; overflow: hidden; background: var(--paper); box-shadow: 11px 11px 0 #080808; }
.anime-card { z-index: 2; display: grid; grid-template-columns: 56% 44%; color: var(--ink); cursor: grab; touch-action: pan-y; transform-origin: 50% 110%; transition: transform .34s cubic-bezier(.2,.8,.2,1), opacity .25s; user-select: none; }
.anime-card.dragging { transition: none; cursor: grabbing; }
.anime-card.behind { z-index: 1; transform: translate(13px, 13px) rotate(1deg); opacity: .38; pointer-events: none; }
.anime-card.swipe-left { transform: translate(-115%, 20px) rotate(-9deg); opacity: 0; }
.anime-card.swipe-right { transform: translate(115%, 20px) rotate(9deg); opacity: 0; }
.anime-card.swipe-down { transform: translateY(80%) scale(.9); opacity: 0; }
.anime-image { grid-column: 1; width: 100%; height: 100%; object-fit: cover; }
.anime-card::after { content: ''; position: absolute; left: 56%; top: 0; bottom: 0; width: 1px; background: rgba(18,18,18,.2); }
.match-badge { position: absolute; left: 21px; top: 21px; z-index: 2; padding: 9px 11px; color: var(--paper); background: var(--red); font: 800 9px Arial, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.format-badge { position: absolute; right: 21px; top: 21px; z-index: 2; color: #706c62; font: 800 8px Arial, sans-serif; letter-spacing: .13em; text-transform: uppercase; }
.card-copy { grid-column: 2; position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; padding: 34px 28px; }
.meta { order: 1; margin-bottom: 14px; color: var(--red); font-size: 8px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.card-copy h3 { order: 2; font: 400 clamp(34px, 3.8vw, 58px)/.92 Georgia, serif; letter-spacing: -.055em; overflow-wrap: anywhere; }
.card-copy > p { order: 3; margin: 20px 0 0; color: #635f56; font: 12px/1.55 Georgia, serif; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.reasons { order: 4; display: flex; flex-wrap: wrap; gap: 0; margin-top: 23px; border-top: 1px solid #aaa697; }
.reasons span { padding: 9px 9px 0 0; color: #716d64; font: italic 9px Georgia, serif; }
.reasons span:not(:last-child)::after { content: ' /'; color: var(--red); }
.loading-card, .empty-card { display: grid; place-items: center; align-content: center; gap: 20px; padding: 38px; color: #77736a; text-align: center; }
.loading-card span { display: grid; place-items: center; width: 76px; height: 76px; border: 1px solid var(--red); border-radius: 50%; color: var(--red); font: 400 33px "Yu Mincho", serif; animation: breathe 1.3s ease-in-out infinite alternate; }
.loading-card p, .empty-card p { font: italic 14px Georgia, serif; }
.empty-card h3 { color: var(--ink); font: 400 38px Georgia, serif; }
@keyframes breathe { to { transform: scale(.88); opacity: .45; } }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 24px; border-top: 1px solid #393838; border-bottom: 1px solid #393838; }
.action { min-height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border: 0; border-right: 1px solid #393838; background: transparent; }
.action:last-child { border-right: 0; }
.action small { color: #8b8982; font-size: 8px; font-weight: 800; letter-spacing: .16em; }
.action span { color: var(--paper); font: 400 27px Georgia, serif; }
.action:hover small, .action.watch span { color: var(--red); }
.keyboard-hint { margin: 13px 0 0; color: #5f5d58; text-align: center; font: italic 9px Georgia, serif; }
kbd { padding: 1px 4px; border: 1px solid #4c4b48; color: #8f8c85; background: transparent; font-family: Arial, sans-serif; }

.taste-cloud { display: flex; flex-wrap: wrap; gap: 0; padding: 8px 0 27px; }
.taste-cloud span { --size: 1; padding: 5px 10px 5px 0; color: #656158; font: italic calc(9px + var(--size) * 3px) Georgia, serif; }
.taste-cloud span:not(:last-child)::after { content: ','; color: var(--red); }
.taste-cloud span:first-child { color: var(--ink); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid #aaa697; border-bottom: 1px solid #aaa697; }
.stat-grid article { padding: 16px 8px 16px 0; }
.stat-grid article + article { padding-left: 16px; border-left: 1px solid #aaa697; }
.stat-grid b, .stat-grid span { display: block; }
.stat-grid b { font: 400 31px/1 Georgia, serif; }
.stat-grid span { margin-top: 5px; color: #817d73; font-size: 8px; text-transform: uppercase; letter-spacing: .08em; }
.sync-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 17px; color: #827e74; font-size: 8px; }
.sync-row button { padding: 0; border: 0; border-bottom: 1px solid var(--red); color: var(--red); background: none; font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.queue { margin-top: 32px; }
.queue .section-label { margin-bottom: 15px; }
#queueList { display: grid; gap: 12px; }
#queueList p { color: #837f75; font: italic 10px/1.5 Georgia, serif; }
.queue-item { display: flex; gap: 11px; align-items: center; color: var(--ink); text-decoration: none; }
.queue-item img { width: 36px; height: 49px; object-fit: cover; filter: grayscale(.25); }
.queue-item b { display: block; font: 400 11px/1.2 Georgia, serif; }
.queue-item small { color: #8b877d; font-size: 7px; text-transform: uppercase; letter-spacing: .08em; }

.taste-mobile { padding: 26px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 25px; transform: translate(-50%, 30px); padding: 13px 18px; color: var(--paper); background: var(--red); font-size: 10px; font-weight: 800; letter-spacing: .06em; opacity: 0; pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1120px) {
    .onboarding { grid-template-columns: 90px 1fr minmax(320px, .8fr); gap: 35px; }
    .edition-rail span { font-size: 56px; }
    .app-shell { grid-template-columns: 250px 1fr; }
    .pulse-panel { display: none; }
}

@media (max-width: 760px) {
    .topbar { height: 68px; grid-template-columns: 1fr auto; padding: 0 18px; }
    nav, .brand small, .profile-pill b { display: none; }
    main { padding: 20px 16px 42px; }
    .onboarding { min-height: auto; grid-template-columns: 1fr; gap: 0; border-bottom: 0; }
    .edition-rail { min-height: 85px; flex-direction: row; justify-content: flex-start; gap: 18px; border-right: 0; border-bottom: 1px solid var(--line); }
    .edition-rail span, .edition-rail small { writing-mode: horizontal-tb; }
    .edition-rail span { font-size: 40px; }
    .intro-copy { padding: 44px 0 50px; }
    .intro-copy h1 { font-size: clamp(55px, 17vw, 82px); }
    .lead { margin-left: 0; }
    .margin-notes { display: grid; margin-left: 0; }
    .connect-card { margin-bottom: 40px; padding: 28px; box-shadow: 8px 8px 0 #080808; }
    .red-sun { width: 220px; height: 220px; right: -130px; top: 40px; font-size: 76px; }
    .app-shell { display: flex; flex-direction: column; }
    .mood-panel { position: static; width: 100%; min-height: 0; padding: 25px; }
    .deck-column { width: 100%; margin-top: 18px; }
    .deck-heading h2 { font-size: 25px; }
    .card-stage { height: 72vh; min-height: 590px; }
    .anime-card { display: block; }
    .anime-image { position: absolute; inset: 0 0 42% 0; width: 100%; height: 58%; }
    .anime-card::after { left: 0; right: 0; top: 58%; bottom: auto; width: auto; height: 1px; }
    .format-badge { color: var(--paper); text-shadow: 0 1px 5px #000; }
    .card-copy { position: absolute; inset: 58% 0 0; padding: 25px; }
    .card-copy h3 { font-size: clamp(34px, 11vw, 48px); }
    .card-copy > p { -webkit-line-clamp: 3; font-size: 11px; }
    .reasons { margin-top: 15px; }
    .actions { margin-top: 18px; }
    .action { min-height: 58px; padding: 0 12px; }
    .taste-mobile { color: var(--ink); }
}

@media (max-height: 760px) and (min-width: 761px) {
    .card-stage { min-height: 520px; height: calc(100vh - 245px); }
    .mood-panel, .pulse-panel { min-height: 540px; padding: 22px; }
    .mood-control { margin: 20px 0; }
}
