/* Sandcat account surfaces: standalone /login, /register and /forgot-password
 * plus the account menu and inline launch panels inside /chat/.
 * Account management uses the main site's Settings UI.
 *
 * Account entry pages load the same appearance tokens and fixed header styles
 * as Chat. This file only adds account-specific layout and controls. */

/* ========================================
   ACCOUNT MENU (inside /chat/)
   ======================================== */
.top-bar-inner {
    min-width: 0;
    box-sizing: border-box;
}

.top-bar-left {
    min-width: 0;
    flex: 1 1 auto;
}

.top-bar-left .app-title {
    min-width: 0;
    overflow: hidden;
}

.top-bar-right {
    min-width: 0;
    max-width: min(50%, 360px);
    flex: 0 1 auto;
}

body.ui-version-v2 .shell-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    max-width: none;
    flex: 0 1 auto;
}
body.ui-version-v2 .shell-panel-toggle {
    display: inline-flex;
    position: relative;
    align-items: center;
    justify-content: center;
    width: 34px;
    min-width: 34px;
    height: 32px;
    flex: none;
    padding: 4px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--ink-secondary);
    cursor: pointer;
}
body.ui-version-v2 .shell-panel-toggle svg { width: 24px; height: 24px; pointer-events: none; }
body.ui-version-v2 .shell-panel-toggle[aria-pressed=true] { color: var(--lime-default); background: var(--surface-muted); }
body.ui-version-v2 .shell-panel-toggle:focus-visible { outline: 2px solid var(--lime-default); outline-offset: -2px; }
body.ui-version-v2 .shell-panel-toggle:disabled { opacity: .45; cursor: default; }
.shell-panel-toggle[hidden],.shell-panel-indicator[hidden] { display: none!important; }
.shell-panel-indicator { position: absolute; top: 4px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--lime-default); }

body.ui-version-v2 .shell-mode-control {
    position: relative;
    display: flex;
    align-items: center;
    align-self: center;
    flex: none;
    min-width: 0;
}
body.ui-version-v2 .shell-mode-trigger {
    display: inline-flex;
    height: var(--footer-control-height);
    align-items: center;
    gap: 4px;
    padding: 0 var(--footer-control-inline-padding);
    border: 1px solid color-mix(in srgb, var(--ink-primary) 16%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
    color: var(--ink-secondary);
    font: 650 .68rem/1 var(--font-interface);
    cursor: pointer;
}
body.ui-version-v2 .shell-mode-trigger > .disclosure-caret {
    color: var(--lime-default);
}
body.ui-version-v2 .shell-mode-trigger:is(:hover, [aria-expanded='true']) {
    border-color: color-mix(in srgb, var(--lime-default) 34%, transparent);
    background: color-mix(in srgb, var(--lime-default) 10%, var(--surface-strong));
    color: var(--ink-primary);
}
body.ui-version-v2 .shell-mode-trigger:focus-visible {
    outline: 2px solid var(--lime-default);
    outline-offset: 1px;
}
body.ui-version-v2 .shell-mode-menu {
    position: fixed;
    inset: auto;
    z-index: 1500;
}
body.ui-version-v2 .shell-mode-menu:popover-open {
    display: grid;
}
/* The dim behind the open mode menu; light dismiss closes it on an outside click. */
body.ui-version-v2 .shell-mode-menu::backdrop {
    background: var(--menu-scrim, rgba(0, 0, 0, 0.73));
}


/* The account control owns the full footer band of Chat's conversations and
 * Studio's Workspace. It is not a card nested inside either panel. It is as tall
 * as the status bar beside it, so every column's footer shares one top edge
 * (user decision, 2026-11-23); a full-width row stays above the 24px minimum target. */
.account-nav {
    position: relative;
    flex: 0 0 var(--statusbar-height, 28px);
    width: 100%;
    min-width: 0;
    height: var(--statusbar-height, 28px);
    box-sizing: border-box;
    padding: 0;
    border-top: 1px solid color-mix(in srgb, var(--lime-strong) 38%, transparent);
    background: color-mix(in srgb, var(--lime-strong) 14%, var(--surface-default));
}

.account-nav[hidden],
.account-menu[hidden],
.account-menu-identity[hidden],
.account-menu-separator[hidden] {
    display: none;
}

.account-control {
    position: relative;
    height: 100%;
}

.account-control-button {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    align-items: center;
    gap: 7px;
    box-sizing: border-box;
    padding: 0 8px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ink-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.account-control-button:hover,
.account-control-button[aria-expanded='true'],
.account-control-button:focus-visible {
    background: color-mix(in srgb, var(--lime-strong) 22%, var(--surface-default));
}

.account-control-button:focus-visible .account-avatar {
    background: var(--lime-default);
    color: var(--lime-on);
}

.account-avatar {
    display: grid;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--lime-strong) 44%, transparent);
    border-radius: 50%;
    background: color-mix(in srgb, var(--lime-strong) 10%, transparent);
    color: var(--lime-default);
}

