/* Custom tooltip for bubble */
.bubble-has-tooltip[title] {
    position: relative;
    cursor: pointer;
}
.bubble-has-tooltip[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: 50%;
    bottom: 100%;
    transform: translateX(-50%) translateY(-8px);
    background: #222;
    color: #fff;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    z-index: 10;
    pointer-events: none;
    opacity: 0.97;
}
/* Add spacing between blocks in fansifter settings */
.fansifter-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 4px;
    margin-top: 4px;
}
/* =========================================================
   Cross‑browser dual range slider (Chrome / Firefox / Safari)
   Rewritten: neutralizes native progress fill; uses custom fill bar.
   ========================================================= */
.dual-range {
    position: relative;
    height: 40px; /* a little taller to ensure easy thumb targeting */
    display: flex;
    align-items: center; /* center track & thumbs vertically */
}

.dual-range__track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    height: 6px;
    background: #d1d1d6;
    border-radius: 3px;
    pointer-events: none;
}

.dual-range__fill {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    background: #007aff;
    border-radius: 3px;
    pointer-events: none;
}

.dual-range input[type=range] {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 40px;
    margin: 0;
    background: none;
    pointer-events: none; /* only thumbs capture */
    -webkit-appearance: none;
    appearance: none;
}

/* WebKit (Chrome / Safari) */
.dual-range input[type=range]::-webkit-slider-runnable-track {
    background: transparent; /* show our custom track */
    height: 6px;
}
.dual-range input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #007aff;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #007aff;
    cursor: pointer;
    pointer-events: auto; /* allow dragging */
    transition: box-shadow .15s ease, transform .15s ease;
    margin-top: -7px; /* vertically center relative to 6px track (WebKit) */
}
.dual-range input[type=range]:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(0,122,255,.4), 0 0 0 2px #007aff;
}
.dual-range input[type=range]::-webkit-slider-thumb:active { transform: scale(1.05); }

/* Firefox */
.dual-range input[type=range]::-moz-range-track { background: transparent; height: 6px; }
.dual-range input[type=range]::-moz-range-progress { background: transparent; height: 6px; }
.dual-range input[type=range]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #007aff;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 2px #007aff;
    cursor: pointer;
    pointer-events: auto;
    transition: box-shadow .15s ease, transform .15s ease;
}
.dual-range input[type=range]:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 3px rgba(0,122,255,.4), 0 0 0 2px #007aff;
}
.dual-range input[type=range]::-moz-range-thumb:active { transform: scale(1.05); }

/* Layer order: max above min while dragging for better accessibility */
#delay-min { z-index: 3; }
#delay-max { z-index: 4; }

