/* ============================================================
   YDP NAVIGATOR — Director Patch
   Old premium YDP style + requested fixes only
   ============================================================ */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #050508;
    --bg-grid: rgba(255, 255, 255, 0.03);
    --surface: #0C0C10;
    --surface-2: #141418;
    --card: #1C1C22;
    --border: rgba(255, 255, 255, 0.14);
    --border-strong: rgba(255, 255, 255, 0.24);

    --text: #F5F5F7;
    --text-2: #D1D1D6;
    --text-dim: #8E8E93;
    --text-faint: #636366;

    --accent: #F5F5F7;
    --accent-hover: #FFFFFF;
    --accent-soft: rgba(255, 255, 255, 0.08);
    --accent-line: rgba(255, 255, 255, 0.22);

    --bot-bg: #1C1C22;
    --bot-text: #F5F5F7;
    --user-bg: #09090B;
    --user-text: #FFFFFF;

    --send-bg: #09090B;
    --send-bg-hover: #1C1C22;
    --send-icon: #FFFFFF;

    --online: #4ADE80;
    --danger: #F87171;

    --focus-line: rgba(255, 255, 255, 0.55);
    --focus-soft: rgba(255, 255, 255, 0.10);
    --scroll-thumb: rgba(255, 255, 255, 0.32);
    --scroll-thumb-hover: rgba(255, 255, 255, 0.50);
    --edge-visible: rgba(255, 255, 255, 0.28);
    --edge-soft: rgba(255, 255, 255, 0.18);

    --logo-img: url("assets/logo-dark.png");

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.38);
    --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.60);
    --glow: 0 0 34px rgba(0, 0, 0, 0.25);

    --radius: 20px;
    --radius-bubble: 17px;
    --font-head: 'DM Sans', system-ui, sans-serif;
    --font-body: 'DM Sans', system-ui, sans-serif;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Responsive spacing — scales across phones → PCs */
    --page-pad: clamp(12px, 2.2vw, 24px);
    --header-pad-x: clamp(14px, 3.2vw, 22px);
    --header-pad-y: clamp(12px, 2vw, 18px);
    --chat-pad-x: clamp(12px, 3vw, 20px);
    --input-pad-x: clamp(12px, 3vw, 18px);
    --input-pad-top: clamp(10px, 1.6vw, 14px);
    --input-pad-bottom: clamp(12px, 2.4vw, 18px);
    --footer-pad-y: clamp(8px, 1.4vw, 12px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --composer-lift: 0px;
}

[data-theme="light"] {
    --focus-line: rgba(0, 0, 0, 0.42);
    --focus-soft: rgba(0, 0, 0, 0.07);
    --scroll-thumb: rgba(0, 0, 0, 0.24);
    --scroll-thumb-hover: rgba(0, 0, 0, 0.38);
    --edge-visible: rgba(0, 0, 0, 0.16);
    --edge-soft: rgba(0, 0, 0, 0.09);

    --bg: #E9E9EC;
    --bg-grid: rgba(0, 0, 0, 0.025);
    --surface: #FFFFFF;
    --surface-2: #F4F4F5;
    --card: #EFEFF1;
    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.14);

    --text: #111318;
    --text-2: #2B2F37;
    --text-dim: #626977;
    --text-faint: #7B8190;

    --accent: #111318;
    --accent-hover: #000000;
    --accent-soft: rgba(0, 0, 0, 0.055);
    --accent-line: rgba(0, 0, 0, 0.18);

    --bot-bg: #F0F1F3;
    --bot-text: #111318;
    --user-bg: #090A0D;
    --user-text: #FFFFFF;

    --send-bg: #090A0D;
    --send-bg-hover: #1B1D22;
    --send-icon: #FFFFFF;

    --online: #16A34A;
    --logo-img: url("assets/logo-light.png");

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.10);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.13);
    --glow: 0 0 34px rgba(0, 0, 0, 0.045);
}

html {
    height: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--page-pad);
    padding-bottom: calc(var(--page-pad) + var(--safe-bottom));
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background 0.35s var(--ease), color 0.35s var(--ease);
}

.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

.chat-wrapper {
    container-type: inline-size;
    container-name: chat;
    width: 100%;
    max-width: min(500px, 100%);
    position: relative;
    z-index: 1;
    animation: containerIn 0.55s var(--ease) both;
}

