/* ═══════════════════════════════════════════════════════════════════════
   DELPHOS · APP-WINDOWS.CSS
   Authoritative, modern styling for app windows/popups. Loaded AFTER
   style.css so it supersedes the older, basic window rules.

   Sections:
     1. Backdrop (windows-overlay)
     2. Base window shell (.data-window / #consentModal) + mobile bottom-sheet
     3. Window header + footer buttons
     4. Claude-style Settings layout (sidebar + panels + rows)
     5. Secure Pass PIN lock + Secure Pass manage
     6. Memory window
     7. Small shared bits (loaders, selects inside windows)
   ═══════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   1. BACKDROP
   ───────────────────────────────────────────────────────────── */
.windows-overlay,
.overlay-blurred {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.55) !important;
    backdrop-filter: blur(6px) saturate(120%);
    -webkit-backdrop-filter: blur(6px) saturate(120%);
    z-index: 9998 !important;
    opacity: 0;
    display: none;
    transition: opacity 0.25s ease;
}

.windows-overlay.active,
.overlay-blurred.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* ─────────────────────────────────────────────────────────────
   2. BASE WINDOW SHELL
   ───────────────────────────────────────────────────────────── */
.data-window,
#consentModal {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) scale(0.96) !important;
    width: min(920px, 94vw) !important;
    height: min(660px, 88vh) !important;
    max-width: 94vw;
    max-height: 90vh;
    background: var(--darker-background, #1a1a1a) !important;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1)) !important;
    border-radius: 20px !important;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(0, 0, 0, 0.4) !important;
    z-index: 9999 !important;
    overflow: hidden !important;
    display: none;
    opacity: 0;
    transition: opacity 0.24s ease, transform 0.26s cubic-bezier(0.22, 0.61, 0.36, 1);
    will-change: transform, opacity;
}

/* When shown via display:block, animate in */
.data-window[style*="display: block"],
.data-window[style*="display:block"],
#consentModal[style*="display: block"],
#consentModal[style*="display:block"] {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) !important;
}

/* Header */
.data-window .head {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    height: 58px !important;
    padding: 0 10px 0 22px !important;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08)) !important;
    background: transparent !important;
    flex-shrink: 0;
}

.data-window .head .window-data-title,
.data-window .head h2 {
    font-size: 17px !important;
    font-weight: 600;
    color: var(--text-color);
}

.data-window .head .icon-close {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    color: var(--subheading-color, #9b9b9b);
    background: transparent;
    border: none;
    transition: background 0.16s ease, color 0.16s ease;
}

.data-window .head .icon-close:hover {
    background: var(--secondary-hover-color, rgba(255, 255, 255, 0.08));
    color: var(--text-color);
}

/* Content region */
.data-window .content {
    position: relative;
    height: calc(100% - 58px) !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.data-window .content .content-viewer {
    height: 100%;
    overflow-y: auto;
    padding: 22px 24px 84px !important;
    border-bottom: none !important;
    -webkit-overflow-scrolling: touch;
}

/* Footer action buttons (Save / Close / Back) */
.data-window .content > div:last-child:not(.content-viewer):not(.window-loaders) {
    position: absolute;
    right: 20px !important;
    bottom: 18px !important;
    display: flex;
    gap: 10px;
    z-index: 5;
    padding: 6px 0;
}

.data-window #acceptConsentBtn,
.data-window #declineConsentBtn {
    min-width: 104px;
    height: 40px;
    padding: 0 18px !important;
    border-radius: 10px !important;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.16s ease, transform 0.1s ease, opacity 0.16s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.data-window #acceptConsentBtn {
    background: var(--text-color) !important;
    color: var(--chat-area-background, #0b0b0b) !important;
}

.data-window #acceptConsentBtn:hover {
    opacity: 0.88;
}

.data-window #declineConsentBtn {
    background: transparent !important;
    color: var(--text-color) !important;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.16)) !important;
}

.data-window #declineConsentBtn:hover {
    background: var(--secondary-hover-color, rgba(255, 255, 255, 0.07)) !important;
}

.data-window #acceptConsentBtn:active,
.data-window #declineConsentBtn:active {
    transform: scale(0.97);
}

