/* =========================================================
   Vault Data Wrapper — Modern UI
   ========================================================= */

/* ── Design Tokens ── */
:root {
    /* Color palette — Light */
    --bg:               #eef0f6;
    --surface:          #ffffff;
    --surface-raised:   #f7f8fc;
    --border:           #e0e4ef;
    --border-focus:     #5046e4;
    --text:             #1a1c2e;
    --text-muted:       #6b7290;
    --text-on-primary:  #ffffff;

    --primary:          #5046e4;
    --primary-hover:    #3d35c7;
    --primary-dim:      rgba(80, 70, 228, 0.09);
    --primary-shadow:   rgba(80, 70, 228, 0.28);

    --success:          #059669;
    --success-bg:       rgba(5, 150, 105, 0.09);
    --success-border:   rgba(5, 150, 105, 0.25);

    --warning:          #b45309;
    --warning-bg:       rgba(251, 191, 36, 0.12);
    --warning-border:   rgba(251, 191, 36, 0.45);
    --warning-text:     #92400e;

    --danger:           #dc2626;
    --danger-bg:        rgba(220, 38, 38, 0.07);
    --danger-border:    rgba(220, 38, 38, 0.22);
    --danger-text:      #991b1b;

    /* Shape */
    --r-sm:   5px;
    --r-md:   9px;
    --r-lg:   13px;
    --r-xl:   18px;
    --r-full: 9999px;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 14px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg:  0 12px 32px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.05);

    /* Motion */
    --ease: 0.18s ease;
    --ease-md: 0.26s ease;

    /* Layout */
    --max-w: 860px;
    --gutter: 24px;
}

/* ── Dark Theme ── */
body.night-mode {
    --bg:               #0c0d17;
    --surface:          #12131e;
    --surface-raised:   #191a28;
    --border:           rgba(255,255,255,0.08);
    --border-focus:     #7c6de8;
    --text:             #dde0f2;
    --text-muted:       #6b7290;

    --primary:          #7c6de8;
    --primary-hover:    #6a5cd4;
    --primary-dim:      rgba(124, 109, 232, 0.14);
    --primary-shadow:   rgba(124, 109, 232, 0.35);

    --success:          #34d399;
    --success-bg:       rgba(52, 211, 153, 0.10);
    --success-border:   rgba(52, 211, 153, 0.28);

    --warning:          #fbbf24;
    --warning-bg:       rgba(251, 191, 36, 0.10);
    --warning-border:   rgba(251, 191, 36, 0.35);
    --warning-text:     #fbbf24;

    --danger:           #f87171;
    --danger-bg:        rgba(248, 113, 113, 0.10);
    --danger-border:    rgba(248, 113, 113, 0.28);
    --danger-text:      #f87171;

    --shadow-sm:  0 1px 3px rgba(0,0,0,.3);
    --shadow-md:  0 4px 14px rgba(0,0,0,.4);
    --shadow-lg:  0 12px 32px rgba(0,0,0,.55);
}

/* ── Reset & Base ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--ease-md), color var(--ease-md);
}

/* ── App shell ── */
.app-shell {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 var(--gutter) 40px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Header ── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
    transition: border-color var(--ease-md);
}

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

.brand-icon {
    width: 36px;
    height: 36px;
    color: var(--primary);
    flex-shrink: 0;
    transition: color var(--ease-md);
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    line-height: 1.2;
    transition: color var(--ease-md);
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    transition: color var(--ease-md);
}

/* Theme toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--ease), border-color var(--ease), color var(--ease), transform 0.15s ease;
    box-shadow: var(--shadow-sm);
}

.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: scale(1.05);
}

.theme-toggle svg {
    width: 17px;
    height: 17px;
}

/* Show moon in light mode, sun in dark mode */
body.light-mode .icon-sun { display: none; }
body.light-mode .icon-moon { display: block; }
body.night-mode .icon-moon { display: none; }
body.night-mode .icon-sun  { display: block; }

/* ── Main ── */
.app-main {
    flex: 1;
}