@keyframes containerIn {
    from { opacity: 0; transform: translateY(18px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-container {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg), var(--glow);
    display: flex;
    flex-direction: column;
    height: min(88vh, 780px);
    height: min(88dvh, 780px);
    max-height: 780px;
    min-height: min(520px, 100dvh);
    overflow: hidden;
}

/* HEADER */

.chat-header {
    padding: var(--header-pad-y) var(--header-pad-x) calc(var(--header-pad-y) - 2px);
    background: linear-gradient(160deg, var(--surface-2) 0%, var(--surface) 100%);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 13px;
    flex: 1;
    min-width: 0;
}

.logo-mark {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-image: var(--logo-img);
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
    border: 1.5px solid var(--border-strong);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.brand-text h1 {
    font-family: 'DM Sans', var(--font-body);
    font-size: 40px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.05;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.online-status {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-dim);
    font-size: 11px;
    margin-top: 4px;
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--online);
    flex-shrink: 0;
    animation: pulseWorking 2s ease-in-out infinite;
}

@keyframes pulseWorking {
    0% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55);
        transform: scale(1);
    }
    55% {
        box-shadow: 0 0 0 6px rgba(74, 222, 128, 0);
        transform: scale(1.08);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
        transform: scale(1);
    }
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    position: relative;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.025);
    color: var(--text-dim);
    display: grid;
    place-items: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.icon-btn:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--accent-soft);
    transform: translateY(-1px);
}

.theme-toggle .sun { display: none; }
[data-theme="light"] .theme-toggle .moon { display: none; }
[data-theme="light"] .theme-toggle .sun { display: block; }

/* READ ALOUD MUTE TOGGLE */

.tts-mute .vol-off { display: none; }
.tts-mute.is-muted .vol-on { display: none; }
.tts-mute.is-muted .vol-off { display: block; }

.tts-mute.is-muted {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(248, 113, 113, 0.08);
}

/* CHAT */

.chat-box {
    flex: 1;
    padding: clamp(14px, 2.4vw, 20px) var(--chat-pad-x);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 13px;
    scroll-behavior: smooth;
}

.chat-box::-webkit-scrollbar { width: 4px; }
.chat-box::-webkit-scrollbar-track { background: transparent; }
.chat-box::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 10px;
}

.chat-box::-webkit-scrollbar-thumb:hover {
    background: var(--scroll-thumb-hover);
}

.chat-box {
    scrollbar-color: var(--scroll-thumb) transparent;
}

.message-row {
    display: flex;
    width: 100%;
    animation: msgIn 0.28s var(--ease-bounce) both;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.bot-row {
    justify-content: flex-start;
    padding-right: 44px;
}

.user-row {
    justify-content: flex-end;
    padding-left: 62px;
}

.message-wrap {
    max-width: 100%;
}

.message-bubble {
    position: relative;
    padding: 12px 16px;
    border-radius: var(--radius-bubble);
    border: 1.5px solid var(--edge-visible);
    font-size: 14.5px;
    line-height: 1.65;
    box-shadow: var(--shadow-sm);
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: visible;
}

.bot-row .message-bubble {
    background: var(--bot-bg);
    color: var(--bot-text);
    border-bottom-left-radius: 4px;
}

.user-row .message-bubble {
    background: var(--user-bg);
    color: var(--user-text);
    border-bottom-right-radius: 4px;
}

/* Clean bubble tails — single shape, no border gap */

.bot-row .message-bubble::before,
.user-row .message-bubble::before {
    content: none;
}

.bot-row .message-bubble::after {
    content: "";
    position: absolute;
    left: -7px;
    bottom: 0;
    width: 11px;
    height: 11px;
    background: var(--bot-bg);
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
    z-index: 0;
}

.user-row .message-bubble::after {
    content: "";
    position: absolute;
    right: -7px;
    bottom: 0;
    width: 11px;
    height: 11px;
    background: var(--user-bg);
    clip-path: polygon(0 0, 100% 100%, 0 100%);
    z-index: 0;
}

.message-bubble > * {
    position: relative;
    z-index: 1;
}

/* Markdown inside bot messages */

.message-bubble p { margin-bottom: 8px; }
.message-bubble p:last-child { margin-bottom: 0; }

.message-bubble strong,
.message-bubble .brand-term {
    color: inherit;
    font-family: var(--font-body);
    font-weight: 700;
    font-synthesis: none;
    font-variant-numeric: normal;
    letter-spacing: 0.01em;
}

.message-bubble em {
    font-style: italic;
    color: var(--text-2);
}

.message-bubble ul,
.message-bubble ol {
    margin: 8px 0 8px 18px;
    padding-left: 18px;
    list-style: disc;
}

.message-bubble li {
    margin-bottom: 6px;
    padding-left: 2px;
}

.message-bubble li::marker {
    color: var(--text-dim);
}

.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
    font-family: var(--font-head);
    color: var(--text);
    margin: 10px 0 6px;
    line-height: 1.22;
    font-weight: 700;
}

