:root {
    --bg: #0d0906;
    --bg-soft: #17100b;
    --card: rgba(31, 20, 13, 0.88);
    --card-solid: #1f140d;
    --text: #fff7ef;
    --muted: #c7b4a7;
    --line: rgba(255, 132, 61, 0.22);
    --accent: #f27a32;
    --accent-soft: rgba(242, 122, 50, 0.14);
    --accent-strong: #ffb36b;
    --buy: #6aa875;
    --buy-hover: #579263;
    --danger: #d95a4f;
    --danger-soft: rgba(217, 90, 79, .14);
    --danger-line: rgba(217, 90, 79, .35);
    --shadow: 0 24px 80px rgba(0, 0, 0, .38);
    --radius-xl: 30px;
    --radius-lg: 22px;
}

.theme-light {
    --bg: #fbf6ef;
    --bg-soft: #f4eadf;
    --card: #ffffff;
    --card-solid: #ffffff;
    --text: #28180f;
    --muted: #735f51;
    --line: rgba(120, 62, 28, 0.16);
    --accent: #df6d2b;
    --accent-soft: rgba(223, 109, 43, 0.13);
    --accent-strong: #b84f18;
    --shadow: 0 18px 60px rgba(55, 31, 17, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 20% -10%, rgba(242, 122, 50, .18), transparent 34rem),
        radial-gradient(circle at 90% 10%, rgba(255, 179, 107, .10), transparent 28rem),
        var(--bg);
    line-height: 1.65;
}

body.modal-open { overflow: hidden; }

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }

.site-shell,
.page { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 26px 0 56px; }
.site-header,.site-footer,.legal-site-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.site-header,.legal-site-header { margin-bottom: 22px; }
.site-header-balanced { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.site-header-brand { justify-self: start; }
.site-header-nav { justify-self: center; }
.site-header-account { justify-self: end; display: flex; align-items: center; gap: 10px; }
.site-logout-form { margin: 0; }
.site-logout-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--danger-line); background: var(--danger-soft); color: #ffb8ae; font-weight: 900; cursor: pointer; transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease; }
.site-logout-button:hover { background: rgba(217, 90, 79, .22); border-color: rgba(217, 90, 79, .58); color: #ffd0c9; transform: translateY(-1px); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); font-weight: 950; letter-spacing: .06em; }
.brand:hover { text-decoration: none; }
.brand-avatar { width: 58px; height: 58px; flex: 0 0 58px; border-radius: 999px; object-fit: cover; filter: drop-shadow(0 0 22px rgba(242, 122, 50, .34)); }
.brand-text { font-size: 18px; }
.site-nav { display: flex; flex-wrap: wrap; gap: 10px; }
.site-login-link { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--text); font-weight: 900; }
.site-login-link:hover { text-decoration: none; border-color: rgba(255, 132, 61, .48); }

