/* Edison UI system: home + auth pages */

:root {
    --bg-page: #f5f5f5;
    --bg-grid: rgba(0, 0, 0, 0.04);
    --surface: rgba(255, 255, 255, 0.82);
    --surface-strong: #ffffff;
    --surface-soft: #f4f6fb;

    --text-primary: #0a0a0a;
    --text-secondary: #525252;
    --text-muted: #737373;

    --accent: #1269f2;
    --accent-strong: #0b4dc7;
    --accent-soft: #e7efff;
    --danger: #cc3d31;
    --success: #2f8f4e;

    --border-soft: rgba(18, 74, 166, 0.14);
    --border-strong: rgba(12, 56, 126, 0.26);

    --shadow-sm: 0 8px 18px rgba(16, 30, 56, 0.08);
    --shadow-md: 0 18px 36px rgba(16, 30, 56, 0.14);
    --shadow-lg: 0 26px 70px rgba(16, 30, 56, 0.18);

    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 28px;

    --ease-fluid: cubic-bezier(0.22, 1, 0.36, 1);

    /* Backward-compatible aliases for inline styles in index.html */
    --accent-primary: var(--accent);
    --accent-success: var(--success);
    --accent-destructive: var(--danger);
    --bg-surface: var(--surface-strong);
    --bg-surface-hover: var(--surface-soft);
    --text-tertiary: var(--text-muted);
    --border-subtle: var(--border-soft);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

html,
body {
    min-height: 100%;
}

body {
    font-family: "Share Tech Mono", "IBM Plex Mono", "Noto Sans SC", monospace;
    color: var(--text-primary);
    background: linear-gradient(180deg, #fafafa 0%, var(--bg-page) 100%);
    background-attachment: fixed;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 38px 38px;
    mask-image: radial-gradient(circle at 50% 10%, black 0 45%, transparent 85%);
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    border: none;
    background: none;
    font-family: inherit;
    color: inherit;
}

/* Home layout */
.app-container {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 26px 0 30px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    padding: 12px 14px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    background: var(--surface);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-sm);
    animation: liftIn 640ms var(--ease-fluid);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-logo {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    object-fit: cover;
    border: 1px solid rgba(15, 28, 44, 0.16);
    box-shadow: 0 4px 10px rgba(14, 28, 44, 0.12);
    filter: grayscale(1) contrast(1.08);
}

.brand-word {
    font-size: 16px;
    letter-spacing: 0.14em;
    font-weight: 800;
    color: #111;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-user-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.s9-navdeck .nav-user-row {
    justify-content: flex-end;
}

.credits-badge {
    background: #eef3ff;
    border: 1px solid #d7e0ec;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 12px;
    color: #50627e;
    font-weight: 700;
}

.user-name {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}

.btn-login,
.btn-logout {
    border-radius: 999px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: transform 180ms var(--ease-fluid), box-shadow 180ms var(--ease-fluid), background 180ms var(--ease-fluid);
}

.btn-login {
    background: linear-gradient(135deg, var(--accent), #2f80ff);
    color: #fff;
    box-shadow: 0 10px 20px rgba(18, 105, 242, 0.28);
}

.btn-login:hover {
    transform: translateY(-1px);
}

.btn-logout {
    background: #f0f4fc;
    color: var(--text-secondary);
}

.btn-logout:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.main-content {
    flex: 1;
}

.hero-section {
    text-align: center;
    margin-bottom: 20px;
    animation: liftIn 760ms var(--ease-fluid) 120ms both;
}

.hero-title {
    font-size: clamp(34px, 6vw, 58px);
    line-height: 1.05;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
    color: #11253f;
}

.hero-subtitle {
    font-size: clamp(16px, 2.4vw, 22px);
    color: var(--text-secondary);
}

.quick-panels {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.quick-card {
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: var(--shadow-sm);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    animation: liftIn 460ms var(--ease-fluid);
}

.quick-card h3 {
    font-size: 15px;
    margin-bottom: 2px;
    letter-spacing: 0.01em;
}

.quick-card p {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.quick-card-btn {
    border-radius: 999px;
    border: none;
    padding: 10px 14px;
    background: linear-gradient(135deg, var(--accent), #2f80ff);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    box-shadow: 0 8px 16px rgba(18, 105, 242, 0.24);
    cursor: pointer;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.tool-card {
    position: relative;
    border-radius: 22px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
    padding: 22px 20px;
    cursor: pointer;
    overflow: hidden;
    transition: transform 220ms var(--ease-fluid), box-shadow 220ms var(--ease-fluid), border-color 220ms var(--ease-fluid);
    animation: tileIn 620ms var(--ease-fluid) both;
}

.tool-card:nth-child(1) {
    animation-delay: 120ms;
}

.tool-card:nth-child(2) {
    animation-delay: 180ms;
}

.tool-card:nth-child(3) {
    animation-delay: 240ms;
}

.tool-card:nth-child(4) {
    animation-delay: 300ms;
}

.tool-card:nth-child(5) {
    animation-delay: 360ms;
}

.tool-card:nth-child(6) {
    animation-delay: 420ms;
}

.tool-card:nth-child(7) {
    animation-delay: 480ms;
}

.tool-card:nth-child(8) {
    animation-delay: 540ms;
}

.tool-card:nth-child(9) {
    animation-delay: 600ms;
}

.tool-card::before {
    content: "";
    position: absolute;
    inset: -70% 56% auto -40%;
    height: 180px;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.04), transparent 70%);
    pointer-events: none;
    transition: transform 300ms var(--ease-fluid), opacity 300ms var(--ease-fluid);
}

.tool-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

.tool-card:hover::before {
    transform: translateX(16px);
    opacity: 0.95;
}

.tool-icon {
    font-size: 34px;
    margin-bottom: 8px;
}

.tool-name {
    font-size: 19px;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.tool-desc {
    font-size: 14px;
    color: var(--text-secondary);
}

.tool-arrow {
    position: absolute;
    top: 18px;
    right: 18px;
    color: var(--text-muted);
    transform: translateX(-8px);
    opacity: 0;
    transition: all 220ms var(--ease-fluid);
}

.tool-card:hover .tool-arrow {
    transform: translateX(0);
    opacity: 1;
}

.is-mobile-device .navbar {
    position: sticky;
    top: calc(env(safe-area-inset-top, 0px) + 6px);
    z-index: 120;
}

.is-mobile-device .tool-card:active {
    transform: scale(0.992);
    transition-duration: 80ms;
}

.mobile-app-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    z-index: 9000;
    display: flex;
    gap: 10px;
    padding: 10px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border-soft);
    box-shadow: 0 16px 26px rgba(12, 30, 54, 0.18);
    backdrop-filter: blur(10px);
}

.mobile-app-bar button {
    flex: 1;
    border: none;
    border-radius: 999px;
    padding: 11px 10px;
    font-weight: 700;
    font-size: 13px;
    background: linear-gradient(135deg, var(--accent), #2f80ff);
    color: #fff;
}

.mobile-app-bar button.secondary {
    background: #eff3fa;
    color: var(--text-secondary);
}

.footer {
    margin-top: auto;
    border-top: 1px solid var(--border-soft);
    padding-top: 18px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.footer-contact {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.wechat-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

#download-apk-footer {
    display: inline-block;
    margin-left: 2px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(18, 105, 242, 0.24);
    background: #eef3ff;
    color: #2b4e8d;
    font-size: 12px;
    font-weight: 700;
}

#download-apk-footer:hover {
    background: #e5edff;
}

.is-standalone-app #download-apk-footer {
    display: none;
}

.is-embedded-webview #download-apk-footer {
    display: none;
}

.webview-limited-note {
    margin: 10px auto 0;
    width: min(720px, 100%);
    border: 1px solid rgba(18, 58, 112, 0.16);
    border-radius: 12px;
    background: rgba(243, 247, 255, 0.86);
    padding: 10px 12px;
    text-align: left;
}

.webview-limited-note p {
    margin: 0 0 8px;
    font-size: 12px;
    color: #4f6078;
}

.webview-limited-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

#webview-url-text {
    display: inline-block;
    padding: 6px 9px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #d4deee;
    color: #2f486f;
    font-size: 12px;
    word-break: break-all;
}

#copy-web-url-btn {
    border: none;
    border-radius: 999px;
    padding: 7px 11px;
    background: #e7efff;
    color: #2f4f86;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.is-embedded-webview .webview-limited-note {
    display: block !important;
}

/* Settings */
.settings-panel {
    position: fixed;
    inset: 0;
    background: rgba(11, 26, 52, 0.34);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
    z-index: 1200;
    display: grid;
    place-items: center;
}

.settings-panel.active {
    opacity: 1;
    pointer-events: auto;
}

.settings-content {
    width: min(560px, calc(100% - 30px));
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    border-radius: 22px;
    border: 1px solid var(--border-soft);
    background: var(--surface-strong);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    transform: translateY(10px) scale(0.98);
    transition: transform 220ms var(--ease-fluid);
}

.settings-panel.active .settings-content {
    transform: translateY(0) scale(1);
}

.settings-content h3 {
    font-size: 24px;
    margin-bottom: 12px;
}

.settings-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-md);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: transform 220ms var(--ease-fluid);
}