[data-theme="light"] .message-bubble h2,
[data-theme="light"] .message-bubble h3,
[data-theme="light"] .message-bubble h4 {
    color: #111318;
}

.message-bubble a {
    color: #60A5FA;
    text-decoration: underline;
}

.message-bubble code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 5px;
    font-size: 12px;
}

/* MESSAGE ACTIONS */

.message-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 7px;
    padding-left: 2px;
}

.action-btn {
    height: 28px;
    min-width: 28px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.025);
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    overflow: hidden;
    padding: 0 8px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 11px;
    white-space: nowrap;
    transition: all 0.24s var(--ease);
}

.action-btn svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.2;
    flex-shrink: 0;
}

.action-btn span {
    max-width: 0;
    opacity: 0;
    transform: translateX(-4px);
    transition: all 0.24s var(--ease);
}

.action-btn:hover {
    color: var(--text);
    background: var(--accent-soft);
    border-color: var(--accent-line);
    min-width: 86px;
}

.action-btn:hover span {
    max-width: 90px;
    opacity: 1;
    transform: translateX(0);
}

/* RECOMMENDED PROMPT CARDS */

.prompt-cards {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding: 6px 2px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}

.prompt-cards::-webkit-scrollbar {
    height: 6px;
}

.prompt-cards::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 10px;
}

.prompt-cards::-webkit-scrollbar-thumb:hover {
    background: var(--scroll-thumb-hover);
}

.prompt-card {
    flex: 0 0 auto;
    min-width: 168px;
    max-width: 220px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1.5px solid var(--edge-soft);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font-body);
    text-align: left;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.22s var(--ease), border-color 0.22s var(--ease), background 0.22s var(--ease);
}

.prompt-card:hover {
    border-color: var(--focus-line);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: var(--shadow-md), 0 0 22px rgba(255, 255, 255, 0.08);
}

.prompt-card-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 6px;
}

.prompt-card-text {
    display: block;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--text-2);
}

.msg-attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid var(--edge-soft);
    background: rgba(255, 255, 255, 0.05);
    font-size: 12px;
}

.msg-attachment svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* TYPING */

.typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--text-dim);
    border-radius: 50%;
    animation: typingBounce 1.35s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* PDF PREVIEW & DROP ZONE */

.pdf-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 16px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--edge-soft);
    background: var(--surface-2);
    flex-shrink: 0;
}

.pdf-preview[hidden] {
    display: none !important;
}

.pdf-preview-icon svg {
    width: 22px;
    height: 22px;
    color: var(--text-dim);
}

.pdf-preview-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pdf-preview-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdf-preview-status {
    font-size: 11px;
    color: var(--text-dim);
}

.pdf-preview-remove {
    width: 28px;
    height: 28px;
    border: 1px solid var(--edge-soft);
    border-radius: 50%;
    background: transparent;
    color: var(--text-dim);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.pdf-preview-remove:hover {
    color: var(--text);
    border-color: var(--focus-line);
}

.drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    border-radius: var(--radius);
    pointer-events: none;
}

.drop-overlay.is-active {
    display: flex;
}

.drop-overlay-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 24px 32px;
    border-radius: 16px;
    border: 2px dashed var(--focus-line);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.drop-overlay-inner svg {
    width: 36px;
    height: 36px;
}

/* VOICE INLINE */