.site-nav a,.button-link,.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--accent-soft); color: var(--text); font-weight: 800; cursor: pointer; }
.site-nav a:hover,.button-link:hover,.btn:hover { text-decoration: none; border-color: rgba(255, 132, 61, .48); }
.primary,.button-link.primary,.btn.primary,.hero-actions .btn:first-child:not(.buy) { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); color: #160b05; border-color: transparent; box-shadow: 0 16px 38px rgba(242, 122, 50, .20); }
.btn.buy,.button-link.buy { background: linear-gradient(135deg, var(--buy), #8bc093); color: #081109; border-color: transparent; box-shadow: 0 16px 34px rgba(106, 168, 117, .20); }
.btn.buy:hover,.button-link.buy:hover { background: linear-gradient(135deg, var(--buy-hover), #78ad82); }
.btn.disabled,.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn.ready { filter: saturate(1.12); }

.hero,.help-header,.legal-hero { position: relative; overflow: hidden; padding: clamp(26px, 5vw, 56px); border: 1px solid var(--line); border-radius: var(--radius-xl); background: linear-gradient(135deg, rgba(242, 122, 50, .13), transparent 42%), var(--card); color: var(--text); box-shadow: var(--shadow); }
.hero:after,.help-header:after,.legal-hero:after { content: ""; position: absolute; width: 280px; height: 280px; right: -120px; top: -110px; border: 18px solid rgba(242, 122, 50, .16); border-radius: 50%; }
.hero > *,.help-header > *,.legal-hero > * { position: relative; z-index: 1; }
.hero h1,.help-header h1,.legal-hero h1 { margin: 0 0 12px; color: var(--text); font-size: clamp(32px, 6vw, 64px); line-height: 1.02; letter-spacing: -.04em; }
.hero p,.help-header p,.legal-hero p { margin: 0; max-width: 780px; color: var(--muted); font-size: 18px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.hero-with-mascot { min-height: 380px; display: grid; align-items: center; background-image: linear-gradient(90deg, rgba(13, 9, 6, .96) 0%, rgba(13, 9, 6, .84) 42%, rgba(13, 9, 6, .18) 100%), url('/static/public/img/friendly-hero-banner.png'); background-size: cover; background-position: center right; background-repeat: no-repeat; }
.hero-with-mascot:after { display: none; }
.hero-with-mascot .hero-content { max-width: 620px; }
.hero-with-mascot h1 { font-size: clamp(42px, 7vw, 76px); }
.hero-with-mascot p { max-width: 620px; }
.eyebrow,.pill { display: inline-flex; padding: 7px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 13px; font-weight: 800; }

.help-nav,.platform-grid,.steps,.legal-layout,.grid,.shop-grid,.shop-form-card,.account-grid,.flow-grid,.info-grid,.faq-section,.section-heading { margin-top: 22px; }
.help-nav { display: flex; flex-wrap: wrap; gap: 10px; }
.platform-grid,.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; align-items: stretch; }
.flow-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.section-heading h2,.faq-section h2 { margin: 0 0 6px; font-size: clamp(26px, 4vw, 38px); }
.section-heading p { margin: 0; color: var(--muted); }
.flow-card { border: 1px solid var(--line); border-radius: 20px; background: rgba(31,20,13,.72); padding: 18px; }
.flow-card span { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-weight: 950; }
.flow-card h2 { margin: 12px 0 6px; font-size: 18px; }
.flow-card p { margin: 0; color: var(--muted); }
.clean-list { margin: 0; padding-left: 20px; color: var(--muted); }
.clean-list li { margin: 7px 0; }
.faq-list { display: grid; gap: 10px; }
.faq-list details { border: 1px solid var(--line); border-radius: 18px; background: var(--card); padding: 16px 18px; }
.faq-list summary { cursor: pointer; font-weight: 900; color: var(--text); }
.faq-list p { color: var(--muted); margin: 10px 0 0; }

.platform-card,.plan-card { display: flex; flex-direction: column; min-height: 190px; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.platform-card .button-link,.plan-card .button-link { align-self: flex-start; margin-top: auto; }
.plan-card:hover { transform: translateY(-3px); border-color: rgba(255, 132, 61, .46); box-shadow: 0 24px 70px rgba(0,0,0,.22); }

.card,.step-card,.notice,.legal-doc,.legal-card,.doc,.toc,.plan-card,.shop-form-card,.key-card,.public-flash { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card); box-shadow: 0 18px 50px rgba(0,0,0,.12); padding: 20px; }
.auth-card-public { margin-top: 22px; max-width: 640px; padding: clamp(22px, 4vw, 34px); background: linear-gradient(135deg, rgba(242, 122, 50, .10), rgba(255,255,255,.03)), var(--card); }
.auth-card-public .shop-form { max-width: none; }
.auth-secondary-actions { justify-content: flex-start; }
.card h2,.step-card h2,.notice h2,.toc h2,.plan-card h2 { margin-top: 0; }
.card p,.step-card p,.notice p,.legal-doc p,.legal-doc li,.doc p,.doc li,.plan-card p,.shop-form-card p { color: var(--muted); }
.notice { background: var(--accent-soft); }
.steps { display: grid; gap: 14px; }
.tariff-summary { margin-top: 22px; }
.plan-price { font-size: 34px; font-weight: 950; margin: 8px 0; color: var(--text); }
.plan-meta { margin: 0 0 14px; color: var(--muted); }

.shop-form { display: grid; gap: 14px; max-width: 620px; }
.form-field { display: grid; gap: 7px; color: var(--text); font-weight: 800; }
.form-field input,.form-field select,.account-actions select,.inline-form select { width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(0, 0, 0, .18); color: var(--text); font-size: 16px; outline: none; }
.form-field input:focus,.form-field select:focus,.account-actions select:focus,.inline-form select:focus { border-color: rgba(255, 179, 107, .62); box-shadow: 0 0 0 4px rgba(242, 122, 50, .13); }
.form-checkbox { display: flex; align-items: flex-start; gap: 10px; color: var(--muted); }
.form-checkbox input { margin-top: 7px; accent-color: var(--buy); }
.field-hint { color: var(--muted); font-weight: 600; }
.field-hint.error { color: #ffb1a2; }

.buy-modal { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; padding: 24px; }
.buy-modal.open { display: flex; }
.buy-modal-backdrop { position: absolute; inset: 0; background: rgba(8, 5, 3, .72); backdrop-filter: blur(10px); }
.buy-modal-dialog { position: relative; width: min(720px, 100%); max-height: min(90vh, 820px); overflow: auto; border: 1px solid rgba(255, 132, 61, .30); border-radius: 30px; background: radial-gradient(circle at 14% 0%, rgba(242, 122, 50, .20), transparent 28rem), rgba(25, 15, 9, .98); box-shadow: 0 30px 100px rgba(0,0,0,.58); padding: clamp(22px, 4vw, 34px); animation: modalIn .18s ease-out; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.buy-modal-close { position: absolute; top: 16px; right: 16px; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.06); color: var(--text); font-size: 28px; line-height: 1; cursor: pointer; }
.buy-modal-head { padding-right: 42px; }
.buy-modal-head h2 { margin: 12px 0 8px; font-size: clamp(28px, 4vw, 42px); line-height: 1.06; }
.buy-modal-head p { margin: 0 0 20px; color: var(--muted); }
.buy-modal-form { max-width: none; }
.modal-step { display: none; }
.modal-step-active { display: grid; gap: 14px; }
.modal-secondary-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.link-button { border: 0; background: transparent; color: var(--accent-strong); font-weight: 900; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.modal-message { min-height: 22px; margin: 2px 0 0; color: var(--muted); font-weight: 700; }
.modal-message-success { color: #a6d8ad; }
.modal-message-error { color: #ffb1a2; }

.custom-select { position: relative; }
.custom-select-trigger { width: 100%; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(135deg, rgba(255,255,255,.06), rgba(255,255,255,.025)); color: var(--text); padding: 13px 16px; text-align: left; cursor: pointer; outline: none; }
.custom-select-trigger:focus,.custom-select.open .custom-select-trigger { border-color: rgba(255, 179, 107, .66); box-shadow: 0 0 0 4px rgba(242, 122, 50, .13); }
.custom-select.selected .custom-select-value { color: var(--text); }
.custom-select-value { color: var(--muted); font-weight: 900; }
.custom-select-arrow { color: var(--accent-strong); font-size: 22px; transition: transform .18s ease; }
.custom-select.open .custom-select-arrow { transform: rotate(180deg); }
.custom-select-menu { position: absolute; left: 0; right: 0; top: calc(100% + 10px); z-index: 6; display: none; max-height: 320px; overflow-y: auto; overflow-x: hidden; padding: 10px 8px; padding-right: 12px; border: 1px solid rgba(255, 132, 61, .34); border-radius: 22px; background: linear-gradient(180deg, rgba(38, 22, 13, .99), rgba(24, 14, 9, .99)); box-shadow: 0 22px 65px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.04); backdrop-filter: blur(10px); scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: rgba(255, 167, 92, .95) rgba(255, 255, 255, .05); }
.custom-select-menu::-webkit-scrollbar { width: 10px; }
.custom-select-menu::-webkit-scrollbar-track { background: rgba(255, 255, 255, .04); border-radius: 999px; border: 1px solid rgba(255, 145, 70, .12); }
.custom-select-menu::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #ffb46b 0%, #ff8f47 100%); border-radius: 999px; border: 2px solid rgba(26, 10, 4, .95); box-shadow: 0 0 12px rgba(255, 140, 66, .25); }
.custom-select-menu::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #ffc27f 0%, #ffa257 100%); }
.custom-select-menu::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.custom-select-menu::-webkit-scrollbar-corner { background: transparent; }
.custom-select.open .custom-select-menu { display: grid; gap: 8px; }
.custom-select-option { display: grid; gap: 4px; width: 100%; border: 1px solid transparent; border-radius: 16px; background: transparent; color: var(--text); padding: 14px 16px; text-align: left; cursor: pointer; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.custom-select-option:hover { border-color: rgba(255, 132, 61, .28); background: rgba(242, 122, 50, .10); transform: translateX(2px); }
.custom-select-option[aria-selected="true"] { border-color: rgba(255, 166, 92, .32); background: rgba(242, 122, 50, .14); }
.option-title { display: block; font-weight: 950; font-size: 18px; line-height: 1.22; }
.option-meta { display: block; color: rgba(255, 235, 220, .78); font-size: 14px; }
.modal-submit { width: 100%; min-height: 52px; margin-top: 4px; }

.account-hero { margin-top: 10px; }
.account-key-list { margin-top: 22px; }
.account-key-card { display: grid; gap: 18px; }
.account-key-card h2 { margin: 0 0 4px; font-size: 24px; }
.key-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.key-secret-panel { display: grid; gap: 14px; padding: 16px; border: 1px solid rgba(255, 132, 61, .16); border-radius: 18px; background: rgba(0,0,0,.14); }
.key-secret-panel[hidden] { display: none; }
.key-qr-wrap { display: flex; align-items: center; justify-content: flex-start; }
.site-renew-form { padding-top: 14px; border-top: 1px solid var(--line); }
.renewal-card { display: grid; grid-template-columns: minmax(180px, 1.1fr) minmax(260px, 2fr) auto; gap: 16px; align-items: center; padding: 18px; border: 1px solid rgba(255, 132, 61, .22); border-radius: 22px; background: linear-gradient(135deg, rgba(242, 122, 50, .10), rgba(255,255,255,.03)); box-shadow: inset 0 1px 0 rgba(255,255,255,.035); }
.renewal-card h3 { margin: 4px 0 0; font-size: 20px; }
.renewal-card p { margin: 8px 0 0; color: var(--muted); }
.renewal-label { color: var(--accent-strong); font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.renewal-meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.renewal-meta-item { padding: 12px 14px; border: 1px solid rgba(255, 132, 61, .16); border-radius: 16px; background: rgba(0,0,0,.14); }
.renewal-meta-item span { display: block; margin-bottom: 2px; color: var(--muted); font-size: 13px; }
.renewal-meta-item strong { color: var(--text); font-size: 16px; }
.renewal-button { min-width: 130px; }
.renewal-card-muted { grid-template-columns: 1fr; opacity: .82; }
.account-empty-card { margin-top: 22px; }
.account-actions,.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.key-list { display: grid; gap: 14px; }
.key-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.key-expiry { color: #a6d8ad; font-weight: 950; }
.key-text { width: 100%; min-height: 118px; border-radius: 16px; border: 1px solid var(--line); background: rgba(0,0,0,.26); color: var(--text); padding: 14px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 13px; line-height: 1.5; }
.qr-img { width: 180px; max-width: 100%; padding: 8px; border-radius: 16px; background: #fff; }
.grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 24px; align-items: start; }
.toc { position: sticky; top: 18px; backdrop-filter: blur(10px); }
.toc h2 { margin: 0 0 12px; font-size: 16px; }
.toc ol,.toc ul { margin: 0; padding-left: 0; list-style: none; }
.toc li { margin: 8px 0; color: var(--muted); }
.toc a { color: var(--text); font-size: 14px; }
.help-screenshot { margin: 18px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 24px; background: rgba(0, 0, 0, .18); }
.help-screenshot img { display: block; width: min(100%, 420px); max-height: 760px; margin: 0 auto; border-radius: 18px; object-fit: contain; box-shadow: 0 18px 42px rgba(0, 0, 0, .28); }
.legal-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.legal-doc,.doc { background: var(--card-solid); padding: clamp(22px, 4vw, 42px); }
.legal-doc section + section,.doc section + section { margin-top: 30px; padding-top: 26px; border-top: 1px solid var(--line); }
.legal-doc h2,.doc h2 { margin: 0 0 14px; color: var(--accent-strong); font-size: clamp(22px, 3vw, 30px); line-height: 1.2; }
.legal-doc p,.doc p { margin: 0 0 12px; }
.legal-doc ul,.doc ul { margin: 10px 0 16px; padding-left: 24px; }
.legal-doc li,.doc li { margin: 7px 0; }
.site-footer,.footer { margin-top: 32px; color: var(--muted); font-size: 14px; text-align: center; }
.public-flash { margin-bottom: 16px; }
.public-flash-success { border-color: rgba(106, 168, 117, .45); }
.public-flash-danger { border-color: rgba(255, 90, 90, .45); }

@media (max-width: 920px) {
    .grid { grid-template-columns: 1fr; }
    .toc { position: static; }
    .site-header-balanced { grid-template-columns: 1fr; }
    .site-header-brand,.site-header-nav,.site-header-account { justify-self: start; }
    .renewal-card { grid-template-columns: 1fr; }
    .renewal-meta-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .renewal-button { justify-self: start; }
    .hero-with-mascot { min-height: 360px; background-image: linear-gradient(90deg, rgba(13, 9, 6, .97) 0%, rgba(13, 9, 6, .86) 58%, rgba(13, 9, 6, .48) 100%), url('/static/public/img/friendly-hero-banner.png'); background-position: 68% center; }
    .hero-with-mascot .hero-content { max-width: 560px; }
}
@media (max-width: 720px) {
    .site-shell,.page { width: min(100% - 20px, 1120px); padding-top: 14px; }
    .site-header,.site-footer,.legal-site-header { align-items: flex-start; flex-direction: column; }
    .site-header-account { justify-content: flex-start; flex-wrap: wrap; }
    .brand-avatar { width: 52px; height: 52px; flex-basis: 52px; }
    .hero,.help-header,.legal-hero,.card,.step-card,.notice,.legal-doc,.doc,.toc,.plan-card,.shop-form-card { border-radius: 18px; }
    .hero-with-mascot { min-height: 420px; align-items: end; background-image: linear-gradient(180deg, rgba(13, 9, 6, .94) 0%, rgba(13, 9, 6, .72) 46%, rgba(13, 9, 6, .92) 100%), url('/static/public/img/friendly-hero-banner.png'); background-size: cover; background-position: 64% center; }
    .hero-with-mascot .hero-content { padding-top: 120px; }
    .buy-modal { padding: 12px; align-items: flex-end; }
    .buy-modal-dialog { width: 100%; max-height: 92vh; border-radius: 24px 24px 0 0; }
}