/* ── Sections grid (two-column single-page layout) ── */
.sections-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.panel {
    min-width: 0; /* prevent grid blowout on long content */
}

/* ── Tabs (kept for reference, not rendered) ── */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
    transition: border-color var(--ease-md);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 22px 11px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--ease);
    white-space: nowrap;
    position: relative;
}

.tab-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

/* Sliding underline indicator */
.tab-btn::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: var(--r-full);
    transform: scaleX(0);
    transition: transform 0.22s ease;
}

.tab-btn:hover {
    color: var(--text);
    background: transparent;
}

.tab-btn.active {
    color: var(--primary);
    font-weight: 600;
    background: transparent;
    box-shadow: none;
}

.tab-btn.active::after {
    transform: scaleX(1);
}

.tab-btn.active:hover {
    color: var(--primary);
    background: transparent;
}

.tab-btn:first-child {
    padding-left: 0;
}

/* Tab content */
.tab-content {
    display: none;
    animation: fadeSlideIn var(--ease-md) forwards;
}

.tab-content.active {
    display: block;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Section card ── */
.wrap-section,
.unwrap-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
    transition: background var(--ease-md), border-color var(--ease-md);
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    transition: color var(--ease-md);
}

.info-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    cursor: help;
    opacity: 0.7;
    transition: opacity var(--ease), color var(--ease);
}

.info-badge:hover {
    opacity: 1;
    color: var(--primary);
}

.info-badge svg {
    width: 16px;
    height: 16px;
}

/* ── Field labels ── */
.field-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 7px;
    transition: color var(--ease-md);
}

/* ── Drop zone + editor ── */
.drop-zone {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    transition: border-color var(--ease), background var(--ease);
    margin-bottom: 12px;
}

.drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-dim);
    box-shadow: 0 0 0 3px var(--primary-shadow);
}

.drop-zone.dragover .drop-overlay {
    opacity: 1;
    pointer-events: none;
}

.drop-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(var(--bg), 0.85);
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--ease);
    z-index: 10;
    backdrop-filter: blur(4px);
}

.drop-overlay svg {
    width: 44px;
    height: 44px;
}

/* CodeMirror overrides */
.CodeMirror {
    height: auto;
    min-height: 140px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
    font-size: 0.875rem;
    line-height: 1.7;
    /* No border/radius here — the container provides them */
    border-radius: 0;
    border: none;
}

.CodeMirror-scroll {
    min-height: 140px;
}

/* Unwrap result editor gets its own border so it vanishes when hidden */
.unwrap-result .CodeMirror {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    transition: border-color var(--ease-md);
}

body.night-mode .CodeMirror {
    background-color: #1a1b2a;
    color: var(--text);
}

/* Attach files button (inside drop zone) */
.file-attach-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 5;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0.8;
    transition: all var(--ease);
    box-shadow: var(--shadow-sm);
}

.file-attach-btn:hover {
    opacity: 1;
    color: var(--primary);
    border-color: var(--primary);
    transform: scale(1.07);
}

.file-attach-btn svg {
    width: 15px;
    height: 15px;
}

/* ── File chips ── */
.file-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    min-height: 0;
}

.file-bubble {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px 5px 10px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: all var(--ease);
    box-shadow: var(--shadow-sm);
}

.file-bubble::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}

.file-bubble:hover {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.file-bubble:hover::before {
    background: var(--danger);
}

/* ── Size bar ── */
.size-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: var(--r-full);
    overflow: visible;
    position: relative;
    margin-top: 14px;
    margin-bottom: 18px;
    transition: background var(--ease-md);
}

.size-bar::after {
    content: attr(data-size);
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    transition: color var(--ease-md);
}

.size-bar-inner {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    border-radius: var(--r-full);
    transition: width 0.3s ease, background 0.3s ease;
    width: 0;
    overflow: hidden;
}