.settings-btn:hover {
    transform: rotate(55deg) scale(1.03);
}

.btn-close {
    margin-top: 16px;
    width: 100%;
    padding: 11px 16px;
    border-radius: 12px;
    background: #f0f4fc;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 180ms ease, transform 180ms ease;
}

.btn-close:hover {
    background: #e7eefb;
    transform: translateY(-1px);
}

/* Inputs and shared controls */
input {
    width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 15px;
    color: var(--text-primary);
    background: #fff;
    outline: none;
    transition: border-color 200ms ease, box-shadow 200ms ease;
}

input:focus {
    border-color: rgba(18, 105, 242, 0.5);
    box-shadow: 0 0 0 3px rgba(18, 105, 242, 0.14);
}

/* Auth pages */
.auth-container {
    min-height: 100vh;
    width: min(980px, calc(100% - 28px));
    margin: 0 auto;
    display: grid;
    place-items: center;
    padding: 36px 0;
}

.auth-card {
    width: min(540px, 100%);
    border-radius: 26px;
    border: 1px solid var(--border-soft);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(16px);
    padding: 30px 30px 24px;
    animation: liftIn 720ms var(--ease-fluid) both;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: "";
    position: absolute;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    right: -170px;
    top: -240px;
    background: radial-gradient(circle, rgba(18, 105, 242, 0.2), transparent 68%);
    pointer-events: none;
}