.account-avatar svg {
    width: 13px;
    height: 13px;
}

.account-control-copy {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: stretch;
    line-height: 1.1;
}

.account-control-copy strong,
.account-control-copy #accountLogin {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-control-copy strong {
    width: 100%;
    min-width: 0;
    color: var(--ink-primary);
    font-size: 0.72rem;
    font-weight: 650;
    line-height: 1.1;
}

.account-control-copy small {
    display: flex;
    width: 100%;
    min-width: 0;
    margin: 0;
    color: var(--ink-secondary);
    font-size: calc(0.61rem - 0.5pt);
    line-height: 1.1;
}

.account-control-copy #accountTags {
    flex: none;
}

.account-control-copy #accountLogin {
    min-width: 0;
    flex: 1 1 auto;
    white-space: pre;
}

.account-control-copy small[hidden] {
    display: none;
}

.account-control-chevron {
    flex: none;
    color: var(--ink-muted);
    transform: rotate(180deg);
}

/* Phones and touch screens: one point larger type and a wider gutter in the same band. */
@media (max-width: 768px), (pointer: coarse) {
    .account-control-button {
        gap: 9px;
        padding: 0 12px;
    }

    .account-avatar {
        width: 22px;
        height: 22px;
        flex-basis: 22px;
    }

    .account-avatar svg {
        width: 14px;
        height: 14px;
    }

    .account-control-copy strong {
        font-size: 0.76rem;
    }

    .account-control-copy small {
        font-size: calc(0.64rem - 0.5pt);
    }
}

body .account-nav .account-menu {
    position: absolute;
    bottom: calc(100% + 7px);
    left: 0;
    right: 0;
    z-index: 240;
    display: flex;
    flex-direction: column;
    width: auto;
    opacity: 0;
    transform: translateY(8px) scale(0.98);
    transform-origin: bottom center;
    transition: opacity 180ms ease, transform 180ms ease;
}

body .account-nav .account-menu.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.account-menu-identity {
    display: grid;
    gap: 2px;
    padding: 7px 9px 9px;
    border-bottom: 1px solid color-mix(in srgb, var(--ink-primary) 10%, transparent);
    overflow-wrap: anywhere;
}

.account-menu-identity small {
    color: var(--ink-muted);
    font-size: 0.62rem;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.account-menu-identity strong {
    color: var(--ink-primary);
    font-size: 0.78rem;
    font-weight: 600;
    min-width: 0;
    overflow-wrap: anywhere;
}

.account-menu-separator {
    height: 1px;
    margin: 3px 2px;
    background: color-mix(in srgb, var(--ink-primary) 12%, transparent);
}

.account-state {
    margin: 0;
    padding: 5px 9px;
    color: var(--ink-secondary);
    font-size: 0.72rem;
    line-height: 1.35;
}

.account-state[hidden] {
    display: none;
}

/* Account operations inherit the same modal, tabs, groups and fields as Settings. */
.account-settings-heading {
    margin: 0 0 var(--space-3);
}

.account-settings-field {
    margin-bottom: var(--space-3);
}

.account-settings-field > .setting-input {
    margin-top: var(--space-2);
}

.account-settings-field[hidden] {
    display: none;
}

.account-settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.account-settings-form {
    grid-column: 1 / -1;
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
}

.account-settings-list {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-3) 0;
    padding: 0;
    list-style: none;
}

.account-settings-list-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-1) var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.account-settings-list-main {
    display: flex;
    grid-column: 1;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2);
    overflow-wrap: anywhere;
}

.account-settings-list-primary {
    font-size: var(--settings-label-size);
}

.account-settings-list-meta,
.account-settings-badge,
.account-settings-status {
    color: var(--text-secondary);
    font-size: var(--settings-detail-size);
    overflow-wrap: anywhere;
}

.account-settings-list-meta {
    grid-column: 1;
}

.account-settings-list-item > button {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
}

.account-settings-status {
    margin: var(--space-2) 0 0;
}

.account-settings-status:empty {
    display: none;
}

.account-settings-status.is-error {
    color: var(--error);
}