.data-window .canc {
    background: rgba(239, 68, 68, 0.14) !important;
    color: #f87171 !important;
    border-color: transparent !important;
}

.data-window .canc:hover {
    background: rgba(239, 68, 68, 0.22) !important;
}

/* ─────────────────────────────────────────────────────────────
   4. CLAUDE-STYLE SETTINGS LAYOUT
   ───────────────────────────────────────────────────────────── */

/* When settings is showing, the content-viewer holds a full-bleed shell */
.data-window .content-viewer:has(.stg-shell) {
    padding: 0 !important;
    overflow: hidden !important;
}

.stg-shell {
    display: flex;
    height: 100%;
    min-height: 0;
    width: 100%;
}

/* Sidebar */
.stg-sidebar {
    width: 232px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    padding: 16px 12px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.015);
}

.stg-search {
    position: relative;
    margin-bottom: 14px;
}

.stg-search input {
    width: 100%;
    height: 36px;
    border-radius: 9px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    background: var(--secondary-color, #2a2a2a);
    color: var(--text-color);
    padding: 0 12px 0 34px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.16s ease;
}

.stg-search input:focus {
    border-color: rgba(148, 163, 184, 0.5);
}

.stg-search .stg-search-icon {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--subheading-color, #8a8a8a);
    pointer-events: none;
}

.stg-group-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--subheading-color, #8a8a8a);
    padding: 12px 10px 6px;
}

.stg-nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-color);
    cursor: pointer;
    user-select: none;
    transition: background 0.14s ease, color 0.14s ease;
}

.stg-nav-item .material-symbols-rounded {
    font-size: 19px;
    color: var(--subheading-color, #9b9b9b);
    transition: color 0.14s ease;
}

.stg-nav-item:hover {
    background: var(--secondary-hover-color, rgba(255, 255, 255, 0.06));
}

.stg-nav-item.active {
    background: var(--highlight-background, rgba(255, 255, 255, 0.1));
}

.stg-nav-item.active .material-symbols-rounded {
    color: var(--text-color);
}

/* Main panel area */
.stg-main {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 22px 26px 84px;
    -webkit-overflow-scrolling: touch;
}

.stg-panel {
    display: none;
    animation: stgPanelIn 0.24s ease;
}

.stg-panel.active {
    display: block;
}

@keyframes stgPanelIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.stg-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.stg-panel-back {
    display: none !important;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    color: var(--subheading-color);
    font-size: 20px;
}

.stg-panel-back:hover {
    background: var(--secondary-hover-color, rgba(255, 255, 255, 0.07));
    color: var(--text-color);
}

.stg-panel-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

.stg-section-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--subheading-color, #8a8a8a);
    margin: 22px 0 6px;
}

/* A settings row: label (+desc) on the left, control on the right */
.stg-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.06));
}

.stg-row:last-child {
    border-bottom: none;
}

.stg-row-text {
    min-width: 0;
    flex: 1;
}

.stg-row-text h4 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
    margin: 0;
}

.stg-row-text p {
    font-size: 12.5px;
    color: var(--subheading-color, #8a8a8a);
    margin: 3px 0 0;
    line-height: 1.45;
}

.stg-row-control {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Buttons used inside settings rows */
.stg-row-control button,
.data-window .settings-con button,
.data-window .setting-item button {
    height: 34px;
    padding: 0 16px !important;
    border-radius: 9px !important;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.14)) !important;
    background: var(--secondary-color, #2a2a2a) !important;
    color: var(--text-color) !important;
    transition: background 0.14s ease, transform 0.1s ease;
    width: auto !important;
}

.stg-row-control button:hover {
    background: var(--secondary-hover-color, rgba(255, 255, 255, 0.1)) !important;
}

.stg-row-control button:active {
    transform: scale(0.97);
}

.stg-row-control button.cancel,
.stg-row-control button.canc {
    background: rgba(239, 68, 68, 0.14) !important;
    color: #f87171 !important;
    border-color: transparent !important;
}

/* Full-width dropdowns inside settings look tidy on the right */
.stg-row-control .suparva-select-wrapper {
    width: 168px;
    margin: 0;
}

/* Plan badge fits inline */
.stg-row-control .plan-view-stg {
    padding: 8px 20px;
    pointer-events: none;
}

/* Avatar chip */
.stg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #4f8ef7);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────
   5. SECURE PASS — PIN lock screen
   ───────────────────────────────────────────────────────────── */
.secure-pass {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: rgba(10, 10, 12, 0.72);
    backdrop-filter: blur(14px) saturate(120%);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    text-align: center;
    padding: 24px;
}

.secure-pass .head {
    position: fixed;
    top: 14px;
    left: 14px;
}

.secure-pass .head .icon-close {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-color);
    font-size: 22px;
    background: rgba(255, 255, 255, 0.05);
    transition: background 0.16s ease;
}

