/* ========== 2026 unified account surface ========== */

:root {
    --auth-bg: var(--ph-product-bg, var(--ph-bg, #f3f6f4));
    --auth-surface: var(--ph-surface, #fff);
    --auth-ink: var(--ph-product-ink, var(--ph-ink, #132b27));
    --auth-muted: var(--ph-product-muted, var(--ph-ink-secondary, #536b66));
    --auth-line: var(--ph-product-line, var(--ph-line, rgba(24, 76, 69, .12)));
    --auth-accent: var(--ph-product-accent, var(--ph-chrome-accent, #0f766e));
    --auth-accent-hover: var(--ph-product-accent-hover, var(--ph-chrome-accent-hover, #0b625c));
    --auth-accent-soft: var(--ph-product-accent-soft, var(--ph-chrome-accent-soft, #e8f6f3));
    --auth-halo: var(--ph-product-halo, var(--ph-accent-halo, rgba(80, 178, 160, .14)));
    --auth-brand-filter: var(--ph-product-brand-filter, var(--ph-brand-mark-filter, none));
    --auth-radius-control: var(--ph-radius-control, 10px);
    --auth-radius-panel: var(--ph-radius-panel, 22px);
    --auth-shadow-overlay: var(--ph-shadow-overlay, 0 24px 70px rgba(7, 29, 25, .18));
    --auth-motion-fast: var(--ph-motion-fast, 140ms);
    --auth-motion-panel: var(--ph-motion-panel, 220ms);
    --auth-motion-ease: var(--ph-motion-ease, cubic-bezier(.2, .8, .2, 1));
}

html[data-theme="ocean"] {
    --auth-bg: #f3f6fb; --auth-ink: #14243a; --auth-muted: #52657d;
    --auth-line: rgba(29, 78, 140, .13); --auth-accent: #2563eb;
    --auth-accent-hover: #1d4ed8; --auth-accent-soft: #eaf2ff;
    --auth-halo: rgba(71, 132, 238, .14);
    --auth-brand-filter: hue-rotate(55deg) saturate(1.28) brightness(1.02);
}

html[data-theme="rose"] {
    --auth-bg: #f8f4f5; --auth-ink: #321f28; --auth-muted: #735967;
    --auth-line: rgba(110, 44, 68, .13); --auth-accent: #b94d72;
    --auth-accent-hover: #9e3d60; --auth-accent-soft: #faeaf0;
    --auth-halo: rgba(211, 93, 134, .13);
    --auth-brand-filter: hue-rotate(165deg) saturate(.9) brightness(1.04);
}

html[data-theme="iris"] {
    --auth-bg: #f5f4fa; --auth-ink: #25223c; --auth-muted: #625e7b;
    --auth-line: rgba(77, 64, 137, .13); --auth-accent: #6757c8;
    --auth-accent-hover: #5546ad; --auth-accent-soft: #efedff;
    --auth-halo: rgba(123, 104, 214, .14);
    --auth-brand-filter: hue-rotate(82deg) saturate(.92) brightness(1.02);
}

body.auth-required,
body.auth-dialog-open { overflow: hidden; }

body.auth-required .main-content {
    filter: blur(8px);
    pointer-events: none;
    user-select: none;
}

body.auth-required .content-grid { pointer-events: none; }

.auth-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 28% 18%, color-mix(in srgb, var(--auth-accent) 20%, transparent), transparent 30%),
        radial-gradient(circle at 76% 78%, var(--auth-halo), transparent 34%),
        rgba(5, 18, 16, .72);
    -webkit-backdrop-filter: blur(26px) saturate(1.08);
    backdrop-filter: blur(26px) saturate(1.08);
    animation: auth-overlay-in var(--auth-motion-panel) ease both;
}

@keyframes auth-overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.auth-modal-container {
    position: relative;
    width: min(452px, 100%);
    max-height: calc(100svh - 48px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 24px;
    border: 1px solid color-mix(in srgb, var(--auth-line) 72%, #fff);
    border-radius: var(--auth-radius-panel);
    background:
        linear-gradient(150deg, rgba(255, 255, 255, .97), color-mix(in srgb, var(--auth-bg) 84%, #fff)),
        var(--auth-surface);
    color: var(--auth-ink);
    box-shadow: var(--auth-shadow-overlay), inset 0 1px rgba(255, 255, 255, .88);
    animation: auth-surface-in 340ms var(--auth-motion-ease) both;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--auth-accent) 22%, transparent) transparent;
}

.auth-modal-container[data-active-tab="register"] {
    height: min(772px, calc(100svh - 48px));
}

@keyframes auth-surface-in {
    from { opacity: 0; transform: translateY(8px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 2;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--auth-line);
    border-radius: var(--auth-radius-control);
    background: color-mix(in srgb, var(--auth-bg) 72%, #fff);
    color: var(--auth-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: color var(--auth-motion-fast) ease, background-color var(--auth-motion-fast) ease, border-color var(--auth-motion-fast) ease, transform var(--auth-motion-fast) ease;
}

.auth-modal-close:hover,
.auth-modal-close:focus-visible {
    outline: 0;
    border-color: color-mix(in srgb, var(--auth-accent) 26%, transparent);
    background: var(--auth-accent-soft);
    color: var(--auth-accent-hover);
    transform: translateY(-1px);
}

.auth-modal-close:focus-visible,
.auth-tab:focus-visible,
.auth-password-toggle:focus-visible,
.auth-submit-btn:focus-visible {
    outline: 2px solid var(--auth-accent);
    outline-offset: 2px;
}

.auth-modal-brand {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 40px;
    margin-right: 44px;
}

.auth-brand-mark.app-nav-mark,
.auth-brand-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 12px;
    background: url("../assets/brand/physicshub-mark.svg?v=20260827-zyh-final-v2") center / cover no-repeat;
    box-shadow: 0 9px 24px color-mix(in srgb, var(--auth-accent) 20%, transparent), inset 0 0 0 1px rgba(255, 255, 255, .2);
    filter: var(--auth-brand-filter);
    transition: filter var(--auth-motion-panel) var(--auth-motion-ease);
}

.auth-brand-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
    line-height: 1.2;
}

.auth-brand-copy strong {
    color: var(--auth-ink);
    font-size: 15px;
    font-weight: 750;
    letter-spacing: -.02em;
}

.auth-brand-copy small {
    overflow: hidden;
    color: var(--auth-muted);
    font-size: 9.5px;
    font-weight: 560;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-modal-context {
    margin: 16px 0 0;
    padding: 11px 13px;
    border: 1px solid color-mix(in srgb, var(--auth-accent) 13%, transparent);
    border-radius: 13px;
    background: color-mix(in srgb, var(--auth-accent-soft) 78%, #fff);
}

.auth-modal-context[hidden] { display: none; }
.auth-modal-context strong { display: block; color: var(--auth-ink); font-size: 12px; }
.auth-modal-context p { margin: 4px 0 0; color: var(--auth-muted); font-size: 10.5px; line-height: 1.5; }

.auth-tabs {
    display: flex;
    gap: 4px;
    margin: 20px 0 18px;
    padding: 4px;
    border: 1px solid var(--auth-line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--auth-bg) 72%, #fff);
}

.auth-tab {
    position: relative;
    flex: 1;
    min-height: 38px;
    padding: 8px 14px;
    border: 0;
    border-radius: var(--auth-radius-control);
    background: transparent;
    color: var(--auth-muted);
    font-size: 12px;
    font-weight: 680;
    white-space: nowrap;
    cursor: pointer;
    transition: color var(--auth-motion-fast) ease, background-color var(--auth-motion-fast) ease, box-shadow var(--auth-motion-fast) ease;
}

.auth-tab:hover { color: var(--auth-accent-hover); background: color-mix(in srgb, var(--auth-accent-soft) 64%, transparent); }
.auth-tab.active {
    color: var(--auth-accent-hover);
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 5px 14px color-mix(in srgb, var(--auth-accent) 9%, transparent), inset 0 1px rgba(255, 255, 255, .8);
}

.auth-form { display: none; }
.auth-form.active { display: block; animation: auth-form-in 180ms ease both; }

@keyframes auth-form-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-input-group { margin-bottom: 13px; }
.auth-input-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--auth-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .025em;
}
.auth-input-group small {
    display: block; margin-top: 5px; color: var(--auth-muted); font-size: 10px; line-height: 1.45;
}
.auth-registration-path {
    width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
    margin: 1px 0 13px; padding: 4px; border: 1px solid var(--auth-line);
    border-radius: 13px; background: color-mix(in srgb, var(--auth-bg) 70%, #fff);
}
.auth-registration-path .ph-segment {
    min-width: 0; min-height: 36px; padding: 7px 9px; border: 0; border-radius: 9px;
    background: transparent; color: var(--auth-muted); font-size: 11px; font-weight: 700;
    cursor: pointer;
}
.auth-registration-path .ph-segment.is-active {
    background: #fff; color: var(--auth-accent-hover);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--auth-accent) 10%, transparent);
}

.auth-input-group input,
.auth-input-group select,
.auth-input-group textarea {
    width: 100%;
    min-height: 46px;
    padding: 10px 13px;
    border: 1px solid var(--auth-line);
    border-radius: 12px;
    background: color-mix(in srgb, var(--auth-bg) 58%, #fff);
    color: var(--auth-ink);
    font: 13px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", sans-serif;
    box-shadow: inset 0 1px 2px rgba(13, 54, 48, .025);
    transition: border-color var(--auth-motion-fast) ease, background-color var(--auth-motion-fast) ease, box-shadow var(--auth-motion-fast) ease;
}

.auth-input-group select { cursor: pointer; }
.auth-input-group textarea { min-height: 84px; resize: vertical; }
.auth-input-group input::placeholder,
.auth-input-group textarea::placeholder { color: color-mix(in srgb, var(--auth-muted) 62%, #fff); }

.auth-input-group input:hover,
.auth-input-group select:hover,
.auth-input-group textarea:hover {
    border-color: color-mix(in srgb, var(--auth-accent) 23%, transparent);
    background: #fff;
}

.auth-input-group input:focus,
.auth-input-group select:focus,
.auth-input-group textarea:focus {
    outline: 0;
    border-color: color-mix(in srgb, var(--auth-accent) 52%, #fff);
    background: #fff;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--auth-accent) 11%, transparent);
}

.auth-password-wrapper { position: relative; display: flex; align-items: center; }
.auth-password-wrapper input { padding-right: 58px; }
.auth-password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    min-width: 43px;
    padding: 6px 7px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--auth-muted);
    font-size: 9px;
    font-weight: 720;
    cursor: pointer;
    transform: translateY(-50%);
}

.auth-password-toggle:hover { background: var(--auth-accent-soft); color: var(--auth-accent-hover); }

.auth-notice {
    margin-bottom: 13px;
    padding: 10px 12px;
    border: 1px solid rgba(59, 111, 182, .12);
    border-left: 2px solid rgba(59, 111, 182, .52);
    border-radius: 10px;
    background: rgba(237, 242, 250, .82);
    color: #536a94;
    font-size: 10px;
    line-height: 1.5;
}

.auth-submit-btn {
    width: 100%;
    min-height: 46px;
    padding: 10px 16px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(145deg, var(--auth-accent-hover), var(--auth-accent));
    color: #fff;
    font-size: 12px;
    font-weight: 720;
    cursor: pointer;
    box-shadow: 0 10px 22px color-mix(in srgb, var(--auth-accent) 20%, transparent), inset 0 1px rgba(255, 255, 255, .14);
    transition: transform var(--auth-motion-fast) ease, box-shadow var(--auth-motion-fast) ease;
}

.auth-submit-btn:hover { transform: translateY(-1px); box-shadow: 0 13px 26px color-mix(in srgb, var(--auth-accent) 26%, transparent), inset 0 1px rgba(255, 255, 255, .14); }
.auth-submit-btn:active { transform: translateY(0); }

.auth-message {
    display: none;
    margin-top: 11px;
    padding: 10px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.4;
    text-align: center;
}

.auth-message.success { display: block; background: #d1fae5; color: #065f46; }
.auth-message.error { display: block; background: #fee2e2; color: #991b1b; }

/* Lightweight fallback account entry for routes that do not mount AppHeader. */
#authBtn { display: flex; align-items: center; gap: 8px; }
.login-link,
.user-profile-link {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 13px;
    border: 1px solid color-mix(in srgb, var(--auth-accent) 18%, transparent);
    border-radius: var(--auth-radius-control);
    background: var(--auth-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform var(--auth-motion-fast) ease, background-color var(--auth-motion-fast) ease, box-shadow var(--auth-motion-fast) ease;
}

.login-link:hover,
.user-profile-link:hover { background: var(--auth-accent-hover); transform: translateY(-1px); box-shadow: 0 7px 18px color-mix(in srgb, var(--auth-accent) 18%, transparent); }
.user-menu-container { display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 28px; height: 28px; display: grid; place-items: center; overflow: hidden; border-radius: 9px; background: var(--auth-accent); color: #fff; font-size: 16px; }
.user-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.user-name { max-width: 100px; overflow: hidden; color: inherit; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.admin-link { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--auth-line); border-radius: var(--auth-radius-control); background: color-mix(in srgb, var(--auth-bg) 70%, #fff); color: var(--auth-accent-hover); text-decoration: none; }
.admin-link:hover { background: var(--auth-accent-soft); }
#userInfo { display: none; }
#authOverlay { animation: auth-overlay-in var(--auth-motion-panel) ease; }

@media (max-width: 480px) {
    .auth-modal-overlay { align-items: flex-end; padding: 12px 10px 0; }
    .auth-modal-container {
        width: 100%;
        max-height: calc(100svh - 12px);
        padding: 21px 17px max(20px, env(safe-area-inset-bottom, 0px));
        border-radius: var(--auth-radius-panel) var(--auth-radius-panel) 0 0;
        box-shadow: 0 -18px 60px rgba(0, 13, 11, .28), inset 0 1px rgba(255, 255, 255, .88);
    }
    .auth-modal-container[data-active-tab="register"] { height: min(680px, calc(100svh - 12px)); }
    .auth-modal-brand { margin-right: 42px; }
    .auth-modal-close { top: 17px; right: 15px; }
    .auth-tabs { margin: 18px 0 16px; }
    .auth-tab { min-height: 42px; padding: 9px 10px; }
    .auth-input-group input,
    .auth-input-group select,
    .auth-input-group textarea { min-height: 48px; padding: 10px 12px; font-size: 16px; }
    .auth-input-group textarea { min-height: 84px; }
    .auth-submit-btn { min-height: 48px; font-size: 14px; }
    .user-name { display: none; }
}

@media (max-width: 360px) {
    .auth-modal-container { padding-right: 14px; padding-left: 14px; }
    .auth-brand-copy small { max-width: 170px; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-modal-overlay,
    .auth-modal-container,
    .auth-form.active { animation: none !important; }
}

/* Forced-login overlay remains separate from the focused account sheet. */
@media (max-width: 480px) {
    #authOverlay > div { padding: 12px !important; }
    #authOverlayContent { max-width: 100% !important; padding: 28px 20px !important; }
    #authOverlayContent h2 { font-size: 18px !important; }
    #authOverlayContent p { font-size: 13px !important; }
}