/* ========================================
   STANDALONE AUTH PAGES
   ======================================== */
html.acct-standalone,
body.acct-standalone {
    margin: 0;
    background: var(--surface-canvas);
    color: var(--ink-primary);
    font-family: var(--font-interface);
    font-size: 16px;
    line-height: 1.5;
}

.acct-shell {
    padding-top: var(--topbar-height);
}

.acct-home {
    color: var(--ink-primary);
    text-decoration: none;
}

.acct-home img {
    flex: 0 0 28px;
}

.acct-standalone .acct-shell .top-bar-right {
    gap: 16px;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.acct-shell [aria-current='page'] {
    color: var(--ink-primary);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.acct-page {
    display: grid;
    width: calc(100% - 32px);
    max-width: 1040px;
    box-sizing: border-box;
    gap: 14px;
    min-height: 0;
    overflow-y: auto;
    align-content: start;
    margin: 0 auto;
    padding: clamp(24px, 4vw, 46px) 0 48px;
}

.acct-page-narrow {
    max-width: 430px;
}

.acct-section {
    display: grid;
    gap: var(--space-3, 0.75rem);
    min-width: 0;
    padding: clamp(16px, 2vw, 22px);
    border: 1px solid color-mix(in srgb, var(--ink-primary) 14%, transparent);
    border-radius: 5px;
    background: color-mix(in srgb, var(--surface-default) 94%, transparent);
}

.acct-section h2 {
    margin: 0;
    color: var(--ink-primary);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.acct-section p {
    margin: 0;
    color: var(--ink-secondary);
    font-size: 0.84rem;
    line-height: 1.55;
}

.acct-section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 16px;
}

/* ========================================
   FORMS (shared by pages and the inline panel)
   ======================================== */
.acct-panel {
    color: var(--ink-primary, #10120e);
}

.acct-card {
    display: grid;
    gap: var(--space-3, 0.75rem);
    padding: clamp(1rem, 2.5vw, 1.5rem);
    border: 1px solid var(--line-default, #ced5c7);
    border-radius: 5px;
    background: var(--surface-default, #fff);
    --busy-surface: var(--surface-default, #fff);
    max-width: 30rem;
    margin-inline: auto;
    width: 100%;
    box-sizing: border-box;
}

/* Busy overlays inside the settings modal (chat shell) match its panel color. */
.account-settings-group,
#creditsHistoryPanel,
#activityReport {
    --busy-surface: var(--bg-elevated, var(--surface-default, #fff));
}

.acct-session-dialog {
    width: min(30rem, calc(100vw - 2rem));
    max-height: calc(100dvh - 2rem);
    overflow: auto;
    border-color: var(--border-strong, var(--line-default, #aeb8a6));
    background: var(--surface-strong, #e4e0d6);
    color: var(--ink-primary, #10120e);
    box-shadow: var(--shadow-xl, 0 22px 48px rgba(16, 18, 14, 0.2));
    margin: auto;
}

.acct-session-dialog::backdrop {
    background: var(--surface-canvas, #f5f3ed);
}

.acct-update-heading {
    display: flex;
    align-items: center;
    gap: var(--space-3, 0.75rem);
    min-width: 0;
}

.acct-update-heading .acct-title {
    min-width: 0;
}

.acct-update-sparkle {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    color: var(--accent-primary, #0b7a55);
    background: color-mix(in srgb, var(--accent-primary, #0b7a55) 14%, transparent);
    font-size: 1.5rem;
}

.acct-update-builds {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.5rem;
    color: var(--ink-secondary, #4f584a);
    font-size: 0.8rem;
}

.acct-update-builds code { white-space: nowrap; }
.acct-update-sparkle[hidden], .acct-update-builds[hidden] { display: none; }

.acct-title {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.acct-copy {
    margin: 0;
    font-size: 0.9rem;
    color: var(--ink-secondary, #4f584a);
}

.acct-form {
    display: grid;
    gap: var(--space-3, 0.75rem);
}

.acct-field {
    display: grid;
    gap: 0.3rem;
}

.acct-field-group {
    display: grid;
    gap: var(--space-3, 0.75rem);
}

.acct-tab-panel {
    display: grid;
    gap: var(--space-3, 0.75rem);
}

.acct-field-group[hidden],
.acct-actions-row[hidden],
.acct-tab-panel[hidden] {
    display: none;
}

.acct-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-secondary, #4f584a);
}

.acct-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--line-default, #ced5c7);
    border-radius: 8px;
    background: var(--surface-canvas, #f7f8f5);
    color: var(--ink-primary, #10120e);
    font: inherit;
    font-size: 0.92rem;
}

.acct-input:focus-visible,
.acct-button:focus-visible,
.acct-tab:focus-visible {
    outline: 2px solid var(--focus-ring, #2563eb);
    outline-offset: 2px;
}

.acct-input[readonly] {
    color: var(--ink-muted, #6b7465);
}

.acct-hint {
    margin: 0;
    font-size: 0.78rem;
    color: var(--ink-muted, #6b7465);
}

.acct-link {
    color: var(--lime-strong, #1d4ed8);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.acct-page-nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.acct-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2, 0.5rem);
}

.acct-provider-action {
    display: grid;
    gap: var(--space-3, 0.75rem);
}

.acct-divider {
    margin: 0;
    color: var(--ink-muted, #6b7465);
    font-size: 0.78rem;
    text-align: center;
}

.acct-provider-action .acct-button {
    width: 100%;
    justify-content: center;
}

.acct-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2, 0.5rem);
}

.acct-button {
    display: inline-flex;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0.55rem 0.9rem;
    border: 1px solid var(--line-default, #ced5c7);
    border-radius: 8px;
    background: var(--surface-default, #fff);
    color: var(--ink-primary, #10120e);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}

.acct-button:hover {
    border-color: var(--ink-muted, #6b7465);
}

.acct-button[disabled] {
    opacity: 0.6;
    cursor: default;
}

.acct-button-primary {
    border-color: var(--lime-default, #2563eb);
    background: var(--lime-default, #2563eb);
    color: var(--lime-on, #fff);
}

.acct-button-primary:hover {
    background: var(--lime-strong, #1d4ed8);
    border-color: var(--lime-strong, #1d4ed8);
    color: var(--lime-strong-on, var(--lime-on, #fff));
}

.acct-button-quiet {
    border-color: transparent;
    background: transparent;
}

.acct-button-danger {
    border-color: var(--error, #b42318);
    color: var(--error, #b42318);
    background: transparent;
}

.acct-button-danger:hover {
    background: color-mix(in srgb, var(--error, #b42318) 10%, transparent);
}

.acct-status {
    margin: 0;
    min-height: 1.2em;
    font-size: 0.82rem;
    color: var(--ink-secondary, #4f584a);
}

.acct-status:empty {
    display: none;
}

.acct-notice {
    margin: 0;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--line-default, #ced5c7);
    border-radius: 8px;
    font-size: 0.82rem;
    color: var(--ink-secondary, #4f584a);
    background: var(--surface-muted, #ecefe8);
}

.acct-notice-error {
    border-color: color-mix(in srgb, var(--error, #b42318) 45%, transparent);
    background: color-mix(in srgb, var(--error, #b42318) 10%, transparent);
    color: var(--error, #b42318);
}

.acct-notice-info {
    border-color: var(--line-default, #ced5c7);
}

.acct-status.acct-notice-error {
    color: var(--error, #b42318);
}

/* ========================================
   TABS + LISTS
   ======================================== */
.acct-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-bottom: 1px solid var(--line-default, #ced5c7);
}

.acct-tab {
    padding: 0.5rem 0.7rem;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--ink-secondary, #4f584a);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
}

.acct-tab[aria-selected='true'] {
    border-bottom-color: var(--lime-default, #2563eb);
    color: var(--ink-primary, #10120e);
}

.acct-tab-body {
    padding-top: var(--space-3, 0.75rem);
}

.acct-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   LAUNCH GATE (inside /chat/)
   ======================================== */
.launch-gate {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: grid;
    place-items: center;
    padding: clamp(1rem, 4vw, 2rem);
    background: var(--surface-canvas, #f7f8f5);
    overflow: auto;
}

.launch-gate[hidden] {
    display: none;
}

.launch-gate-inner {
    width: 100%;
    max-width: 32rem;
}

.launch-gate .acct-card {
    margin-inline: auto;
}

@media (max-width: 768px) {
    .top-bar-right {
        max-width: none;
    }

    body.ui-version-v2 .shell-actions .shell-panel-toggle { width: 34px; min-width: 34px; height: 32px; padding: 4px; }

    .acct-page {
        grid-template-columns: minmax(0, 1fr);
        width: calc(100% - 24px);
        padding: 16px 0 30px;
    }
}

@media (max-width: 480px) {
    .acct-section,
    .acct-card {
        padding: 14px;
    }

    .acct-actions .acct-button,
    .acct-actions-row .acct-button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .account-menu {
        transition: none;
    }
}