.secure-pass .head .icon-close:hover {
    background: rgba(255, 255, 255, 0.12);
}

.secure-pass .inner-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    max-width: 360px;
    margin-top: 0;
}

.secure-pass .inner-content h3 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-color);
}

.secure-pass .inner-content > span {
    color: var(--subheading-color, #9b9b9b);
}

.secure-pass .pin-inputs {
    display: flex;
    gap: 14px;
    margin: 22px 0 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.secure-pass .pin-input {
    width: 58px;
    height: 64px;
    border-radius: 14px;
    border: 1.5px solid var(--border-color, rgba(255, 255, 255, 0.14));
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-color);
    text-align: center;
    font-size: 26px;
    font-weight: 600;
    outline: none;
    caret-color: transparent;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.secure-pass .pin-input:focus {
    border-color: #7c3aed;
    background: rgba(124, 58, 237, 0.12);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.22);
}

.secure-pass .pin-input.filled {
    border-color: rgba(124, 58, 237, 0.7);
    background: rgba(124, 58, 237, 0.16);
}

.secure-pass .pin-input.error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

/* ─────────────────────────────────────────────────────────────
   6. MEMORY WINDOW
   ───────────────────────────────────────────────────────────── */
.memory-con {
    width: 100%;
    padding: 2px;
}

.memory-con textarea {
    width: 100%;
    min-height: 140px;
    max-height: 320px;
    resize: vertical;
    border-radius: 14px;
    background: var(--secondary-color, #2a2a2a);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    color: var(--text-color);
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.6;
    outline: none;
    transition: border-color 0.16s ease;
    box-shadow: none;
}

.memory-con textarea:focus {
    border-color: rgba(148, 163, 184, 0.5);
}

/* Structured memory: toolbar + per-fact cards (overrides the legacy single
   textarea layout above). */
.memory-con .memory-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 2px 14px;
}

.memory-con .memory-count {
    font-size: 13px;
    color: var(--text-color);
    opacity: 0.7;
}

.memory-con .memory-add {
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.14));
    background: var(--secondary-color, #2a2a2a);
    color: var(--text-color);
    border-radius: 10px;
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease;
}

.memory-con .memory-add:hover {
    border-color: rgba(148, 163, 184, 0.6);
}

.memory-con .memory-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 2px;
}

.memory-con .memory-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 14px;
    padding: 12px 14px;
    background: var(--secondary-color, #2a2a2a);
}

.memory-con .memory-fact {
    width: 100%;
    min-height: 46px;
    max-height: 200px;
    resize: vertical;
    border-radius: 10px;
    background: var(--primary-color, rgba(0, 0, 0, 0.15));
    border: 1px solid transparent;
    color: var(--text-color);
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.16s ease;
    box-shadow: none;
}

.memory-con .memory-fact:focus {
    border-color: rgba(148, 163, 184, 0.5);
}

.memory-con .memory-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.memory-con .memory-date {
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.55;
}

.memory-con .memory-delete {
    border: none;
    background: transparent;
    color: #ef4444;
    font-size: 12.5px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.16s ease;
}

.memory-con .memory-delete:hover {
    background: rgba(239, 68, 68, 0.12);
}

/* ─────────────────────────────────────────────────────────────
   7. SHARED — selects inside windows + loaders
   ───────────────────────────────────────────────────────────── */
