:root {
    color-scheme: dark;
    --bg: #080809;
    --surface: #111114;
    --surface-2: #17171b;
    --line: #2a292f;
    --line-strong: #454149;
    --text: #f7f5f7;
    --muted: #aaa5ad;
    --subtle: #777179;
    --red: #ff4d5f;
    --red-soft: #30161b;
    --violet: #b58aff;
    --rose: #ff829a;
    --cyan: #6cd6c9;
    --focus: #ff9ba5;
    --radius: 14px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.55; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body::before { position: fixed; z-index: 1000; inset: 0 0 auto; height: 2px; background: var(--red); content: ""; }
a, button { font: inherit; -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip-link { position: fixed; z-index: 2000; top: 8px; left: 8px; padding: 10px 14px; background: #fff; color: #111; text-decoration: none; transform: translateY(-140%); }
.skip-link:focus { transform: translateY(0); }

.site-header { position: relative; z-index: 100; border-bottom: 1px solid #242326; background: rgba(8,8,9,.93); backdrop-filter: blur(16px); }
.header-inner, main, .site-footer { width: min(1120px, calc(100% - 56px)); margin: 0 auto; }
.header-inner { min-height: 74px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; }
.brand { width: max-content; display: inline-flex; align-items: center; text-decoration: none; }
.brand img { width: 142px; height: auto; display: block; }
.header-inner nav { display: flex; align-items: center; gap: 28px; }
.header-inner nav a { color: var(--muted); font-size: 13px; font-weight: 650; text-decoration: none; transition: color 140ms ease; }
.header-inner nav a:hover { color: var(--text); }

.auth-shell { position: relative; justify-self: end; }
.auth-button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 700; cursor: pointer; transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease; }
.auth-button:hover { border-color: #69636c; background: var(--surface-2); transform: translateY(-1px); }
.auth-button:disabled, .google-login:disabled { cursor: wait; opacity: .72; }
.google-mark { width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 50%; background: #f7f7f7; color: #4285f4; font: 800 12px/1 Arial, sans-serif; }
.auth-chevron { color: var(--subtle); font-size: 14px; transition: transform 150ms ease; }
.auth-button[aria-expanded="true"] .auth-chevron { transform: rotate(180deg); }
.account-menu { position: absolute; top: calc(100% + 10px); right: 0; width: 276px; padding: 8px; border: 1px solid var(--line-strong); border-radius: 12px; background: #151518; box-shadow: 0 24px 60px rgba(0,0,0,.46); }
.account-summary { display: flex; align-items: center; gap: 11px; padding: 11px 10px 14px; border-bottom: 1px solid var(--line); }
.account-summary > span:last-child { min-width: 0; display: grid; }
.account-summary strong, .account-summary small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-summary strong { font-size: 13px; }
.account-summary small { margin-top: 2px; color: var(--subtle); font-size: 11px; }
.account-initial { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--red-soft); color: var(--red); font-weight: 800; }
.account-menu a, .account-menu button { width: 100%; min-height: 40px; display: flex; align-items: center; justify-content: space-between; margin-top: 4px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; text-align: left; text-decoration: none; cursor: pointer; }
.account-menu a:hover, .account-menu button:hover { background: #202024; color: var(--text); }

.history-hero { max-width: 790px; padding: 82px 0 68px; }
.eyebrow { display: flex; align-items: center; gap: 9px; margin: 0 0 18px; color: var(--red); font-size: 11px; font-weight: 780; letter-spacing: .09em; text-transform: uppercase; }
.eyebrow span { width: 22px; height: 2px; background: currentColor; }
.history-hero h1 { margin: 0; font-size: clamp(54px, 7vw, 82px); font-weight: 770; letter-spacing: -.06em; line-height: 1; }
.history-hero > p:last-child { max-width: 680px; margin: 26px 0 0; color: var(--muted); font-size: 16px; line-height: 1.75; word-break: keep-all; }

.loading-state { padding: 4px 0 100px; }
.loading-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; color: var(--muted); }
.loading-head span { font-size: 13px; font-weight: 700; }
.loading-head small { color: var(--subtle); font-size: 11px; }
.skeleton-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.skeleton-card { height: 274px; display: grid; align-content: start; gap: 15px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.skeleton-card i, .skeleton-card b, .skeleton-card em { display: block; border-radius: 4px; background: linear-gradient(90deg,#1b1a1f 20%,#26242a 50%,#1b1a1f 80%); background-size: 220% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton-card i { width: 38px; height: 12px; margin-bottom: 36px; }
.skeleton-card b { width: 58%; height: 24px; }
.skeleton-card b + b { width: 88%; height: 12px; }
.skeleton-card em { width: 100%; height: 42px; margin-top: auto; }
@keyframes shimmer { to { background-position: -220% 0; } }

.signed-out-state { display: grid; grid-template-columns: minmax(0, .92fr) minmax(410px, .78fr); gap: 80px; align-items: stretch; padding: 0 0 110px; }
.signed-out-copy { padding: 42px; border: 1px solid #5d3037; border-radius: var(--radius); background: var(--red-soft); }
.state-number { margin: 0 0 22px; color: var(--red); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.signed-out-copy h2, .error-state h2 { margin: 0; font-size: clamp(42px, 5vw, 60px); font-weight: 760; letter-spacing: -.055em; line-height: 1.04; }
.signed-out-copy > p:not(.state-number) { max-width: 520px; margin: 25px 0 0; color: #c8b9bc; font-size: 14px; line-height: 1.8; word-break: keep-all; }
.google-login { width: 100%; min-height: 54px; display: flex; align-items: center; gap: 10px; margin-top: 28px; padding: 0 16px; border: 1px solid #fff; border-radius: 8px; background: #fff; color: #171316; font-size: 13px; font-weight: 800; cursor: pointer; transition: transform 150ms ease, background-color 150ms ease; }
.google-login b { margin-left: auto; }
.google-login:hover { background: #f5f1f2; transform: translateY(-2px); }
.signed-out-copy > small { display: block; margin-top: 10px; color: #95777c; font-size: 10px; }
.privacy-card { padding: 34px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.privacy-card > p { margin: 0 0 20px; color: var(--subtle); font-size: 11px; font-weight: 760; }
.privacy-card ul { margin: 0; padding: 0; border-top: 1px solid var(--line); list-style: none; }
.privacy-card li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 21px 0; border-bottom: 1px solid var(--line); }
.privacy-card li > span { color: var(--red); font-size: 10px; font-weight: 800; }
.privacy-card li div { display: grid; gap: 4px; }
.privacy-card strong { font-size: 14px; }
.privacy-card small { color: var(--muted); font-size: 12px; line-height: 1.65; }

.history-dashboard { padding: 0 0 100px; }
.dashboard-topline { display: flex; align-items: end; justify-content: space-between; gap: 30px; padding-bottom: 30px; border-bottom: 1px solid var(--line); }
.dashboard-topline h2 { margin: 0; font-size: clamp(34px, 4.5vw, 52px); font-weight: 750; letter-spacing: -.05em; }
.new-test-link { min-height: 44px; display: inline-flex; align-items: center; gap: 34px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--text); font-size: 12px; font-weight: 720; text-decoration: none; transition: border-color 150ms ease, background-color 150ms ease; }
.new-test-link:hover { border-color: var(--red); background: var(--red-soft); }
.summary-grid { display: grid; grid-template-columns: .7fr .7fr 1.6fr; border-bottom: 1px solid var(--line); }
.summary-grid article { min-height: 128px; display: flex; align-items: baseline; gap: 7px; padding: 28px; border-left: 1px solid var(--line); }
.summary-grid article:first-child { border-left: 0; }
.summary-grid article > span { display: block; align-self: flex-start; margin-right: auto; color: var(--subtle); font-size: 11px; }
.summary-grid strong { align-self: flex-end; font-size: 43px; font-weight: 720; letter-spacing: -.04em; line-height: 1; }
.summary-grid small { align-self: flex-end; color: var(--subtle); font-size: 11px; }
.summary-grid .latest-summary { align-items: flex-end; flex-wrap: wrap; }
.latest-summary > span { flex: 0 0 100%; }
.latest-summary strong { font-size: 24px; }
.latest-summary small { margin-left: auto; }

.archive-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 38px 0 20px; }
.filter-tabs { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-tabs button { min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--subtle); font-size: 11px; font-weight: 700; cursor: pointer; transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease; }
.filter-tabs button:hover { border-color: var(--line-strong); color: var(--text); }
.filter-tabs button.is-active { border-color: #61313a; background: var(--red-soft); color: var(--red); }
.filter-tabs button span { margin-left: 3px; font-variant-numeric: tabular-nums; }
.archive-toolbar > p { margin: 0; color: var(--subtle); font-size: 11px; }

.records-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.record-card { --tone: var(--red); --tone-soft: var(--red-soft); position: relative; min-height: 298px; display: flex; flex-direction: column; overflow: hidden; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: border-color 170ms ease, background-color 170ms ease, transform 190ms ease, box-shadow 170ms ease; }
.record-card::before { position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--tone); content: ""; opacity: .65; }
.record-card[data-type="FETISH"] { --tone: var(--violet); --tone-soft: #271d34; }
.record-card[data-type="LOVE"] { --tone: var(--rose); --tone-soft: #311a21; }
.record-card[data-type="SEXUALITY"] { --tone: var(--cyan); --tone-soft: #142a28; }
.record-card[data-type="SAJU_BDSM"] { --tone: #f1c56f; --tone-soft: #302719; }
.record-card:hover { border-color: #4d4850; background: var(--surface-2); transform: translateY(-3px); box-shadow: 0 20px 46px rgba(0,0,0,.22); }
.record-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.record-type { color: var(--tone); font-size: 10px; font-weight: 800; letter-spacing: .07em; }
.record-date { color: var(--subtle); font-size: 10px; font-variant-numeric: tabular-nums; }
.record-main { flex: 1; padding: 28px 0 22px; }
.record-main > span { color: var(--subtle); font-size: 10px; }
.record-main h3 { margin: 7px 0 5px; font-size: 31px; font-weight: 730; letter-spacing: -.045em; }
.record-main > p { margin: 0; color: var(--muted); font-size: 12px; }
.mini-scores { display: grid; gap: 9px; margin-top: 25px; }
.mini-score { display: grid; grid-template-columns: minmax(60px,auto) 1fr 30px; align-items: center; gap: 9px; color: var(--muted); font-size: 10px; }
.mini-score span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-score i { height: 3px; overflow: hidden; background: #2b2930; }
.mini-score i::after { width: var(--score); height: 100%; display: block; background: var(--tone); content: ""; }
.mini-score b { color: var(--tone); font-size: 10px; font-variant-numeric: tabular-nums; text-align: right; }
.record-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 17px; border-top: 1px solid var(--line); }
.record-foot > span { color: var(--subtle); font-size: 10px; }
.record-foot button { display: inline-flex; align-items: center; gap: 20px; padding: 7px 0 7px 10px; border: 0; background: transparent; color: var(--text); font-size: 11px; font-weight: 720; cursor: pointer; }
.record-foot button b { color: var(--tone); font-size: 15px; transition: transform 150ms ease; }
.record-foot button:hover b { transform: translateX(3px); }

.empty-history { min-height: 330px; display: flex; align-items: flex-start; flex-direction: column; justify-content: center; padding: 48px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.empty-glyph { color: var(--red); font-size: 30px; }
.empty-history .state-number { margin: 22px 0 10px; }
.empty-history h3 { margin: 0; font-size: 31px; font-weight: 730; letter-spacing: -.04em; }
.empty-history > p:not(.state-number) { max-width: 530px; margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.75; }
.empty-history a { min-height: 43px; display: inline-flex; align-items: center; gap: 36px; margin-top: 26px; padding: 0 13px; border: 1px solid var(--red); border-radius: 7px; background: var(--red); color: #160507; font-size: 12px; font-weight: 800; text-decoration: none; }
.empty-filter { min-height: 160px; display: grid; place-items: center; align-content: center; gap: 14px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted); font-size: 13px; text-align: center; }
.empty-filter p { margin: 0; }
.empty-filter button { border: 0; border-bottom: 1px solid var(--line-strong); background: transparent; color: var(--text); font-size: 12px; cursor: pointer; }

.error-state { margin-bottom: 100px; padding: 42px; border: 1px solid #5d3037; border-radius: var(--radius); background: var(--red-soft); }
.error-state > p:not(.state-number) { margin: 15px 0 0; color: #c8b9bc; font-size: 13px; }
.error-state button { min-height: 42px; margin-top: 24px; padding: 0 14px; border: 1px solid #88515a; border-radius: 7px; background: transparent; font-size: 12px; font-weight: 720; cursor: pointer; }
.history-guide { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 30px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.history-guide p { margin: 0; padding: 22px 24px; color: var(--subtle); font-size: 11px; line-height: 1.7; }
.history-guide p + p { border-left: 1px solid var(--line); }
.history-guide strong { color: var(--muted); }

.site-footer { min-height: 130px; display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-top: 70px; border-top: 1px solid var(--line); }
.footer-brand img { width: 126px; }
.site-footer > div { display: flex; align-items: center; gap: 22px; color: var(--subtle); font-size: 11px; }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: var(--text); }

.record-dialog { --dialog-tone: var(--red); width: min(560px, calc(100% - 32px)); max-height: min(760px, calc(100dvh - 32px)); padding: 0; overflow: auto; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #121216; color: var(--text); box-shadow: 0 34px 100px rgba(0,0,0,.65); }
.record-dialog[data-type="FETISH"] { --dialog-tone: var(--violet); }
.record-dialog[data-type="LOVE"] { --dialog-tone: var(--rose); }
.record-dialog[data-type="SEXUALITY"] { --dialog-tone: var(--cyan); }
.record-dialog[data-type="SAJU_BDSM"] { --dialog-tone: #f1c56f; }
.record-dialog::backdrop { background: rgba(0,0,0,.77); backdrop-filter: blur(5px); }
.dialog-head { position: sticky; z-index: 2; top: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 24px; border-bottom: 1px solid var(--line); background: #121216; }
.dialog-head p { margin: 0 0 5px; color: var(--dialog-tone); font-size: 10px; font-weight: 780; }
.dialog-head h2 { margin: 0; font-size: 25px; letter-spacing: -.04em; }
.dialog-head button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--muted); font-size: 20px; cursor: pointer; }
.dialog-primary { position: relative; display: grid; padding: 28px 24px; border-bottom: 1px solid var(--line); }
.dialog-primary span { color: var(--subtle); font-size: 10px; }
.dialog-primary strong { margin-top: 5px; font-size: 34px; letter-spacing: -.04em; }
.dialog-primary b { position: absolute; right: 24px; bottom: 27px; color: var(--dialog-tone); font-size: 27px; }
.dialog-scores { display: grid; gap: 17px; padding: 25px 24px; }
.dialog-score { display: grid; grid-template-columns: minmax(82px,auto) 1fr 36px; align-items: center; gap: 12px; font-size: 11px; }
.dialog-score span { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.dialog-score i { height: 4px; overflow: hidden; background: #29272e; }
.dialog-score i::after { width: var(--score); height: 100%; display: block; background: var(--dialog-tone); content: ""; }
.dialog-score b { color: var(--dialog-tone); font-size: 11px; text-align: right; }
.dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 24px; border-top: 1px solid var(--line); }
.dialog-foot p { margin: 0; color: var(--subtle); font-size: 10px; }
.dialog-foot button { min-height: 40px; padding: 0 12px; border: 1px solid var(--red); border-radius: 7px; background: var(--red); color: #160507; font-size: 11px; font-weight: 800; cursor: pointer; }
.toast { position: fixed; z-index: 500; right: 24px; bottom: 24px; max-width: min(360px, calc(100vw - 32px)); padding: 13px 16px; border: 1px solid var(--line-strong); border-radius: 9px; background: #1a191d; color: var(--text); box-shadow: 0 18px 50px rgba(0,0,0,.4); font-size: 12px; }

@media (max-width: 880px) {
    .header-inner { grid-template-columns: 1fr auto; }
    .header-inner nav { display: none; }
    .signed-out-state { grid-template-columns: 1fr; gap: 12px; }
    .records-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .header-inner, main, .site-footer { width: min(100% - 32px, 1120px); }
    .header-inner { min-height: 66px; gap: 12px; }
    .brand img { width: 116px; }
    .auth-button { min-height: 38px; padding: 0 11px; }
    .auth-button #authLabel { max-width: 122px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .auth-chevron { display: none; }
    .account-menu { position: fixed; top: 70px; right: 16px; left: 16px; width: auto; }
    .history-hero { padding: 60px 0 48px; }
    .history-hero h1 { font-size: clamp(49px, 14vw, 64px); }
    .history-hero > p:last-child { font-size: 14px; }
    .skeleton-grid { grid-template-columns: 1fr; }
    .skeleton-card:nth-child(2) { display: none; }
    .signed-out-state { padding-bottom: 78px; }
    .signed-out-copy, .privacy-card { padding: 28px 23px; }
    .signed-out-copy h2 { font-size: 43px; }
    .dashboard-topline { align-items: flex-start; flex-direction: column; }
    .new-test-link { width: 100%; justify-content: space-between; }
    .summary-grid { grid-template-columns: 1fr 1fr; }
    .summary-grid article { min-height: 106px; padding: 18px; }
    .summary-grid .latest-summary { grid-column: 1 / -1; border-top: 1px solid var(--line); border-left: 0; }
    .summary-grid strong { font-size: 36px; }
    .latest-summary strong { font-size: 22px; }
    .archive-toolbar { align-items: flex-start; flex-direction: column; padding-top: 28px; }
    .filter-tabs { flex-wrap: nowrap; width: calc(100vw - 16px); margin-left: -8px; padding: 4px 8px 9px; overflow-x: auto; scrollbar-width: none; }
    .filter-tabs::-webkit-scrollbar { display: none; }
    .filter-tabs button { flex: 0 0 auto; }
    .archive-toolbar > p { align-self: flex-end; }
    .record-card { min-height: 288px; padding: 22px; }
    .record-main h3 { font-size: 28px; }
    .empty-history { padding: 34px 24px; }
    .history-guide { grid-template-columns: 1fr; }
    .history-guide p + p { border-top: 1px solid var(--line); border-left: 0; }
    .site-footer { min-height: 160px; align-items: flex-start; flex-direction: column; justify-content: center; }
    .site-footer > div { flex-wrap: wrap; gap: 12px 18px; }
    .record-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); }
    .dialog-foot { align-items: stretch; flex-direction: column; }
    .dialog-foot button { width: 100%; }
    .toast { right: 16px; bottom: 16px; left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