.auth-card h1 {
    margin-bottom: 20px;
    font-size: clamp(30px, 4vw, 44px);
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 700;
}

.btn-primary {
    width: 100%;
    margin-top: 6px;
    padding: 13px 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), #2f80ff);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform 180ms var(--ease-fluid), box-shadow 180ms var(--ease-fluid), opacity 180ms ease;
    box-shadow: 0 10px 20px rgba(18, 105, 242, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.form-error {
    margin: 8px 0 12px;
    border: 1px solid rgba(204, 61, 49, 0.24);
    background: rgba(204, 61, 49, 0.08);
    color: var(--danger);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 700;
}

.auth-link {
    margin-top: 14px;
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-link a {
    color: var(--accent-strong);
    font-weight: 700;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Motion */
@keyframes liftIn {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tileIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive */
@media (max-width: 880px) {
    .app-container {
        width: min(1180px, calc(100% - 14px));
        padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
    }

    .navbar {
        margin-bottom: 18px;
        padding: 12px;
        border-radius: 20px;
        display: grid;
        gap: 10px;
        justify-content: stretch;
    }

    .nav-brand {
        width: 100%;
    }

    .s9-navdeck .nav-user-row {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .s9-navdeck .s9-holo-user {
        width: 100%;
        min-width: 0;
    }

    .s9-navdeck .btn-logout {
        width: 100%;
        text-align: center;
    }

    .brand-logo {
        width: 28px;
        height: 28px;
        border-radius: 8px;
    }

    .brand-word {
        font-size: 14px;
        letter-spacing: 0.12em;
    }

    .nav-user {
        width: 100%;
    }

    .nav-user-row {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "credits user"
            "logout logout";
        gap: 8px;
        align-items: center;
    }

    .credits-badge {
        grid-area: credits;
        width: fit-content;
    }

    .user-name {
        grid-area: user;
        justify-self: end;
    }

    .btn-logout {
        grid-area: logout;
        width: 100%;
        text-align: center;
        padding: 11px 12px;
    }

    .hero-section {
        margin: 10px 2px 14px;
        text-align: left;
    }

    .hero-subtitle {
        font-size: 16px;
    }

    .tools-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 74px;
    }

    .tool-card {
        border-radius: 18px;
        padding: 14px 14px;
        display: grid;
        grid-template-columns: 52px 1fr auto;
        align-items: center;
        gap: 12px;
        min-height: 96px;
    }

    .tool-card::before {
        inset: -42% 70% auto -38%;
        height: 130px;
    }

    .tool-icon {
        width: 52px;
        height: 52px;
        border-radius: 13px;
        margin: 0;
        font-size: 27px;
        background: #eef3fc;
        display: grid;
        place-items: center;
    }

    .tool-name {
        font-size: clamp(16px, 4.4vw, 22px);
        margin: 0 0 2px;
        line-height: 1.05;
    }

    .tool-desc {
        font-size: 13px;
        margin: 0;
    }

    .tool-arrow {
        position: static;
        transform: none;
        opacity: 1;
        font-size: 18px;
        color: #7a8ca8;
    }

    .quick-card {
        border-radius: 16px;
        padding: 12px 13px;
        gap: 10px;
    }

    .quick-card h3 {
        font-size: 14px;
    }

    .quick-card p {
        font-size: 12px;
    }

    .quick-card-btn {
        padding: 9px 12px;
        font-size: 12px;
    }

    .footer {
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 64px);
    }

    .settings-btn {
        right: 14px;
        bottom: 14px;
    }

    .auth-card {
        padding: 22px 18px 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}
