/* =============================================================================
   Settings Page
   ============================================================================= */

.settings-container {
    min-height: 100vh;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border);
}

.settings-header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

/* Header buttons - use shared .header-button class from dashboard.css */

/* Settings Tabs. The strip holds many tabs and must never shed them off the
   right edge on narrow viewports (the iPad hit this: wider than the phone
   breakpoint, narrower than the tab row) — it scrolls horizontally instead,
   with the global thin scrollbar as the affordance. */
.settings-tabs {
    display: flex;
    gap: 0;
    padding: 0 2rem;
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tab-button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 1rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab-button:hover {
    color: var(--text-primary);
}

.tab-button.active {
    color: var(--accent);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.expiring-badge {
    background: var(--error);
    color: white;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
}

.count-badge {
    background: var(--border);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}

/* Settings Content */
.settings-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.account-settings {
    max-width: 760px;
}

.profile-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.profile-setting {
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-darker);
}

.profile-setting h3 {
    margin: 0 0 0.25rem;
    color: var(--text-primary);
}

.profile-nickname-input {
    width: min(100%, 28rem);
    box-sizing: border-box;
    margin-top: 0.75rem;
    padding: 0.55rem 0.75rem;
    color: var(--text-primary);
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.profile-nickname-input:focus {
    outline: none;
    border-color: var(--accent);
}

.profile-save-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.linked-logins-section {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.identity-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.identity-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border);
}

.identity-row:last-child {
    border-bottom: 0;
}

.identity-provider {
    min-width: 4.5rem;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: var(--bg-dark);
    color: var(--text-primary);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}

.identity-details {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.identity-details strong {
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.identity-details span {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.identity-row .delete-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.settings-error {
    color: var(--error);
    margin: 0;
}

/* Section shell — the vertical stack every settings/admin panel is built from.
   Its `gap` is the single source of spacing between the blocks inside it
   (header, cards, lists, loading/empty states).
 *
 * Spacing lives on the shell rather than on the blocks because flex/grid item
 * margins do NOT collapse into `gap` — they add to it. So any child carrying its
 * own vertical margin double-counts every boundary. `.section-header` used to
 * own the spacing below itself with `margin-bottom: 1.5rem`, which rendered at
 * 3rem inside `.appearance-section` and 2.75rem inside `.performance-panel`
 * (both already had a `gap`) while being correct in the shells that didn't.
 * One mechanism in one place removes the whole class of bug, and the reset below
 * keeps it from returning as children acquire margins.
 *
 * Sections keep their own class for what is genuinely theirs (`max-width`,
 * colours); they should not redeclare the stack. */
.section-stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Direct children only: a block's outermost vertical margin is inter-block
   spacing, which the shell owns. Anything nested deeper keeps its margins.
 *
 * `> [class]` rather than `> *`: `> *` scores 0-1-0, which merely *ties* the
 * single-class rules it must override (`.notification-prefs`, `.sound-toggle`,
 * `.subdomain-create`), leaving stylesheet source order to decide — and all
 * three are declared after this rule, so the reset would lose and do nothing.
 * The attribute selector makes it 0-2-0, which wins regardless of order,
 * including across files. Every child here carries a class.
 *
 * Those children keep their own margin declarations on purpose: they are correct
 * outside a shell, so this scopes the removal to where `gap` actually applies. */
.section-stack > [class] {
    margin-block: 0;
}

.section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.section-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.section-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0.25rem 0 0 0;
    flex-basis: 100%;
}

.create-button {
    background: var(--accent);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.create-button:hover {
    background: var(--accent-hover);
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.tokens-table,
.sessions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.tokens-table th,
.sessions-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: var(--bg-darker);
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.tokens-table td,
.sessions-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.tokens-table tr:last-child td,
.sessions-table tr:last-child td {
    border-bottom: none;
}

.token-row.disabled {
    opacity: 0.5;
}

.token-name,
.session-name {
    font-weight: 500;
}

.session-directory {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.session-branch {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* Status indicators */
.token-status,
.session-status {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.token-status.active {
    background: rgba(158, 206, 106, 0.2);
    color: var(--success);
}

.token-status.expiring-soon {
    background: rgba(255, 158, 100, 0.2);
    color: #ff9e64;
}

.token-status.expired,
.token-status.revoked {
    background: rgba(247, 118, 142, 0.2);
    color: var(--error);
}

.session-status.active {
    background: rgba(158, 206, 106, 0.2);
    color: var(--success);
}

.session-status.inactive {
    background: rgba(224, 175, 104, 0.2);
    color: #e0af68;
}

.session-status.disconnected {
    background: rgba(127, 132, 156, 0.2);
    color: var(--text-secondary);
}

/* Actions column */
.session-actions {
    white-space: nowrap;
    text-align: center;
}

.session-actions button {
    display: inline-block;
    vertical-align: middle;
}

/* Action buttons - use specific selectors to override dashboard.css */
.settings-container .renew-button {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    position: static;
    opacity: 1;
    width: auto;
    height: auto;
    top: auto;
    right: auto;
    z-index: auto;
    margin-right: 0.5rem;
}

.settings-container .renew-button:hover {
    background: var(--accent);
    color: white;
}

.settings-container .revoke-button,
.settings-container .delete-button {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;

    /* Override dashboard.css absolute positioning */
    position: static;
    opacity: 1;
    width: auto;
    height: auto;
    top: auto;
    right: auto;
    z-index: auto;
}

.settings-container .revoke-button:hover,
.settings-container .delete-button:hover {
    background: var(--error);
    color: white;
}

.share-button {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    margin-right: 0.5rem;
}

.share-button:hover {
    background: var(--accent);
    color: white;
}

/* Create Token Form */
.create-token-form {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.create-token-form form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.form-group input {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 200px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group input[type="number"] {
    min-width: 100px;
}

.submit-button {
    background: var(--accent);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.submit-button:hover {
    background: var(--accent-hover);
}

/* Update-and-restart button */
.launcher-update-actions {
    display: grid;
    grid-template-columns: 11rem 7rem 5rem;
    gap: 0.5rem;
    justify-content: end;
    align-items: center;
}

.update-button {
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}
.launcher-update-primary,
.launcher-restart-button,
.launcher-update-secondary {
    width: 100%;
    min-height: 2.25rem;
    white-space: nowrap;
}

/* The "Restart" action deliberately shares the .update-button styles below.
   (An earlier outline variant set its text to var(--text-secondary) #7f849c —
   the same value .update-button.stage-0 uses as its BACKGROUND, and since the
   restart button carries both classes the later background rule won: invisible
   text. Same-color-on-same-color; don't reintroduce per-button color rules.) */
.update-button.stage-0 {
    background: #7f849c;
}
.update-button.stage-0:hover {
    background: #565f89;
}
.update-button.confirming {
    background: var(--error);
}
.update-button.confirming:hover {
    background: #ff5a72;
}
.update-button.stage-3 {
    background: #565f89;
    cursor: progress;
}
.update-button[disabled] {
    cursor: not-allowed;
    opacity: 0.85;
}
.launcher-update-secondary {
    padding: 0.5rem 0.75rem;
}
.launcher-update-secondary.is-placeholder {
    visibility: hidden;
    pointer-events: none;
}

/* Per-launcher update lifecycle feedback (#710 follow-up) */

/* The status line sits in a full-width cell beneath its row. Keep the cell a
   real table cell so `colspan` spans every column (and its bottom border spans
   with it) — the flex layout for the spinner + text lives on the inner div, NOT
   the td. Putting `display: flex` on the td drops it out of table layout, which
   makes it ignore `colspan` and collapse under the first column. */
.launcher-update-status td {
    padding-top: 0;
}

.launcher-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding-bottom: 0.25rem;
}
.launcher-status--waiting {
    color: var(--text-secondary);
}
.launcher-status--success {
    color: var(--success);
    font-weight: 500;
}
.launcher-status--warning {
    color: var(--warning);
    font-weight: 500;
}
.launcher-status--failed {
    color: var(--error);
    font-weight: 500;
}

/* A launcher that has dropped off the list while it self-updates. Dimmed so
   it reads as transient, but kept visible so the machine doesn't vanish. */
.launcher-row--phantom {
    opacity: 0.75;
}
.launcher-phantom-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--text-muted);
    color: white;
}

/* Token Created Success */
.token-created-success {
    text-align: center;
}

.token-created-success h3 {
    color: var(--success);
    margin: 0 0 1rem 0;
}

.token-created-success .warning {
    color: var(--error);
    font-weight: 500;
    margin-bottom: 1rem;
}

.token-display,
.init-url {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.token-display code,
.init-url code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    word-break: break-all;
    color: var(--accent);
}

.init-url label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.expires-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.token-created-success button {
    background: var(--accent);
    border: none;
    color: white;
    padding: 0.5rem 2rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Confirmation Modal */
.confirm-modal {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 400px;
    text-align: center;
}

.confirm-modal p {
    color: var(--text-primary);
    margin: 0 0 1.5rem 0;
    font-size: 1rem;
}

.confirm-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.cancel-button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.cancel-button:hover {
    border-color: var(--text-secondary);
}

.confirm-button {
    background: var(--error);
    border: none;
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.confirm-button:hover {
    background: #ff5a72;
}

/* Keyboard focus ring for the panel-style confirm modal buttons (#1384). */
.cancel-button:focus-visible,
.confirm-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Empty State */
.tokens-section .empty-state,
.sessions-section .empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Loading State */
.tokens-section .loading,
.sessions-section .loading {
    text-align: center;
    padding: 3rem;
}

/* =============================================================================
   Sounds Tab
   ============================================================================= */

.sounds-section {
    max-width: 900px;
}

.sound-save-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.save-feedback {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.save-feedback.saved {
    color: var(--success);
}

.save-feedback.unsaved {
    color: var(--error);
}

.create-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sound-toggle {
    margin-bottom: 1.5rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Notifications panel (mobile-apps plan D3) */
.notifications-section {
    max-width: 900px;
}

.push-device-control {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--bg-darker);
    border-radius: 8px;
}

.push-device-control.unavailable {
    opacity: 0.85;
}

.push-device-control .unsupported-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.notification-prefs {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.notification-prefs h3 {
    margin: 0;
    color: var(--text-primary);
}

/* Health timer */
.health-settings-section {
    max-width: 760px;
}

.health-settings-card {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.health-toggle-button {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid currentcolor;
    border-radius: 6px;
    background: transparent;
    font-size: 0.95rem;
    cursor: pointer;
}

.health-toggle-button.on {
    color: var(--success);
}

.health-toggle-button.off {
    color: var(--error);
}

/* Sized up so the state reads at a glance rather than from the word. */
.health-toggle-glyph {
    font-size: 1.05rem;
    line-height: 1;
}

.health-setting-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.health-setting-field > span {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.health-minutes-input {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.health-minutes-input input,
.health-setting-field textarea {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 4px;
    font: inherit;
}

.health-minutes-input input {
    width: 7rem;
    padding: 0.45rem 0.55rem;
}

.health-setting-field textarea {
    width: 100%;
    max-width: 620px;
    min-height: 6rem;
    padding: 0.65rem 0.75rem;
    resize: vertical;
    line-height: 1.4;
}

.health-minutes-input input:focus,
.health-setting-field textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.health-minutes-input span {
    color: var(--text-secondary);
}

.sound-event-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sound-event-card {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.sound-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.sound-card-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.sound-card-header p {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.preview-button {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.preview-button:hover {
    background: var(--accent);
    color: #fff;
}

.sound-controls {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.sound-control {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sound-control label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.sound-control select {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.sound-control select:focus {
    outline: none;
    border-color: var(--accent);
}

.sound-control input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

.sound-value {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* Responsive */
@media (max-width: 768px) {
    .settings-header {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .settings-header h1 {
        order: -1;
        flex-basis: 100%;
        text-align: center;
    }

    .settings-tabs {
        padding: 0 1rem;
        overflow-x: auto;
    }

    .settings-content {
        padding: 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .create-button {
        width: 100%;
        text-align: center;
    }

    .create-token-form form {
        flex-direction: column;
    }

    .form-group input {
        width: 100%;
        min-width: auto;
    }

    .table-container {
        font-size: 0.85rem;
    }

    .tokens-table th,
    .tokens-table td,
    .sessions-table th,
    .sessions-table td {
        padding: 0.5rem;
    }

    /* Hide less important columns on mobile */
    .token-created,
    .session-created {
        display: none;
    }
}

/* ==========================================================================
   Agent installation and login
   ========================================================================== */

/* Agent installation/login matrix and its shared confirmation modal. */
.agents-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-x: auto;
}

.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.agents-matrix {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.agents-matrix th,
.agents-matrix td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.agents-matrix th,
.agents-host-alias,
.agents-cell.unreachable,
.agents-cell.unknown,
.agents-cell.loading {
    color: var(--text-secondary);
}

.agents-host-name,
.agent-install-command,
.agent-login-device-code {
    font-family: var(--font-mono, monospace);
}

.agents-host-alias {
    margin-left: 0.4rem;
    font-size: 0.8rem;
}

/* Reserve the height of the tallest loaded state (badge + login line +
   sign-in button, plus cell padding under border-box sizing) in EVERY probe
   state. Probe results percolate in per machine, and without this each
   arriving result grew its row from a one-line "…" to a three-line stack,
   reflowing the whole table. td height acts as a minimum, so unexpected
   content can still grow a cell rather than clip. */
.agents-cell {
    height: 5.5rem;
}

/* Stack the badge/label/button without `display: flex` — flex on a <td>
   takes it out of table layout, so the per-agent cells stop forming columns
   and pile into the first one. */
.agents-cell > * {
    display: block;
}

.agents-cell > * + * {
    margin-top: 0.25rem;
}

.agents-badge {
    width: fit-content;
    padding: 0.05rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.agents-badge.installed,
.agents-login.logged-in,
.agent-login-status.success {
    color: var(--success, #9ece6a);
}

.agents-badge.installed {
    background: color-mix(in srgb, var(--success, #9ece6a) 20%, transparent);
}

.agents-badge.missing,
.agents-login.logged-out,
.agent-login-status.error {
    color: var(--error, #f7768e);
}

.agents-badge.missing {
    background: color-mix(in srgb, var(--error, #f7768e) 18%, transparent);
}

/* One line, ellipsized (full text in the title tooltip): a long login label
   ("signed in — user@host (plan) [via]") must not wrap, both because wrapping
   breaks the reserved-height row stability above and because it widens the
   auto-layout column when the probe result lands. */
.agents-login {
    font-size: 0.8rem;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agents-login.unknown {
    color: var(--text-secondary);
}

.agents-signin,
.agent-login-submit {
    width: fit-content;
    padding: 0.25rem 0.65rem;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
}

.agents-signin {
    margin-top: 0.15rem;
    font-size: 0.75rem;
}

.agents-signin:hover,
.agent-login-submit:hover {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.agent-login-overlay {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgb(0 0 0 / 55%);
}

.agent-login-modal {
    width: min(480px, 92vw);
    max-height: 90vh;
    padding: 1rem 1.25rem 1.25rem;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;

    /* --bg-secondary does not exist in this design system (base.css defines
       --bg-dark/--bg-darker); an undefined var() left the modal transparent. */
    background: var(--bg-dark);
    box-shadow: 0 12px 40px rgb(0 0 0 / 50%);
}

.agent-login-header,
.agent-login-footer,
.agent-login-code-row {
    display: flex;
    align-items: center;
}

.agent-login-header {
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.agent-login-header h2,
.agent-login-instr {
    margin: 0;
}

.agent-login-close {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
}

.agent-login-body {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.agent-login-instr,
.agent-login-status {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.agent-login-url {
    color: var(--accent);
    font-size: 0.85rem;
    word-break: break-all;
}

.agent-login-device-code,
.agent-install-command {
    padding: 0.5rem 0.6rem;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
}

.agent-login-device-code {
    font-size: 1.4rem;
    letter-spacing: 0.15rem;
    text-align: center;
}

.agent-login-code-row {
    gap: 0.5rem;
}

.agent-login-code-input {
    flex: 1;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.agent-login-submit:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.agent-login-footer {
    justify-content: flex-end;
    margin-top: 1rem;
}

.agent-install-command {
    display: block;
    font-size: 0.85rem;
    word-break: break-all;
}

/* ==========================================================================
   Appearance panel
   ========================================================================== */

/* Stack behaviour comes from `.section-stack`; nothing else is specific to this
   panel, so the rule is gone rather than left as a duplicate. */

.appearance-setting {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.appearance-setting h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.appearance-setting .setting-description {
    margin: 0 0 1rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.orientation-choices {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.orientation-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    color: var(--text-secondary);
    font: inherit;
}

.orientation-choice:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.orientation-choice.active {
    border-color: var(--accent);
    background: rgba(122, 162, 247, 0.1);
    color: var(--text-primary);
}

.orientation-label {
    font-size: 0.85rem;
    font-weight: 500;
}

/* Schematic previews for each rail position */
.orientation-preview {
    width: 120px;
    height: 80px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    display: flex;
    overflow: hidden;
}

.orientation-preview.top    { flex-direction: column; }
.orientation-preview.bottom { flex-direction: column-reverse; }
.orientation-preview.left   { flex-direction: row; }
.orientation-preview.right  { flex-direction: row-reverse; }

.orientation-preview .preview-rail-h {
    height: 16px;
    background: rgba(122, 162, 247, 0.4);
    border-bottom: 1px solid var(--border);
}

.orientation-preview.bottom .preview-rail-h {
    border-bottom: none;
    border-top: 1px solid var(--border);
}

.orientation-preview .preview-rail-v {
    width: 26px;
    background: rgba(122, 162, 247, 0.4);
    border-right: 1px solid var(--border);
}

.orientation-preview.right .preview-rail-v {
    border-right: none;
    border-left: 1px solid var(--border);
}

.orientation-preview .preview-body {
    flex: 1;
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.02),
        rgba(255, 255, 255, 0.02) 4px,
        rgba(255, 255, 255, 0.04) 4px,
        rgba(255, 255, 255, 0.04) 8px
    );
}

/* Settings ▸ Forwarding */
.forwarding-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.forwarding-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.forwarding-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.forwarding-name {
    color: var(--text-primary);
    font-weight: 600;
}

.forwarding-url {
    color: var(--text-teal, #7dcfff);
    font-family: monospace;
    font-size: 0.85rem;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.forwarding-url:hover {
    text-decoration: underline;
}

.forwarding-public {
    flex-shrink: 0;
}

.forwarding-badge {
    font-size: 0.78rem;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.forwarding-badge.is-public {
    background: rgba(224, 175, 104, 0.18);
    color: var(--warning, #e0af68);
}

/* Settings ▸ Schedule */
.schedule-calendar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    align-items: start;
}

.schedule-day {
    min-width: 0;
    overflow: hidden;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.schedule-day.is-today {
    border-color: rgba(122, 162, 247, 0.65);
    box-shadow: 0 0 0 1px rgba(122, 162, 247, 0.12);
}

.schedule-day-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.8rem 0.9rem;
    border-bottom: 1px solid var(--border);
    background: rgba(122, 162, 247, 0.06);
}

.schedule-day-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.schedule-day-header span {
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.schedule-day-events {
    display: flex;
    flex-direction: column;
    max-height: min(58vh, 36rem);
    overflow-y: auto;
}

.schedule-event {
    display: grid;
    grid-template-columns: 4.6rem minmax(0, 1fr);
    gap: 0.7rem;
    padding: 0.7rem 0.8rem;
    border-left: 3px solid var(--accent);
    border-bottom: 1px solid rgba(255, 255, 255, 0.045);
}

.schedule-event.agent-codex { border-left-color: #9ece6a; }
.schedule-event.agent-muse { border-left-color: #bb9af7; }

.schedule-event time {
    color: var(--text-teal, #7dcfff);
    font: 0.78rem var(--font-mono);
    white-space: nowrap;
}

.schedule-event-details {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.15rem;
}

.schedule-event-details strong {
    overflow: hidden;
    color: var(--text-primary);
    font-size: 0.85rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-event-details span,
.schedule-day-empty {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.schedule-day-empty {
    margin: 0;
    padding: 1.4rem 0.9rem;
    text-align: center;
}

.schedule-warning {
    padding: 0.7rem 0.9rem;
    color: var(--warning, #e0af68);
    background: rgba(224, 175, 104, 0.1);
    border: 1px solid rgba(224, 175, 104, 0.3);
    border-radius: 8px;
}

@media (max-width: 768px) {
    .schedule-calendar {
        display: flex;
        margin-inline: -1rem;
        padding-inline: 1rem;
        overflow-x: auto;
        scroll-snap-type: x proximity;
    }

    .schedule-day {
        flex: 0 0 min(84vw, 320px);
        scroll-snap-align: start;
    }
}