.voice-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 16px 8px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--edge-soft);
    background: var(--surface-2);
    flex-shrink: 0;
}

.voice-inline[hidden] {
    display: none !important;
}

.voice-inline-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--online);
    animation: pulseWorking 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

.voice-inline-label {
    flex: 1;
    font-size: 13px;
    color: var(--text-2);
}

.voice-inline-cancel {
    border: 1px solid var(--edge-soft);
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.voice-inline-cancel:hover {
    color: var(--text);
    border-color: var(--focus-line);
}

/* INPUT AREA — raised composer with safe-area gap (chatbot pattern) */

.input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding:
        var(--input-pad-top)
        var(--input-pad-x)
        calc(var(--input-pad-bottom) + var(--composer-lift) + var(--safe-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.upload-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-dim);
    display: grid;
    place-items: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s var(--ease);
}

.upload-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.upload-btn:hover {
    color: var(--text);
    border-color: var(--focus-line);
    background: rgba(255, 255, 255, 0.06);
}

.input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: 26px;
    padding: 0 7px 0 16px;
    min-width: 0;
    transition: all 0.2s var(--ease);
}

.input-wrap:focus-within {
    border-color: var(--focus-line);
    box-shadow: 0 0 0 3px var(--focus-soft);
}

#user-input {
    flex: 1;
    min-width: 0;
    height: 44px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-body);
}

#user-input::placeholder {
    color: var(--text-dim);
}

.mic-btn {
    width: 33px;
    height: 33px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.mic-btn svg {
    width: 17px;
    height: 17px;
    stroke-width: 2.2;
}

.mic-btn:hover,
.mic-btn.is-listening {
    color: var(--text);
    background: var(--accent-soft);
}

#send-btn {
    width: 44px;
    height: 44px;
    background: var(--send-bg);
    color: var(--send-icon);
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
    transition: all 0.2s var(--ease);
}

#send-btn svg {
    width: 19px;
    height: 19px;
}

#send-btn:hover {
    background: var(--send-bg-hover);
    transform: scale(1.05);
}

#send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* FOOTER */