.size-bar-inner.warning {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.size-bar-inner.error {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

/* ── Controls row ── */
.controls-row {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    flex-wrap: wrap;
}

.ttl-group {
    flex: 1;
    min-width: 200px;
}

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

.ttl-input-wrap {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--surface-raised);
    transition: border-color var(--ease), background var(--ease);
}

.ttl-input-wrap:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

.ttl-field {
    width: 90px;
    padding: 8px 10px;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    outline: none;
    -moz-appearance: textfield;
}

.ttl-field::-webkit-inner-spin-button,
.ttl-field::-webkit-outer-spin-button {
    opacity: 0.4;
}

.ttl-unit {
    padding: 0 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    border-left: 1px solid var(--border);
    background: var(--surface-raised);
    align-self: stretch;
    display: flex;
    align-items: center;
    transition: color var(--ease-md), border-color var(--ease-md);
}

.ttl-presets {
    display: flex;
    gap: 4px;
}

.preset-btn {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    background: var(--surface-raised);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ease);
}

.preset-btn:hover {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary);
}

/* ── Action group ── */
.action-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ── Primary button ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 22px;
    border: none;
    border-radius: var(--r-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ease);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-on-primary);
    box-shadow: 0 2px 8px var(--primary-shadow);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--primary-shadow);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Loading spinner */
.loading {
    pointer-events: none;
    opacity: 0.75;
}

.loading svg {
    opacity: 0;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Inline success ── */
.inline-success {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--success);
}

.inline-success svg {
    width: 15px;
    height: 15px;
}

/* ── Alert ── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-top: 14px;
    transition: background var(--ease-md), border-color var(--ease-md);
}

.alert-error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-text);
}

/* ── Result card ── */
.result-card {
    margin-top: 22px;
    border: 1px solid var(--success-border);
    border-radius: var(--r-lg);
    background: var(--surface-raised);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    animation: fadeSlideIn var(--ease-md) forwards;
    transition: background var(--ease-md), border-color var(--ease-md);
}

.result-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--success-bg);
    border-bottom: 1px solid var(--success-border);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--success);
}

.result-card-header svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Token warning */
.token-warning {
    display: none;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 20px;
    background: var(--warning-bg);
    border-bottom: 1px solid var(--warning-border);
    font-size: 0.855rem;
    color: var(--warning-text);
    line-height: 1.5;
    transition: background var(--ease-md), border-color var(--ease-md), color var(--ease-md);
}

.warning-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--warning);
}

/* Copy fields */
.copy-field {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    transition: border-color var(--ease-md);
}

.copy-field:last-of-type {
    border-bottom: none;
}

.copy-input-wrap {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--surface);
    transition: border-color var(--ease), background var(--ease);
}

.copy-input-wrap:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

.copy-input-wrap input[type="text"] {
    flex: 1;
    padding: 9px 12px;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 0.82rem;
    outline: none;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: none;
    border-left: 1px solid var(--border);
    background: var(--surface-raised);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--ease);
}

.copy-btn:hover {
    background: var(--primary-dim);
    color: var(--primary);
}

.copy-btn svg {
    width: 15px;
    height: 15px;
}

/* ── Details accordion ── */
.details-accordion {
    border-top: 1px solid var(--border);
    transition: border-color var(--ease-md);
}

.details-accordion summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 13px 20px;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: color var(--ease);
}

.details-accordion summary::-webkit-details-marker { display: none; }
.details-accordion summary::marker { display: none; }

.details-accordion summary:hover {
    color: var(--primary);
}

.details-accordion summary svg:first-child {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.details-accordion summary .chevron {
    width: 14px;
    height: 14px;
    margin-left: auto;
    transition: transform var(--ease);
    flex-shrink: 0;
}

.details-accordion[open] summary .chevron {
    transform: rotate(180deg);
}

.details-box {
    padding: 0 20px 18px;
}

.details-box pre,
.info-box pre {
    padding: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 0.8rem;
    line-height: 1.65;
    overflow-x: auto;
    color: var(--text);
    transition: background var(--ease-md), border-color var(--ease-md), color var(--ease-md);
}

/* ── Unwrap input ── */
.unwrap-input-group {
    margin-bottom: 16px;
}

.token-input-wrap {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--surface-raised);
    transition: border-color var(--ease), background var(--ease);
}