.data-window .window-loaders {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(3px);
    z-index: 20;
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE — mobile bottom-sheet windows
   ───────────────────────────────────────────────────────────── */
@media screen and (max-width: 820px) {
    /* Full-screen app windows on phones — settings/tools cover the whole
       viewport (no bottom-sheet gap). 100dvh tracks the dynamic viewport so
       the mobile browser's address bar never leaves a dead strip. */
    .data-window,
    #consentModal {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        transform: translateY(1.5%) !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0 !important;
        border: none !important;
    }

    .data-window[style*="display: block"],
    .data-window[style*="display:block"],
    #consentModal[style*="display: block"],
    #consentModal[style*="display:block"] {
        transform: translateY(0) !important;
    }

    /* No grab handle on a full-screen page (that affordance is for sheets) */
    .data-window .head::before {
        content: none !important;
        display: none !important;
    }

    /* Header clears the status bar / notch on installed PWAs */
    .data-window .head {
        height: calc(56px + env(safe-area-inset-top, 0px)) !important;
        padding-top: env(safe-area-inset-top, 0px) !important;
    }

    /* Content fills the rest below the (now taller) header */
    .data-window .content {
        height: calc(100% - 56px - env(safe-area-inset-top, 0px)) !important;
    }

    /* Settings becomes a drill-in: list first, panel slides over */
    .stg-shell {
        position: relative;
        overflow: hidden;
    }

    .stg-sidebar {
        width: 100%;
        border-right: none;
        padding: 14px;
    }

    .stg-main {
        position: absolute;
        inset: 0;
        background: var(--darker-background, #1a1a1a);
        transform: translateX(100%);
        transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
        padding: 18px 18px 90px;
    }

    .stg-shell.panel-open .stg-main {
        transform: translateX(0);
    }

    .stg-shell.panel-open .stg-panel-back {
        display: flex !important;
    }

    /* Solid footer bar so scrolling rows don't bleed behind the buttons */
    .data-window .content > div:last-child:not(.content-viewer):not(.window-loaders) {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100%;
        justify-content: flex-end;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
        background: linear-gradient(to top, var(--darker-background, #1a1a1a) 70%, transparent);
        border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.06));
    }

    .stg-main {
        padding-bottom: 96px;
    }

    .stg-row {
        flex-wrap: wrap;
    }

    .stg-row-control {
        width: 100%;
        justify-content: flex-start;
    }

    .stg-row-control .suparva-select-wrapper {
        width: 100%;
    }

    .secure-pass .pin-input {
        width: 52px;
        height: 58px;
        font-size: 22px;
    }
}

@media screen and (max-width: 400px) {
    .secure-pass .pin-input {
        width: 46px;
        height: 54px;
    }
    .data-window .content .content-viewer,
    .stg-main {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }
}

/* ─────────────────────────────────────────────────────────────
   PREFERENCE BODY CLASSES (set by settings toggles)
   ───────────────────────────────────────────────────────────── */
body.pref-reduce-motion *,
body.pref-reduce-motion *::before,
body.pref-reduce-motion *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}

/* Compact chat density */
body.pref-compact-chat .chat-list .message.incoming {
    margin-top: 0.85rem !important;
}

body.pref-compact-chat .chat-list .message.outgoing {
    margin-top: 14px !important;
}

body.pref-compact-chat .chat-list .message.incoming .text {
    line-height: 1.55;
}

body.pref-compact-chat .message-content .text p {
    margin: 0 0 0.5em;
}


/* ─────────────────────────────────────────────────────────────
   7. PRIVACY POLICY DOCUMENT
   ───────────────────────────────────────────────────────────── */

/* Wrapper used by the in-app privacy policy viewer */
.pp-doc {
    padding: 4px 2px 24px;
    line-height: 1.7;
    font-size: 14px;
    color: var(--text-color);
}

.pp-doc p {
    margin-bottom: 14px;
}

.pp-doc ul {
    padding-left: 22px;
    margin: 8px 0 14px;
}

.pp-doc ul li {
    margin-bottom: 6px;
}