.chat-footer {
    text-align: center;
    padding: var(--footer-pad-y) var(--input-pad-x);
    padding-bottom: calc(var(--footer-pad-y) + var(--safe-bottom));
    font-size: 11px;
    color: var(--text-faint);
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* When footer is present, keep safe-area on footer only (avoid double padding) */
.chat-container:has(.chat-footer) .input-area {
    padding-bottom: calc(var(--input-pad-bottom) + var(--composer-lift));
}

.chat-footer a {
    color: var(--text-dim);
    text-decoration: none;
}

.chat-footer a:hover {
    color: var(--accent);
}

.message-bubble a {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.footer-whatsapp svg {
    width: 12px;
    height: 12px;
    vertical-align: -2px;
    margin-right: 2px;
}

.footer-whatsapp:hover {
    color: #25D366;
}

/* TOAST */

.toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    pointer-events: none;
    z-index: 40;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    box-shadow: var(--shadow-md);
    transition: all 0.25s var(--ease);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast svg {
    width: 16px;
    height: 16px;
}

/* ============================================================
   PROPORTIONATE BREAKPOINTS
   Small phones → large phones → phablets → tablets → PCs
   ============================================================ */

/* Small phones (≤360px) */
@media (max-width: 360px) {
    :root {
        --composer-lift: 10px;
        --page-pad: 0px;
        --header-pad-x: 12px;
        --header-pad-y: 12px;
        --chat-pad-x: 12px;
        --input-pad-x: 10px;
        --input-pad-top: 10px;
        --input-pad-bottom: 14px;
        --footer-pad-y: 8px;
    }

    body {
        padding: 0;
        padding-bottom: 0;
        align-items: stretch;
    }

    .chat-wrapper {
        max-width: 100%;
        height: 100%;
    }

    .chat-container {
        border-radius: 16px 16px 0 0;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        min-height: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }

    .brand-text h1 { font-size: 20px; }
    .logo-mark { width: 44px; height: 44px; }
    .message-bubble { font-size: 13px; }
    .icon-btn { width: 32px; height: 32px; }
    .upload-btn { width: 34px; height: 34px; }
    #send-btn { width: 40px; height: 40px; }
    #user-input { height: 42px; font-size: 16px; }
    .bot-row { padding-right: 18px; }
    .user-row { padding-left: 36px; }
    .prompt-card { min-width: 136px; max-width: 170px; }
}

/* Standard phones (361–480px) */
@media (min-width: 361px) and (max-width: 480px) {
    :root {
        --composer-lift: 12px;
        --page-pad: 0px;
        --header-pad-x: 14px;
        --header-pad-y: 14px;
        --chat-pad-x: 14px;
        --input-pad-x: 12px;
        --input-pad-top: 12px;
        --input-pad-bottom: 16px;
        --footer-pad-y: 9px;
    }

    body {
        padding: 0;
        padding-bottom: 0;
        align-items: stretch;
    }

    .chat-wrapper {
        max-width: 100%;
        height: 100%;
    }

    .chat-container {
        border-radius: 18px 18px 0 0;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        min-height: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }

    .brand-text h1 { font-size: 22px; }
    .logo-mark { width: 48px; height: 48px; }
    .message-bubble { font-size: 13.5px; }
    .icon-btn { width: 34px; height: 34px; }
    .upload-btn { width: 36px; height: 36px; }
    #user-input { font-size: 16px; }
    .bot-row { padding-right: 22px; }
    .user-row { padding-left: 40px; }
    .prompt-card { min-width: 148px; max-width: 190px; }
}

/* Large phones / phablets (481–767px) */
@media (min-width: 481px) and (max-width: 767px) {
    :root {
        --composer-lift: 14px;
        --page-pad: 0px;
        --header-pad-x: 16px;
        --header-pad-y: 15px;
        --chat-pad-x: 16px;
        --input-pad-x: 14px;
        --input-pad-top: 12px;
        --input-pad-bottom: 18px;
        --footer-pad-y: 10px;
    }

    body {
        padding: 0;
        padding-bottom: 0;
        align-items: stretch;
    }

    .chat-wrapper {
        max-width: 100%;
        height: 100%;
    }

    .chat-container {
        border-radius: 20px 20px 0 0;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        min-height: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }

    .brand-text h1 { font-size: 24px; }
    .logo-mark { width: 50px; height: 50px; }
    .message-bubble { font-size: 14px; }
    #user-input { font-size: 16px; }
    .bot-row { padding-right: 28px; }
    .user-row { padding-left: 48px; }
}

/* Tablets (768–1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    :root {
        --composer-lift: 6px;
        --page-pad: 20px;
        --input-pad-bottom: 16px;
    }

    .chat-wrapper {
        max-width: 560px;
    }

    .chat-container {
        height: min(84vh, 820px);
        height: min(84dvh, 820px);
        max-height: 820px;
    }

    .brand-text h1 { font-size: 28px; }
}

/* PCs / desktops (≥1024px) */
@media (min-width: 1024px) {
    :root {
        --composer-lift: 4px;
        --page-pad: 24px;
        --input-pad-bottom: 14px;
    }

    .chat-wrapper {
        max-width: 500px;
    }

    .chat-container {
        height: min(82vh, 820px);
        height: min(82dvh, 820px);
        max-height: 820px;
    }
}

/* Short viewports (landscape phones / short windows) */
@media (max-height: 560px) {
    :root {
        --composer-lift: 8px;
        --header-pad-y: 10px;
        --input-pad-top: 8px;
        --input-pad-bottom: 12px;
        --footer-pad-y: 6px;
    }

    .chat-container {
        min-height: 0;
        height: 100vh;
        height: 100dvh;
        max-height: none;
    }

    .logo-mark { width: 40px; height: 40px; }
    .brand-text h1 { font-size: 20px; }
}

/* Phase 1 — layout polish & notifications */

.chat-container {
    border-color: var(--edge-visible);
}

.chat-header,
.input-area,
.chat-footer,
.input-wrap {
    border-color: var(--edge-soft);
}

.input-wrap {
    border-width: 1.5px;
    border-color: var(--edge-visible);
}

.brand {
    align-items: center;
    gap: 16px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.online-status {
    margin-top: 7px;
}

.pulse-dot {
    width: 9px;
    height: 9px;
}

.icon-btn:hover,
.action-btn:hover,
.prompt-card:hover {
    border-color: var(--focus-line);
    color: var(--text);
}

[data-theme="light"] .icon-btn:hover,
[data-theme="light"] .action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .prompt-card:hover {
    box-shadow: var(--shadow-md), 0 0 18px rgba(0, 0, 0, 0.06);
}

.notif-badge {
    display: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--online);
    margin-left: 4px;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.25);
    animation: notifPulse 1.5s ease-in-out infinite;
}

.notif-badge.is-visible {
    display: inline-block;
}

@keyframes notifPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.85; }
}