.token-input-wrap:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

.token-input-wrap input[type="text"] {
    flex: 1;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 0.875rem;
    outline: none;
    min-width: 0;
}

.token-input-wrap input::placeholder {
    color: var(--text-muted);
    font-family: inherit;
}

.paste-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: none;
    border-left: 1px solid var(--border);
    background: var(--surface-raised);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--ease);
}

.paste-btn:hover {
    background: var(--primary-dim);
    color: var(--primary);
}

.paste-btn svg {
    width: 16px;
    height: 16px;
}

/* ── Unwrap result area ── */
.unwrap-result {
    margin-top: 20px;
}

.unwrap-result .code-editor {
    margin-bottom: 12px;
}

/* info-box used by JS for dynamic content */
.info-box {
    margin-top: 16px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px;
    transition: background var(--ease-md), border-color var(--ease-md);
}

/* ── Footer ── */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 0 8px;
    font-size: 0.77rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 24px;
    transition: border-color var(--ease-md), color var(--ease-md);
}

.footer-sep {
    opacity: 0.4;
}

.app-footer a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--ease);
}

.app-footer a:hover {
    color: var(--primary);
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    display: none;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    background: var(--text);
    color: var(--bg);
    font-size: 0.83rem;
    font-weight: 600;
    border-radius: var(--r-full);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 9999;
    white-space: nowrap;
}

.toast svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.toast.show {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Scrollbar (webkit) ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--r-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Header right group ── */
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Vault status widget ── */
.vault-status {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    cursor: default;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--ease), background var(--ease), color var(--ease);
    user-select: none;
}

.vault-status:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.vault-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    transition: background var(--ease), box-shadow var(--ease);
}

.vault-status-dot.healthy {
    background: var(--success);
    box-shadow: 0 0 0 2px var(--success-bg);
    animation: status-pulse 2.8s ease-in-out infinite;
}

.vault-status-dot.standby {
    background: var(--warning);
    box-shadow: 0 0 0 2px var(--warning-bg);
}

.vault-status-dot.unhealthy {
    background: var(--danger);
    box-shadow: 0 0 0 2px var(--danger-bg);
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}

/* Vault status hover panel */
.vault-status-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 210px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    padding: 12px 14px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity var(--ease), transform var(--ease);
    z-index: 200;
}

.vault-status:hover .vault-status-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.vault-status-panel-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.vault-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 3px 0;
    white-space: nowrap;
}

.vault-status-key {
    font-size: 0.77rem;
    color: var(--text-muted);
    font-weight: 500;
}

.vault-status-val {
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--text);
}

.vault-status-val.ok   { color: var(--success); }
.vault-status-val.warn { color: var(--warning); }
.vault-status-val.err  { color: var(--danger); }

/* ── Floating tooltip ── */
.floating-tooltip {
    position: fixed;
    z-index: 9998;
    background: var(--text);
    color: var(--bg);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.5;
    padding: 5px 10px;
    border-radius: var(--r-sm);
    max-width: 240px;
    white-space: normal;
    text-align: center;
    box-shadow: var(--shadow-md);
    pointer-events: none;
    opacity: 0;
    transform: translateX(-50%);
    transition: opacity 0.14s ease;
    will-change: opacity;
}

.floating-tooltip.visible {
    opacity: 1;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    :root { --gutter: 14px; }

    .app-header { padding: 14px 0 14px; margin-bottom: 18px; }

    .brand-subtitle { display: none; }

    .sections-grid { grid-template-columns: 1fr; gap: 16px; }

    .tab-btn { padding: 9px 16px 10px; font-size: 0.85rem; }
    .tab-btn:first-child { padding-left: 0; }

    .wrap-section,
    .unwrap-section { padding: 18px 16px; }

    .controls-row { flex-direction: column; align-items: stretch; }
    .action-group { justify-content: flex-start; }

    .ttl-row { flex-wrap: wrap; }
}