/* Delay slider wrapper with numeric inputs */
.delay-flex {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}
.range-values {
    display: flex;
    align-items: center; /* vertically center numbers with baseline */
    gap: 6px;
    font-size: 12px;
    color: var(--color-text-secondary, #555);
}
.range-sep { user-select: none; }
.range-suffix { user-select: none; font-size: 11px; }

/* Remove default outline; focus ring handled on thumb */
.dual-range input[type=range]:focus { outline: none; }
body {
    background: var(--color-bg-page);
    font-family: var(--font-stack-sans);
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Connection indicator */
.conn-indicator {
    position: fixed;
    top: 6px;
    left: 6px;
    width: 14px; /* slightly larger for softer pastel */
    height: 14px;
    border-radius: 50%;
    background: #ffb7b7; /* default treat as disconnected (error toast color) */
    box-shadow: 0 0 0 2px rgba(0,0,0,0.08);
    z-index: 1000;
    transition: background 0.25s ease, transform 0.2s ease, box-shadow .25s ease;
    cursor: pointer;
}
.fan-state {
    position: fixed;
    bottom: 6px;
    left: 6px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(0,0,0,0.55);
    color: #fff;
    padding: 4px 8px;
    border-radius: 10px;
    line-height: 1;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
    z-index: 1000;
    user-select: none;
}
/* Status mapped to toast palette */
.conn-indicator.state-connected { background: #b6f8c4; }
.conn-indicator.state-connecting { background: #fae7c7; }
.conn-indicator.state-disconnected { background: #ffb7b7; }
.conn-indicator:hover {
    transform: scale(1.35);
}

/* Generic hover tooltip */
/* Default tooltip appears above element unless too close to top edge */
[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: 100%;
    transform: translate(-50%, -6px);
    background: rgba(0,0,0,0.82);
    color: #fff;
    font-size: 11px;
    line-height: 1.2;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
    z-index: 2000;
}
/* Arrow removed */
/* Remove old bottom tooltip for indicator */
/* Buttons: tooltip to the left */
/* Left tooltips adjacent to buttons */
.settings-btn[data-tip]:hover::after,
.global-reset-btn[data-tip]:hover::after {
    top: 50%;
    right: 100%;
    left: auto;
    bottom: auto;
    transform: translate(-4px, -50%);
}
/* Status indicator: tooltip to the right */
/* Right tooltip adjacent to indicator */
.conn-indicator[data-tip]:hover::after {
    top: 50%;
    left: 100%;
    bottom: auto;
    transform: translate(4px, -50%);
    font-size: 10px;
    padding: 3px 6px;
}
/* Top-right fixed buttons: show tooltip below to keep inside viewport */
/* Remove previous below-tooltip rules for buttons */
/* Ensure indicator keeps fixed positioning despite generic [data-tip] rule */
.conn-indicator[data-tip] {
    position: fixed; /* override relative */
    top: 6px;
    left: 6px;
    z-index: 1000;
}

/* Hybrid sizing variables */
:root {
    /* Design dimensions */
    --design-w: 390;
    /* base width in px */
    --design-h: 807;
    /* restored taller design height */
    --aspect-w: 390;
    /* aspect ratio width component */
    --aspect-h: 807;
    /* aspect ratio height component */
    --design-radius: 42;
    /* target corner radius at design width */
    --min-w: 340;
    /* floor width before scale fallback */
    --min-h: 640;
    /* floor height before scale fallback */
    --h-margin: 32px;
    /* horizontal safe margin */
    --v-margin: 32px;
    /* vertical safe margin */

    /* Font stacks */
    --font-stack-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', Arial, sans-serif;

    /* Colors */
    --color-bg-page: #ececec;
    --color-bg-phone: #ffffff;
    --color-bg-status: #F2F2F7;
    --color-bg-modal: #ffffff;
    --color-bubble-in: #E9E9EB;
    --color-bubble-out: var(--color-accent);
    --color-accent: #007aff;
    --color-accent-hover: #0062cc;
    --color-danger: #ff3b30;
    --color-danger-hover: #d8342a;
    --color-text-primary: #111;
    --color-text-secondary: #555;
    --color-text-tertiary: #666;
    --color-text-invert: #fff;
    --color-toast-bg: #1c1c1e;
    --font-size-toast: 14px;
    --color-toast-border-twilio: #ffcc00;
    --color-toast-border-fansifter: #2ecc71;
    --color-toast-border-state: var(--color-accent);
    --color-border-input: #d1d1d6;
    --color-border-subsection: #a2a2a9;
    /* darker for visibility */
    --color-border-subsection-strong: #8e8e95;
    --color-accent-subtle: rgba(0, 122, 255, .08);

    /* Shadows */
    --shadow-phone: 0 10px 28px -6px rgba(0, 0, 0, .25), 0 2px 6px rgba(0, 0, 0, .12);
    --shadow-status: 0 2px 4px -2px rgba(0, 0, 0, .25);
    --shadow-toast: 0 8px 26px rgba(0, 0, 0, .40);
    --shadow-modal: 0 4px 18px rgba(0, 0, 0, .25);

    /* Radii */
    --radius-bubble: 18px;
    --radius-btn: 18px;
    --radius-modal: 16px;

    /* Durations & easing */
    --duration-fast: .25s;
    --duration-medium: .4s;
    --easing-standard: cubic-bezier(.16, .72, .29, .99);
}

.phone-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 0;
    /* center without extra vertical scroll */
}

/* Adaptive mode (default) */
.rect {
    /* Compute candidate width from viewport constraints while preserving aspect */
    --ratio: calc(var(--aspect-h) / var(--aspect-w));
    /* height/width */
    --avail-h: calc(100vh - var(--v-margin) * 2);
    --avail-w: calc(100vw - var(--h-margin) * 2);
    --candidate-w: min(calc(var(--design-w) * 1px),
            calc(var(--avail-h) / var(--ratio)),
            var(--avail-w));
    width: clamp(calc(var(--min-w) * 1px), var(--candidate-w), calc(var(--design-w) * 1px));
    aspect-ratio: calc(var(--aspect-w) / var(--aspect-h));
    /* width/height */
    height: auto;
    background: var(--color-bg-phone);
    /* Scale radius proportionally to width using percentage, cap via clamp */
    /* 42px / 390px ≈ 10.77% */
    border-radius: clamp(32px, 10.8%, var(--design-radius) * 1px);
    box-shadow: var(--shadow-phone);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    will-change: width, height;
    transition: width .25s ease, height .25s ease, border-radius .25s ease;
}

/* Scale fallback when either width or height too small */
@media (max-width: 360px),
(max-height: 640px) {
    .rect {
        width: calc(var(--design-w) * 1px);
        height: calc(var(--design-h) * 1px);
        aspect-ratio: unset;
        /* Keep design corner radius; scale will apply visually */
        border-radius: calc(var(--design-radius) * 1px);
        transform: scale(min(calc((100vw - var(--h-margin) * 2) / (var(--design-w) * 1px)),
                    calc((100vh - var(--v-margin) * 2) / (var(--design-h) * 1px))));
        transform-origin: center center;
    }
}

.rect-status-bar {
    flex: 0 0 38px;
    background: var(--color-bg-status);
    box-shadow: var(--shadow-status);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 20px 0 20px;
    /* reduce top padding to raise notch */
}

.status-left,
.status-center,
.status-right {
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--color-text-primary);
}

/* Clock: ensure San Francisco (system) and tabular lining figures for steady width */
.status-clock {
    font-family: var(--font-stack-sans);
    font-variant-numeric: tabular-nums;
    -webkit-font-feature-settings: "tnum" 1;
    font-feature-settings: "tnum" 1;
    font-size: 14px;
    margin-left: 18px;
    /* slightly reduced inward shift */
}

.status-left {
    flex: 1;
}

.status-center {
    flex: 1;
    justify-content: center;
}

.status-right {
    flex: 1;
    justify-content: flex-end;
    gap: 6px;
}

.notch {
    width: 100px;
    /* narrower */
    height: 22px;
    /* slightly shorter */
    background: var(--color-text-primary);
    border-radius: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* Status bar icons now use <img>; remove old inline SVG icon classes */
.rect-status-bar .status-right img {
    display: block;
}

.rect-header {
    flex: 0 0 46px;
    background: var(--color-bg-status);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 2px 4px -2px rgba(0, 0, 0, 0.20);
}

.rect-header .contact-name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--color-text-primary);
}

/* Button palette aligned with toast colors */
.global-reset-btn {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1000;
    background: #ffb7b7; /* error toast color */
    color: #4a0d0d; /* error toast foreground */
    border: none;
    font-size: 12px;
    padding: 8px 14px;
    border-radius: 18px;
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    line-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s ease, box-shadow .2s ease, transform .2s ease;
}
.global-reset-btn:hover {
    background: #eaa3a3; /* slightly darker */
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.global-reset-btn:active {
    background: #dc9696;
    transform: translateY(1px);
}
.global-reset-btn:focus-visible { outline: 2px solid rgba(0,0,0,0.35); outline-offset: 2px; }

.settings-btn {
    position: fixed;
    top: 60px; /* placed below reset button */
    right: 12px;
    z-index: 1000;
    background: #b2e7f5; /* system toast color */
    color: #07313d; /* system toast foreground */
    border: none;
    font-size: 12px;
    padding: 8px 14px;
    border-radius: 18px;
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 0;
    transition: background .2s ease, box-shadow .2s ease, transform .2s ease;
}
.settings-btn:hover { background:#a1d6e4; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.settings-btn:active { background:#93c9d7; transform: translateY(1px); }
.settings-btn:focus-visible { outline:2px solid rgba(0,0,0,0.35); outline-offset:2px; }

.download-btn {
    position: fixed;
    top: 108px; /* below settings */
    right: 12px;
    z-index: 1000;
    background: #b6f8c4; /* default toast color */
    color: #053214; /* default toast foreground */
    border: none;
    font-size: 12px;
    padding: 8px 14px;
    border-radius: 18px;
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    transition: background .2s ease, box-shadow .2s ease, transform .2s ease;
}
.download-btn:hover { background:#a6e8b4; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.download-btn:active { background:#98dca7; transform: translateY(1px); }
.download-btn:focus-visible { outline:2px solid rgba(0,0,0,0.35); outline-offset:2px; }
.download-btn[data-tip]:hover::after { top:50%; right:100%; left:auto; bottom:auto; transform:translate(-4px,-50%); }

/* Remove old hover rules now replaced above */

.settings-btn img,
.global-reset-btn img,
.download-btn img {
    display: block;
    filter: brightness(0.9); /* subtle adjustment for pale backgrounds */
}

.global-reset-btn,
.settings-btn {
    line-height: 0;
}


.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    backdrop-filter: blur(2px);
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal-dialog {
    width: 300px;
    background: var(--color-bg-modal);
    border-radius: var(--radius-modal);
    padding: 18px 20px 16px;
    box-shadow: var(--shadow-modal);
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-family: inherit;
}

.settings-dialog {
    width: 1080px;
    /* wide for three panes */
    max-width: 70vw;
    /* allow a bit more width so tabs don't wrap */
    height: 70vh;
    /* fixed viewport-based height */
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* allow children to shrink for scrolling */
}

.settings-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-label {
    font-size: 13px;
    /* unified */
    font-weight: 600;
    letter-spacing: 0.4px;
    color: var(--color-text-secondary);
}

.settings-input {
    border: 1px solid var(--color-border-input);
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 14px;
}

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

.range-pair input[type=range] {
    flex: 1;
}

.range-values {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.settings-hint {
    font-size: 11px;
    color: var(--color-text-tertiary);
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-line input[type=checkbox] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-accent);
}

.checkbox-note {
    font-size: 11px;
    color: #555;
}

.toast-root {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    z-index: 1300;
    max-width: 420px;
}

.toast {
    background: #b6f8c4;
    color: #053214;
    padding: 12px 54px 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 500;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    word-break: break-word;
    min-width: 240px;
}
.toast.toast-system {
    background: #b2e7f5;
    color: #07313d;
}
.toast.toast-error {
    background: #ffb7b7;
    color: #4a0d0d;
}
.toast-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 4px 0;
    line-height: 1.25;
}
.toast-body {
    font-size: 13px;
    font-weight: 400;
    line-height: 1.3;
    margin: 0;
    word-break: break-word;
}

/* Toast close button (restored) */
.toast-close {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 10px;
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: #000;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.toast-close:hover {
    background: rgba(255, 255, 255, .12);
}

.toast-close:active {
    background: rgba(255, 255, 255, .2);
}

.toast-close:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Modal title (single definition) */
.modal-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.4px;
    color: var(--color-text-primary);
    margin: 0 2px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.settings-dialog {
    position: relative;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

/* Toast source color labels */
.toast-skipped { opacity:.85; }

/* Settings tabs */
.settings-tabs {
    display: flex;
    flex-direction: row;
    gap: 0;
    margin: 0 0 12px;
    align-items: stretch;
    border-bottom: 1px solid var(--color-border-input);
    position: relative;
}

.settings-tabs .settings-tab {
    flex: 1 1 0;
}

.settings-tab {
    flex: 1;
    background: var(--color-bg-status);
    border: none;
    padding: 10px 14px 11px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .45px;
    cursor: pointer;
    color: var(--color-text-secondary);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

/* Active tab: solid accent background */
.settings-tab.is-active {
    background: var(--color-accent);
    color: var(--color-text-invert);
    font-weight: 700;
}

.settings-tab:not(.is-active):hover {
    background: #e5e5ea;
}

.settings-tab:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: 6px;
}

.settings-tab:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}


.settings-panes {
    flex: 1 1 auto;
    position: relative;
    overflow-y: auto;
    /* scroll container */
    overflow-x: hidden;
    min-height: 0;
    padding-right: 4px;
    /* space for scrollbar */
}

.settings-pane {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
}

.settings-pane.is-active {
    display: flex;
    flex-direction: column;
    gap: 0;
    box-sizing: border-box;
    min-height: 0;
    padding-right: 0;
}

/* Twilio sections */
.settings-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 4px;
    margin-top: 4px;
}


.settings-section {
    border: 1px solid var(--color-border-input);
    border-radius: 14px;
    padding: 12px 14px 10px;
    background: var(--color-bg-phone);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-section-title {
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .4px;
    color: var(--color-text-primary);
}

.settings-section .settings-label {
    margin-top: 10px;
    display: inline-block;
}

.settings-section .settings-label:first-of-type {
    margin-top: 4px;
}

.settings-section .keyword-list {
    margin-bottom: 6px;
}

.settings-section .settings-text {
    margin-top: 6px;
}

.settings-label {
    font-size: 12px;
    /* unified */
    font-weight: 600;
    letter-spacing: .45px;
    color: var(--color-text-secondary);
}

.keyword-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 24px;
}

.keyword-pill {
    background: var(--color-bg-status);
    border: 1px solid var(--color-border-input);
    padding: 5px 10px 4px;
    /* unified */
    font-size: 12px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
    position: relative;
    transition: background var(--duration-fast) var(--easing-standard), border-color var(--duration-fast) var(--easing-standard);
}

.keyword-pill.add {
    cursor: pointer;
    font-weight: 600;
    color: var(--color-accent);
    border-style: dashed;
    background: transparent;
    padding: 5px 12px 4px;
}

.keyword-pill.add:hover {
    background: var(--color-accent-subtle);
}

.keyword-pill.add:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.keyword-pill.reserved {
    border-style: dashed;
    opacity: .75;
}

.keyword-remove {
    background: transparent;
    border: none;
    color: var(--color-danger);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}

.settings-label {
    font-size: 12px;
    /* +1px */
    font-weight: 600;
    letter-spacing: .45px;
    color: var(--color-text-secondary);
}

/* Inline keyword input (appears in place of + pill) */
.keyword-inline-input {
    border: 1px solid var(--color-border-input);
    border-radius: 10px;
    padding: 5px 8px 4px;
    font-size: 11px;
    font-family: var(--font-stack-sans);
    width: 90px;
    background: var(--color-bg-phone);
}

.keyword-inline-input:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.settings-text {
    width: 100%;
    resize: none;
    border: 1px solid var(--color-border-input);
    border-radius: 12px;
    padding: 9px 12px 8px;
    font-size: 13px;
    font-family: var(--font-stack-sans);
    box-sizing: border-box;
}

/* Fansifter placeholder text */
.fansifter-placeholder {
    font-size: 12px;
    line-height: 1.45;
    padding-bottom: 8px;
}

/* Cleaned malformed nested block */
.modal-body {
    font-size: 13px;
    line-height: 1.4;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-btn {
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 14px;
    letter-spacing: 0.4px;
}

.modal-cancel {
    background: #e5e5ea;
    color: var(--color-text-primary);
}

.modal-cancel:hover {
    background: #d1d1d6;
}

.modal-confirm {
    background: var(--color-danger);
    color: var(--color-text-invert);
}

.modal-confirm:hover {
    background: var(--color-danger-hover);
}

.back-arrow {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
}

.back-arrow::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    border-left: 2.4px solid #007aff;
    border-bottom: 2.4px solid #007aff;
    border-radius: 2px;
}

.rect-chat {
    flex: 1 1 auto;
    background: var(--color-bg-phone);
    overflow-y: auto;
    padding: 10px 14px 0 14px;
    display: flex;
    flex-direction: column;
}

.rect-chat::-webkit-scrollbar {
    display: none;
}

.bubble {
    max-width: 75%;
    margin: 4px 0;
    padding: 8px 12px 6px 12px;
    border-radius: var(--radius-bubble);
    font-size: 14px;
    line-height: 1.25;
    word-wrap: break-word;
    font-family: var(--font-stack-sans);
}

.bubble-out {
    background: var(--color-bubble-out);
    color: var(--color-text-invert);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.bubble-in {
    background: var(--color-bubble-in);
    color: var(--color-text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.msg-link {
    color: var(--color-accent);
    text-decoration: none;
}

.msg-link:hover {
    text-decoration: underline;
}

.bubble-time {
    font-size: 10px;
    opacity: .6;
    margin-top: 4px;
    text-align: right;
}

/* Attachment pill (iMessage-like) */
.attachment-pill {
    margin-top: 8px;
    background: #f2f2f7;
    border: 1px solid #e0e0e5;
    border-radius: 14px;
    padding: 8px 12px 6px;
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 12px;
    max-width: 240px;
}

.bubble-in .attachment-pill {
    background: #e9e9eb;
}

.attachment-icon {
    font-size: 22px;
    line-height: 1;
}

.attachment-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.attachment-name {
    font-weight: 600;
    font-size: 12px;
}

.attachment-type {
    font-size: 10px;
    opacity: .65;
}

.attachment-download {
    font-size: 11px;
    text-decoration: none;
    color: var(--color-accent);
    font-weight: 600;
}

.attachment-download:hover {
    text-decoration: underline;
}

.rect-input-area {
    flex: 0 0 auto;
    background: var(--color-bg-phone);
    padding: 10px 14px;
}

.rect-bottom {
    flex: 0 0 24px;
    background: var(--color-bg-phone);
    position: relative;
}

.imessage-form {
    display: flex;
    gap: 10px;
}

.imessage-input {
    flex: 1;
    background: var(--color-bg-phone);
    border: 1px solid var(--color-border-input);
    border-radius: 18px;
    padding: 10px 14px 8px 14px;
    font-size: 15px;
    outline: none;
}

.imessage-input::placeholder {
    color: #7e7e82;
    font-weight: 500;
    letter-spacing: 0.3px;
}


.rect-bottom::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 5px;
    background: #000;
    opacity: 0.18;
    border-radius: 3px;
}

.error {
    color: #b00020;
    font-size: 13px;
    margin-top: 6px;
}