[data-theme="light"] .bot-row .message-bubble,
[data-theme="light"] .user-row .message-bubble {
    border-color: rgba(0, 0, 0, 0.14);
}

/* ============================================================
   EMBED MODE — full panel inside launcher iframe
   ============================================================ */

html.is-embed,
body.is-embed {
    height: 100%;
    min-height: 100%;
    min-height: 100dvh;
    padding: 0;
    overflow: hidden;
}

body.is-embed .bg-grid {
    display: none;
}

body.is-embed .chat-wrapper {
    max-width: none;
    height: 100%;
    animation: none;
}

body.is-embed .chat-container {
    height: 100%;
    max-height: none;
    min-height: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
}

body.is-embed {
    --composer-lift: 10px;
    --input-pad-bottom: 14px;
}

@media (max-width: 480px) {
    body.is-embed {
        --composer-lift: 14px;
        --input-pad-bottom: 16px;
    }
}

.embed-close[hidden] {
    display: none !important;
}

/* ============================================================
   RESOURCES PANEL
   ============================================================ */

.resources-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.resources-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(320px, calc(100vw - 32px));
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    z-index: 30;
}

.resources-panel[hidden] {
    display: none !important;
}

.resources-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.resources-panel-head h2 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.resources-panel-note {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.45;
    margin-bottom: 10px;
}

.resources-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.resource-link {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    text-decoration: none;
    transition: all 0.2s var(--ease);
}

.resource-link:hover {
    border-color: var(--border-strong);
    background: var(--accent-soft);
    transform: translateY(-1px);
}

.resource-link-title {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.resource-link-title svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.resource-link-whatsapp .resource-link-title svg {
    color: #25D366;
}

.resource-link-whatsapp:hover {
    border-color: rgba(37, 211, 102, 0.55);
}

.resource-link-desc {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.4;
}

/* ============================================================
   WELCOME ENTRANCE
   ============================================================ */

.welcome-entrance {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 28px 24px;
    text-align: center;
    background: linear-gradient(180deg, rgba(5, 5, 8, 0.94), rgba(5, 5, 8, 0.88));
    opacity: 0;
    transition: opacity 0.45s var(--ease);
    pointer-events: none;
}

[data-theme="light"] .welcome-entrance {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 248, 250, 0.92));
}

.welcome-entrance[hidden] {
    display: none !important;
}

.welcome-entrance.is-active {
    opacity: 1;
}

.welcome-entrance.is-exiting {
    opacity: 0;
}

.chat-box {
    position: relative;
}

.welcome-entrance-logo {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: contain;
    border: 1.5px solid var(--border-strong);
    box-shadow: var(--shadow-sm);
    opacity: 0;
    transform: scale(0.88) translateY(8px);
    transition: opacity 0.65s var(--ease), transform 0.65s var(--ease);
}

.welcome-entrance-logo.is-visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.welcome-entrance-text {
    min-height: 1.5em;
    max-width: 22ch;
    font-family: 'DM Sans', var(--font-body);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--text);
    letter-spacing: -0.01em;
}

.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: var(--text);
    animation: typewriterBlink 0.9s step-end infinite;
}

.message-bubble.is-typing p {
    margin: 0 0 10px;
}

.message-bubble.is-typing p:last-child {
    margin-bottom: 0;
}

@keyframes typewriterBlink {
    50% { opacity: 0; }
}

@container chat (max-width: 520px) {
    .brand-text h1 {
        font-size: 26px;
    }

    .logo-mark {
        width: 48px;
        height: 48px;
    }

    .header-top {
        gap: 10px;
    }

    .header-actions {
        gap: 6px;
    }
}

@media (max-width: 640px) {
    .welcome-entrance-text {
        font-size: 16px;
    }
}