.pp-doc strong {
    color: var(--heading-color, #e2e8f0);
}

.pp-doc em {
    color: var(--subheading-color, #94a3b8);
    font-style: normal;
}

.pp-doc h2 {
    font-size: 17px;
    margin-bottom: 12px;
    color: var(--heading-color, #e2e8f0);
}

/* ═══════════════════════════════════════════════════════════════════════
   CLAUDE-STYLE MOBILE POLISH — Settings & Tools windows
   Builds on the existing drill-in (list → panel) behaviour above. Makes the
   nav read like a native mobile settings list (rounded rows + chevrons),
   keeps the panel header pinned with its back button, and lays rows out so
   toggles/buttons stay on the right while full inputs stack underneath.
   ═══════════════════════════════════════════════════════════════════════ */
@media screen and (max-width: 820px) {
    /* ── Nav list: native settings-list feel ─────────────────────────────── */
    .stg-sidebar {
        padding: 6px 14px 28px;
        background: transparent;
    }

    .stg-search {
        margin: 6px 2px 10px;
    }

    .stg-search input {
        height: 46px;
        border-radius: 13px;
        font-size: 15px;
        padding-left: 40px;
    }

    .stg-search .stg-search-icon {
        left: 12px;
        font-size: 20px;
    }

    .stg-group-label {
        padding: 20px 6px 8px;
        font-size: 12px;
    }

    .stg-nav-item {
        padding: 15px 16px;
        margin-bottom: 8px;
        border-radius: 14px;
        font-size: 15px;
        gap: 14px;
        background: var(--secondary-color, rgba(255, 255, 255, 0.045));
        border: 1px solid var(--border-color, rgba(255, 255, 255, 0.06));
    }

    /* On the list there is no persistent "selected" row — it's just a launcher */
    .stg-nav-item.active {
        background: var(--secondary-color, rgba(255, 255, 255, 0.045));
    }

    .stg-nav-item:active {
        background: var(--secondary-hover-color, rgba(255, 255, 255, 0.1));
        transform: scale(0.99);
    }

    .stg-nav-item .material-symbols-rounded {
        font-size: 22px;
    }

    /* Trailing chevron, like iOS/Claude settings rows */
    .stg-nav-item::after {
        content: "chevron_right";
        font-family: "Material Symbols Rounded";
        font-size: 22px;
        line-height: 1;
        margin-left: auto;
        color: var(--subheading-color, #8a8a8a);
        opacity: 0.5;
    }

    /* ── Panel: pinned header with back button ───────────────────────────── */
    /* Clip the header's edge-to-edge bleed so it never triggers sideways scroll */
    .stg-main {
        overflow-x: hidden;
    }

    .stg-shell.panel-open .stg-panel-head {
        position: sticky;
        top: 0;
        z-index: 4;
        margin: -18px -18px 6px;
        padding: 14px 18px 12px;
        background: var(--darker-background, #1a1a1a);
        border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.06));
    }

    .stg-panel-title {
        font-size: 20px;
    }

    .stg-panel-back {
        width: 38px;
        height: 38px;
        font-size: 22px;
    }

    /* ── Rows: keep toggles/buttons on the right, stack only full inputs ──── */
    .stg-row {
        flex-wrap: nowrap;
        align-items: center;
        gap: 14px;
        padding: 16px 2px;
    }

    .stg-row-text h4 {
        font-size: 15px;
    }

    .stg-row-text p {
        font-size: 13px;
    }

    .stg-row-control {
        width: auto;
        justify-content: flex-end;
    }

    /* Text inputs, dropdowns and textareas get their own full-width line */
    .stg-row.stg-row-stack,
    .stg-row:has(.suparva-select-wrapper),
    .stg-row:has(input.suparva-input),
    .stg-row:has(textarea) {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .stg-row.stg-row-stack .stg-row-control,
    .stg-row:has(.suparva-select-wrapper) .stg-row-control,
    .stg-row:has(input.suparva-input) .stg-row-control {
        width: 100%;
        justify-content: flex-start;
        margin-top: 10px;
    }

    .stg-row-control .suparva-select-wrapper {
        width: 100%;
    }

    /* Slightly larger controls for touch */
    .stg-row-control button,
    .data-window .settings-con button,
    .data-window .setting-item button {
        height: 40px;
        padding: 0 18px !important;
        font-size: 14px;
    }
}
