@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* =========================
           Theme system (Light/Dark)
           - Centralized tokens via CSS variables
        ========================= */
:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --accent: #0d9488;
    --accent-2: #0891b2;
    --accent-strong: #0f766e;

    /* Dark defaultss */
    --bg: #0f172a;
    --stage: #0f172a;
    --stage-bg: linear-gradient(to bottom right, #0f172a, #1e293b, #0f172a);

    --text: #e2e8f0;
    --text-strong: #f1f5f9;
    --muted: #94a3b8;
    --muted-2: #9ca3af;

    --border: rgba(71, 85, 105, 0.7);
    --border-strong: rgba(255, 255, 255, 0.4);
    --divider: rgba(71, 85, 105, 0.5);

    --surface: rgba(15, 23, 42, 0.92);
    --surface-2: rgba(15, 23, 42, 0.98);
    --glass: rgba(255, 255, 255, 0.15);
    --glass-2: rgba(255, 255, 255, 0.20);

    --shadow-1: 0 4px 24px rgba(0, 0, 0, 0.35);
    --shadow-2: 0 20px 50px rgba(0, 0, 0, 0.5);

    --focus: rgba(45, 212, 191, 0.35);
    --focus-ring: 0 0 0 3px rgba(45, 212, 191, 0.18);

    --input-bg: rgba(15, 23, 42, 0.8);
    --input-border: #334155;
    --text-muted: #64748b;
}

html[data-theme="light"] {
    --bg: #f6f7fb;
    --stage: #f3f5fb;
    --stage-bg: radial-gradient(ellipse 100% 85% at 50% 50%, rgba(2, 132, 199, 0.10) 0%, rgba(2, 132, 199, 0.04) 45%, rgba(248, 250, 252, 0.95) 100%),
        radial-gradient(ellipse 90% 70% at 50% 20%, rgba(13, 148, 136, 0.10) 0%, rgba(13, 148, 136, 0.04) 55%, transparent 78%),
        #f3f5fb;

    --text: #0f172a;
    --text-strong: #0b1220;
    --muted: #475569;
    --muted-2: #64748b;

    --border: rgba(148, 163, 184, 0.65);
    --border-strong: rgba(15, 23, 42, 0.18);
    --divider: rgba(148, 163, 184, 0.55);

    --surface: rgba(255, 255, 255, 0.92);
    --surface-2: rgba(255, 255, 255, 0.97);
    --glass: rgba(15, 23, 42, 0.06);
    --glass-2: rgba(15, 23, 42, 0.08);

    --shadow-1: 0 10px 28px rgba(15, 23, 42, 0.10);
    --shadow-2: 0 30px 70px rgba(15, 23, 42, 0.18);

    --focus: rgba(13, 148, 136, 0.35);
    --focus-ring: 0 0 0 3px rgba(13, 148, 136, 0.18);

    --input-bg: rgba(255, 255, 255, 0.92);
    --input-border: rgba(148, 163, 184, 0.90);
    --text-muted: #64748b;
}

/* Smooth theme transition */
html,
body,
.app-stage,
.app-stage-bg,
.landing,
.layout,
.orb-box,
.chat-panel,
.landing-mode-btn,
.btn-end,
.btn-start,
.chat-input,
.touch-mode-input-inline,
.payment-modal-container,
.sign-form-container,
.end-session-popup,
.inactivity-popup,
.payment-complete-popup {
    transition: background-color 260ms ease, color 260ms ease, border-color 260ms ease, box-shadow 260ms ease, opacity 260ms ease, transform 0.2s ease-out;
    transform-origin: center center;
}

html {
    width: 100%;
    height: 100%;
    overflow: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

html::-webkit-scrollbar {
    display: none;
}

body {
    font-family: var(--font-sans);
    margin: 0;
    min-height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
}

/* Zoom viewport: contains the scaled app-stage, centers it, allows scroll when zoomed in */
.zoom-viewport {
    position: fixed;
    inset: 0;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 0;
}

/* At 100% zoom: no scrollbars, no overflow (reset removes overflow-x/overflow-y) */
.zoom-viewport.zoom-at-default {
    overflow: hidden;
}

/* Zoom controls: fixed position so always visible */
.zoom-controls {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.zoom-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1.5px solid var(--border-strong);
    background: var(--glass-2);
    color: var(--text-strong);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    box-shadow: var(--shadow-1);
}

.zoom-btn:hover {
    background: color-mix(in srgb, var(--glass-2) 85%, var(--accent) 15%);
    transform: scale(1.05);
}

.zoom-btn:active {
    transform: scale(0.98);
}

.zoom-btn i {
    font-size: 1.1rem;
}

.zoom-btn.zoom-reset i {
    font-size: 1rem;
}

html[data-theme="light"] .zoom-btn {
    background: var(--glass);
    color: var(--text-strong);
    border-color: var(--border-strong);
}

html[data-theme="light"] .zoom-btn:hover {
    background: var(--glass-2);
}

.app-stage {
    position: relative;
    width: 100vw;
    height: 100vh;
    aspect-ratio: 9 / 16;
    background: var(--stage-bg, var(--stage));
    overflow: hidden;
    flex-shrink: 0;
}

/* Zoom: only text/data scales via --zoom-text, not layout/body */
.app-stage-content {
    --zoom-text: 1;
    width: 100%;
    height: 100%;
    font-size: calc(16px * var(--zoom-text, 1));
    transition: font-size 0.2s ease-out;
}


/* Professional dark theme: deep navy with subtle teal accen */
.app-stage-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

#landing-view,
.layout {
    position: relative;
    z-index: 1;
}

/* Initial landing view – entire body centered in viewport */
.landing {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    margin: 0;
    box-sizing: border-box;
}

/* Landing zoom: logo, heading, buttons scale; wrap clips so data not outside body */
.landing-zoom-wrap {
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

#landing-zoom-box {
    transform-origin: center center;
    transition: transform 0.2s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100vh;
}

.landing-card {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    margin: 0 auto;
    background: transparent;
    box-shadow: none;
    border: none;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    box-sizing: border-box;
}

/* Logo: single responsive rule for all screens */
.landing-logo-image {
    max-width: 100%;
    width: 600px;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.landing-title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    color: var(--text-strong);
    line-height: 1.2;
    margin: 0;
}

.landing-subtitle {
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    color: var(--muted);
    margin: 0 0 0.5rem 0;
    max-width: 420px;
}

/* iOS-style glass button (from ios-animated-background.html) */
.landing-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 44px;
    border-radius: 30px;
    border: 1.5px solid rgba(45, 212, 191, 0.5);
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    background: rgba(13, 148, 136, 0.25);
    color: #f9fafb;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.landing-cta:hover {
    background: rgba(13, 148, 136, 0.4);
    border-color: rgba(45, 212, 191, 0.7);
    transform: scale(1.05);
}

.landing-cta:active {
    transform: scale(0.98);
    background: rgba(13, 148, 136, 0.2);
}

/* Status pill at bottom – image style with green dot */
.landing-status {
    margin-top: 1rem;
    padding: 10px 20px;
    min-height: 44px;
    font-size: clamp(0.9rem, 1.8vw, 1.05rem);
    color: var(--text-strong);
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    max-width: 90%;
}
.landing-status::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.8);
    flex-shrink: 0;
}
.landing-status:empty::after {
    content: "MIRA is ready to assist you";
}

.landing-mode-choice {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    margin-top: 0;
    width: 100%;
    max-width: 600px;
    justify-content: center;
}

.landing-mode-choice.visible {
    display: flex;
}

/* Glassmorphism cards – icon left, title + description */
.landing-mode-choice .landing-mode-btn.landing-mode-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    padding: 0;
    min-height: 0;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.landing-mode-choice .landing-mode-btn.landing-mode-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: scale(1.02);
}

/* Check In with Touch: dot pattern on background */
#landing-touch-btn {
    background-image: radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.07) 1px, transparent 0px);
    background-size: 10px 10px;
    background-color: rgba(255, 255, 255, 0.05);
}
#landing-touch-btn:hover {
    background-image: radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.1) 1px, transparent 0px);
    background-color: rgba(255, 255, 255, 0.08);
}


.landing-mode-btn-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
}

.landing-mode-btn-icon {
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.landing-mode-btn-icon i {
    font-size: 1.4rem;
    color: var(--text-strong);
}

.landing-mode-btn-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.landing-mode-btn-title {
    font-size: clamp(1rem, 2vw, 1.2rem);
    font-weight: 700;
    color: var(--text-strong);
}

.landing-mode-btn-desc {
    font-size: clamp(0.8rem, 1.5vw, 0.95rem);
    color: var(--muted);
    line-height: 1.4;
}

.landing-mode-choice .landing-mode-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent);
}

.landing-mode-choice .landing-mode-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

/* Light theme: borders visible on white background */
html[data-theme="light"] .landing-status {
    border-color: rgba(15, 23, 42, 0.15);
    background: rgba(15, 23, 42, 0.06);
}
html[data-theme="light"] .landing-mode-choice .landing-mode-btn.landing-mode-card {
    border-color: rgba(15, 23, 42, 0.12);
    background: rgba(15, 23, 42, 0.05);
}
html[data-theme="light"] .landing-mode-choice .landing-mode-btn.landing-mode-card:hover {
    border-color: rgba(15, 23, 42, 0.2);
    background: rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .landing-mode-btn-icon {
    border-color: rgba(15, 23, 42, 0.12);
    background: rgba(15, 23, 42, 0.06);
}
html[data-theme="light"] #landing-touch-btn {
    background-image: radial-gradient(circle at 2px 2px, rgba(15, 23, 42, 0.04) 1px, transparent 0px);
    background-size: 10px 10px;
    background-color: rgba(15, 23, 42, 0.05);
}
html[data-theme="light"] #landing-touch-btn:hover {
    background-image: radial-gradient(circle at 2px 2px, rgba(15, 23, 42, 0.06) 1px, transparent 0px);
    background-color: rgba(15, 23, 42, 0.08);
}

.layout {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(380px, 2.2fr);
    gap: 0;
    padding: 0;
}

/* Kiosk-friendly: remove side margins and allow content to span full width */
.voice-panel {
    padding-left: 0;
    padding-right: 0;
}

.voice-panel-inner {
    padding-left: 0;
    padding-right: 0;
}

.voice-panel {
    position: relative;
    border-radius: 0;
    padding: 20px 0px 35px 24px;
    background: transparent;
    box-shadow: none;
    overflow: visible;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.voice-panel::before {
    content: none;
}

.voice-panel-inner {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.voice-orb-position {
    position: fixed;
    left: 50%;
    top: 20%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: auto;
    z-index: 1;
    pointer-events: none;
}

.voice-orb-position .voice-orb-wrap,
.voice-orb-position .controls-row {
    pointer-events: auto;
}

.orb-boxes-position {
    position: fixed;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
    max-height: 95vh;
    overflow: visible;
    z-index: 100;
    pointer-events: none;
}

.orb-boxes-position .orb-message-boxes {
    pointer-events: auto;
    max-width: 720px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.orb-boxes-position .touch-mode-only {
    pointer-events: auto;
    width: 100%;
    max-width: 720px;
    min-width: 0;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
}

/* Zoom wrap: overflow visible so zoomed content is not hidden inside body */
.orb-boxes-zoom-wrap {
    overflow: visible;
    width: 100%;
    max-width: 100%;
    max-height: 95vh;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#orb-boxes-zoom-box {
    width: 100%;
    min-width: 0;
    transform-origin: center center;
    transition: transform 0.2s ease-out;
}

.voice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.title-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, #0d9488, #0891b2, #0e7490);
    position: relative;
    padding: 2px;
}

.logo-inner {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: radial-gradient(circle at 30% 0, rgba(248, 250, 252, 0.25), transparent 40%),
        #0c1222;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.title-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.title-text p {
    margin-top: 2px;
    font-size: 0.825rem;
    color: #94a3b8;
}

.session-pill {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(71, 85, 105, 0.6);
    color: #e2e8f0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: default;
}

.session-pill span {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-pill button {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.state-row {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 28px;
    gap: 12px;
}

.state-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 1.2rem;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(71, 85, 105, 0.7);
    color: #e2e8f0;
}

.state-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #6b7280;
}

.state-badge.listening {
    border-color: rgba(34, 197, 94, 0.7);
    background: rgba(6, 78, 59, 0.7);
}

.state-badge.listening .state-dot {
    background: #22c55e;
    animation: pulse 1.6s infinite;
}

.state-badge.speaking {
    border-color: rgba(59, 130, 246, 0.8);
    background: rgba(30, 64, 175, 0.75);
}

.state-badge.speaking .state-dot {
    background: #3b82f6;
    animation: pulse 1.6s infinite;
}

.state-badge.barge-in {
    border-color: rgba(251, 191, 36, 0.9);
    background: rgba(120, 53, 15, 0.8);
}

.state-badge.barge-in .state-dot {
    background: #fbbf24;
    animation: pulse 0.75s infinite;
}

.state-badge.error {
    border-color: rgba(239, 68, 68, 0.8);
    background: rgba(127, 29, 29, 0.85);
}

.state-badge.error .state-dot {
    background: #f97373;
}

.help-row {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    order: -1;
}

.btn-help {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid rgba(71, 85, 105, 0.7);
    background: rgba(15, 23, 42, 0.85);
    color: #e2e8f0;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-help:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(148, 163, 184, 0.8);
}

html[data-theme="light"] .btn-help {
    background: var(--glass);
    color: var(--text-strong);
    border-color: var(--border-strong);
}

html[data-theme="light"] .btn-help:hover {
    background: var(--glass-2);
    border-color: var(--border);
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.25);
        opacity: 0.6;
    }
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    margin-bottom: 32px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 480px;
}

.orb-message-boxes {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: 32px;
    margin-bottom: 24px;
    pointer-events: auto;
    box-sizing: border-box;
}

.orb-box {
    width: 100%;
    min-width: 0;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border) 82%);
    overflow: hidden;
    box-shadow: var(--shadow-1);
}

.orb-box-title {
    padding: 16px 16px;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-strong);
    background: transparent;
    border-bottom: none;
}

.orb-box-content {
    padding: 20px 16px;
    min-height: 140px;
    max-height: 280px;
    overflow-y: auto;
    font-size: 1.1rem;
    line-height: 1.55;
    color: var(--muted);
}

.orb-box-content:empty::before {
    content: "\00a0";
    display: block;
}

.orb-message-boxes-single {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.orb-box-conversation .orb-box-conversation-content {
    width: 100%;
    min-width: 0;
    height: 400px;
    min-height: 380px;
    max-height: 380px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(45, 212, 191, 0.5) rgba(15, 23, 42, 0.95);
    -webkit-overflow-scrolling: touch;
}

.orb-box-conversation .orb-box-conversation-content::-webkit-scrollbar {
    width: 8px;
}

.orb-box-conversation .orb-box-conversation-content::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.95);
    border-radius: 4px;
}

.orb-box-conversation .orb-box-conversation-content::-webkit-scrollbar-thumb {
    background: rgba(45, 212, 191, 0.5);
    border-radius: 4px;
}

.orb-box-conversation .orb-box-conversation-content::-webkit-scrollbar-thumb:hover {
    background: rgba(45, 212, 191, 0.7);
}

.conv-entry {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 1.4rem;
    line-height: 1.5;
    word-break: break-word;
    max-width: 100%;
}

.conv-entry .conv-label {
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    color: #94a3b8;
}

.conv-entry.conv-assistant .conv-label {
    color: #67e8f9;
}

.conv-entry.conv-user .conv-label {
    color: #a78bfa;
}

.conv-entry.conv-assistant {
    align-self: flex-start;
    background: rgba(6, 78, 59, 0.4);
    border-left: 3px solid #2dd4bf;
    color: #ccfbf1;
}

.conv-entry.conv-user {
    align-self: flex-end;
    background: rgba(67, 56, 202, 0.35);
    border-right: 3px solid #a78bfa;
    color: #e9d5ff;
}

.mic-shell {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.mic-circle {
    width: 130px;
    height: 130px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 0, rgba(248, 250, 252, 0.3), transparent 50%),
        rgba(15, 23, 42, 0.95);
    border: 2px solid rgba(148, 163, 184, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.0);
    transition: all 0.2s ease-out;
}

.mic-circle .inner-glow {
    position: absolute;
    inset: 10px;
    border-radius: inherit;
    background: radial-gradient(circle at 50% 0, rgba(96, 165, 250, 0.5), transparent 55%);
    opacity: 0.0;
    pointer-events: none;
    transition: opacity 0.25s ease-out;
}

.mic-circle i {
    position: relative;
    z-index: 1;
    font-size: 40px;
    color: #e2e8f0;
}

.mic-circle.listening {
    border-color: rgba(34, 197, 94, 0.9);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    animation: micPulse 1.6s infinite;
}

.mic-circle.listening .inner-glow {
    opacity: 1;
}

.mic-circle.speaking {
    border-color: rgba(59, 130, 246, 0.9);
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    animation: micPulse 1.8s infinite;
}

.mic-circle.barge-in {
    border-color: rgba(251, 191, 36, 0.95);
    box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.6);
    animation: micPulse 0.9s infinite;
}

@keyframes micPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.45);
    }

    70% {
        box-shadow: 0 0 0 26px rgba(59, 130, 246, 0.0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.0);
    }
}

.mic-label {
    font-size: 0.9rem;
    color: #94a3b8;
}

.primary-actions {
    display: flex;
    flex-direction: row;
    gap: 16px;
    align-items: center;
    position: absolute;
    bottom: 22px;
    right: 88px;
    z-index: 500;
    pointer-events: auto;
}

.primary-actions button {
    border-radius: 999px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 500;
    padding: 10px 18px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.16s ease-out;
}

.btn-start {
    border: none;
    background: linear-gradient(135deg, #0d9488, #0f766e);
    color: white;
    box-shadow: 0 10px 30px rgba(13, 148, 136, 0.45);
}

.btn-start:hover:enabled {
    transform: translateY(-1px);
    box-shadow: 0 16px 35px rgba(13, 148, 136, 0.55);
}

.btn-start:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* End session button (with text) */
.btn-end {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    background: rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
    border: 1.5px solid rgba(255, 255, 255, 0.4);

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    padding: 10px 18px;
    border-radius: 999px;

    white-space: nowrap;
    /* ⭐ prevents text breaking */

    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: background 0.3s, border-color 0.3s;
}

.btn-end:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
}

/* End session button – visible in light theme */
html[data-theme="light"] .btn-end {
    background: var(--glass);
    color: var(--text-strong);
    border-color: var(--border-strong);
}

html[data-theme="light"] .btn-end:hover {
    background: var(--glass-2);
    border-color: var(--border);
}

.btn-end i {
    font-size: 1.2rem;
}

/* End session confirmation popup */
.end-session-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 510;
    pointer-events: auto;
}

.end-session-overlay.active {
    display: flex;
}

.end-session-popup {
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(45, 212, 191, 0.3);
    border-radius: 16px;
    padding: 24px;
    max-width: 420px;
    width: 90%;
    margin: 24px auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.end-session-popup h4 {
    margin: 0 0 12px 0;
    font-size: 1.2rem;
    color: #e2e8f0;
}

.end-session-popup p {
    margin: 0 0 20px 0;
    font-size: 1.2rem;
    color: #94a3b8;
    line-height: 1.5;
}

.end-session-popup-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.end-session-popup-actions button {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
}

.end-session-cancel {
    background: rgba(71, 85, 105, 0.8);
    color: #e2e8f0;
}

.end-session-cancel:hover {
    background: rgba(71, 85, 105, 1);
}

.end-session-confirm {
    background: linear-gradient(135deg, #0d9488, #0f766e);
    color: white;
}

.end-session-confirm:hover {
    opacity: 0.95;
}

/* Inactivity popup */
.inactivity-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 401;
    pointer-events: auto;
}

.inactivity-overlay.active {
    display: flex;
}

.inactivity-popup {
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(45, 212, 191, 0.3);
    border-radius: 16px;
    padding: 24px 28px;
    max-width: 360px;
    width: 90%;
    margin: 24px auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.inactivity-popup .inactivity-message {
    margin: 0 0 20px 0;
    font-size: 1.2rem;
    color: #e2e8f0;
    text-align: center;
}

.inactivity-popup-actions {
    display: flex;
    justify-content: center;
}

.inactivity-yes-btn {
    padding: 10px 32px;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: linear-gradient(135deg, #0d9488, #0f766e);
    color: white;
}

.inactivity-yes-btn:hover {
    background: #0f766e;
}

/* Big popup after payment complete: at top, chat box stays visible and readable below */
.payment-complete-overlay {
    position: fixed;
    inset: 0;
    background: transparent;
    display: none;
    z-index: 402;
    pointer-events: none;
}

.payment-complete-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.payment-complete-overlay.active .payment-complete-popup {
    pointer-events: auto;
}

.payment-complete-popup {
    position: relative;
    margin: 24px auto;
    background: rgba(15, 23, 42, 0.98);
    border: 2px solid rgba(45, 212, 191, 0.4);
    border-radius: 20px;
    padding: 40px 48px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.payment-complete-popup h3 {
    margin: 0 0 16px 0;
    font-size: 1.2rem;
    color: #e2e8f0;
}

.payment-complete-popup p {
    margin: 0 0 28px 0;
    font-size: 1.4rem;
    color: #94a3b8;
    line-height: 1.6;
}

.payment-complete-end-btn {
    padding: 16px 40px;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: linear-gradient(135deg, #0d9488, #0f766e);
    color: white;
}

.payment-complete-end-btn:hover {
    opacity: 0.95;
}

.hint-text {
    font-size: 0.8rem;
    color: #9ca3af;
}

.assistant-banner {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px dashed rgba(71, 85, 105, 0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-size: 0.8rem;
    color: #9ca3af;
}

.assistant-banner strong {
    color: #e2e8f0;
}

/* iOS-style glass button */
.chat-toggle {
    position: absolute;
    right: 16px;
    bottom: 22px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.15);
    color: #f9fafb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 2;
}

.chat-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

.chat-toggle:active {
    transform: scale(0.98);
}

.chat-toggle i {
    font-size: 1.2rem;
}

.assistant-tag-pill {
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(13, 148, 136, 0.25);
    border: 1px solid rgba(45, 212, 191, 0.5);
    font-size: 0.75rem;
    color: #e2e8f0;
}

.chat-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 400px;
    height: 100vh;
    border-radius: 0;
    padding: 22px 22px 16px;
    background: var(--surface-2);
    border: none;
    border-left: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border) 72%);
    box-shadow: var(--shadow-2);
    display: flex;
    flex-direction: column;
    min-height: 0;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease-out;
}

.chat-panel.open {
    transform: translateX(0);
}

.chat-panel.open {
    transform: translateX(0);
}

/* Touch mode: hide voice orb/primary actions/state badge; show orb-boxes + input under it; hide chat-panel.
           Help row stays visible (same backend-driven Help as voice). Only one End Session (touch-mode-end-btn); voice #end-btn hidden.
           Use #app-view (id) not .app-view (class) - element has id="app-view" and class="layout". */
#app-view.touch-mode .voice-orb-position,
#app-view.touch-mode .primary-actions,
#app-view.touch-mode .btn-end,
#app-view.touch-mode .state-badge {
    display: none !important;
}

#app-view.touch-mode .state-row {
    justify-content: flex-end;
}

#app-view.touch-mode .chat-panel {
    display: none !important;
}

#app-view.touch-mode.layout {
    grid-template-columns: 1fr;
    max-width: 100%;
}

#app-view.touch-mode .voice-panel {
    min-height: 0;
}

#app-view.touch-mode .touch-mode-end-row {
    margin-top: 2rem;
}

.touch-mode-only {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 12px 0 16px;
    flex-shrink: 0;
}

.touch-mode-input-row {
    margin-bottom: 0;
}

.touch-mode-form {
    width: 100%;
    box-sizing: border-box;
}

.touch-mode-input-inline {
    display: flex;
    align-items: center;
    gap: 0;
    width: 100%;
    min-height: 42px;
    max-height: calc(5.5rem + 12px);
    padding: 6px 6px 6px 14px;
    border: 1px solid var(--input-border, #334155);
    border-radius: 12px;
    background: var(--input-bg, rgba(15, 23, 42, 0.8));
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.touch-mode-form:focus-within .touch-mode-input-inline {
    border-color: rgba(45, 212, 191, 0.5);
    box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.15);
}

.touch-mode-input-inline textarea {
    flex: 1;
    min-width: 0;
    min-height: 42px;
    max-height: 5.5rem;
    padding: 10px 8px 10px 0;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 1.2rem;
    line-height: 1;
    resize: none;
    box-sizing: border-box;
    overflow-y: auto;
    /* Scrollable when content grows, but scrollbar chrome hidden (touch + mouse wheel still work). */
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.touch-mode-input-inline textarea::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.touch-mode-input-inline textarea:focus {
    outline: none;
}

.touch-mode-input-inline textarea::placeholder {
    color: var(--text-muted);
}

/* Touch-mode input – light theme: visible text and placeholder */
html[data-theme="light"] .touch-mode-input-inline {
    background: var(--input-bg);
    border-color: var(--input-border);
}

html[data-theme="light"] .touch-mode-form:focus-within .touch-mode-input-inline {
    border-color: var(--focus);
    box-shadow: var(--focus-ring);
}

html[data-theme="light"] .touch-mode-input-inline textarea {
    color: var(--text-strong);
}

html[data-theme="light"] .touch-mode-input-inline textarea::placeholder {
    color: var(--muted);
}

/* Theme toggle button */
.theme-toggle {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 2000;
    border: 1px solid var(--border-strong);
    background: var(--glass);
    color: var(--text-strong);
    padding: 10px 14px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--shadow-1);
    user-select: none;
}

.theme-toggle:hover {
    background: color-mix(in srgb, var(--glass) 80%, var(--accent) 20%);
}

.theme-toggle:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.theme-toggle .theme-toggle-label {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.touch-mode-send-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    min-width: 32px;
    min-height: 32px;
    margin: 0 6px 0 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--accent, #0d9488);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.2s ease, transform 0.1s ease;
}

.touch-mode-send-btn:hover {
    background: #0f766e;
}

.touch-mode-send-btn:active {
    transform: scale(0.96);
}

/* Touch mode: suggestions from backend (same pattern as index_chat_smart_suggestion_test) */
.touch-mode-suggestions-row {
    width: 100%;
    margin: 0 auto 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    min-height: 0;
}

.touch-mode-suggestions-row:not(:empty) {
    min-height: 36px;
}

.touch-mode-suggestion-chip {
    padding: 0.4rem 0.75rem;
    background: rgba(45, 212, 191, 0.2);
    border: 1px solid rgba(45, 212, 191, 0.4);
    border-radius: 20px;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.touch-mode-suggestion-chip:hover {
    background: rgba(45, 212, 191, 0.35);
    border-color: var(--accent, #0d9488);
    transform: translateY(-1px);
}

html[data-theme="light"] .touch-mode-suggestion-chip {
    background: rgba(13, 148, 136, 0.12);
    border-color: rgba(13, 148, 136, 0.35);
    color: var(--text-strong);
}

html[data-theme="light"] .touch-mode-suggestion-chip:hover {
    background: rgba(13, 148, 136, 0.2);
    border-color: var(--accent);
}

.touch-mode-end-row {
    width: 100%;
    max-width: 720px;
    margin: 0.75rem auto 0;
    display: flex;
    justify-content: center;
}

/* Same style and size as voice screen .btn-end (Check-In Using Voice) */
.touch-mode-end-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 1.2rem;
    font-weight: 500;
    border-radius: 999px;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    cursor: pointer;
    transition: background 0.3s, border-color 0.3s;
}

.touch-mode-end-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
}

.touch-mode-end-btn:active {
    transform: scale(0.98);
}

.touch-mode-end-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

html[data-theme="light"] .touch-mode-end-btn {
    background: var(--glass);
    color: var(--text-strong);
    border-color: var(--border-strong);
}

html[data-theme="light"] .touch-mode-end-btn:hover {
    background: var(--glass-2);
    border-color: var(--border);
}

.touch-mode-end-btn i {
    font-size: 1.2rem;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.chat-header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-header-left h2 {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-strong);
}

.chat-header-left span {
    font-size: 0.8rem;
    color: var(--muted-2);
}

.chip {
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(71, 85, 105, 0.85);
    font-size: 0.75rem;
    color: #cbd5e1;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(45, 212, 191, 0.5) rgba(15, 23, 42, 0.98);
    -webkit-overflow-scrolling: touch;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.98);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(45, 212, 191, 0.5);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(45, 212, 191, 0.7);
}

.message {
    margin-bottom: 10px;
    display: flex;
}

.message.system {
    justify-content: center;
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.bubble {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.message.user .bubble {
    background: linear-gradient(135deg, #0d9488, #0891b2);
    color: #f9fafb;
    border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(71, 85, 105, 0.8);
    color: #e2e8f0;
    border-bottom-left-radius: 4px;
}

.message.system .bubble {
    background: rgba(13, 148, 136, 0.2);
    border: 1px dashed rgba(45, 212, 191, 0.5);
    color: #e2e8f0;
    max-width: 100%;
    text-align: center;
}

.message.error .bubble {
    background: rgba(127, 29, 29, 0.8);
    border-color: rgba(248, 113, 113, 0.85);
    color: #fecaca;
}

.typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #14b8a6;
    opacity: 0.3;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.3;
    }

    30% {
        transform: translateY(-3px);
        opacity: 1;
    }
}

.conv-entry.conv-typing {
    padding: 12px 14px;
    min-height: 20px;
    background: transparent;
    border: none;
    border-left: none;
    box-shadow: none;
}

.conv-entry.conv-typing .typing-dot {
    background: #2dd4bf;
}

/* Conversation panel – light theme: bg and text for entries and scrollbar */
html[data-theme="light"] .orb-box-conversation .orb-box-conversation-content {
    scrollbar-color: rgba(13, 148, 136, 0.4) rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .orb-box-conversation .orb-box-conversation-content::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .orb-box-conversation .orb-box-conversation-content::-webkit-scrollbar-thumb {
    background: rgba(13, 148, 136, 0.4);
}

html[data-theme="light"] .orb-box-conversation .orb-box-conversation-content::-webkit-scrollbar-thumb:hover {
    background: rgba(13, 148, 136, 0.55);
}

html[data-theme="light"] .conv-entry .conv-label {
    color: var(--muted);
}

html[data-theme="light"] .conv-entry.conv-assistant .conv-label {
    color: #0d9488;
}

html[data-theme="light"] .conv-entry.conv-user .conv-label {
    color: #7c3aed;
}

html[data-theme="light"] .conv-entry.conv-assistant {
    background: rgba(13, 148, 136, 0.12);
    border-left-color: #0d9488;
    color: var(--text-strong);
}

html[data-theme="light"] .conv-entry.conv-user {
    background: rgba(124, 58, 237, 0.12);
    border-right-color: #7c3aed;
    color: var(--text-strong);
}

html[data-theme="light"] .conv-entry.conv-typing .typing-dot {
    background: #0d9488;
}

.chat-input {
    margin-top: auto;
    flex-shrink: 0;
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface-2) 55%, var(--bg) 45%);
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    padding: 10px 14px 10px 16px;
    gap: 10px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input:focus-within {
    border-color: var(--focus);
    box-shadow: var(--focus-ring);
}

.chat-input-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.chat-input textarea {
    width: 100%;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 0.9375rem;
    line-height: 1.5;
    max-height: 90px;
    min-height: 36px;
    padding: 8px 0;
    -webkit-appearance: none;
    appearance: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chat-input textarea::-webkit-scrollbar {
    display: none;
}

.chat-input textarea::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #0d9488, #0891b2);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    box-shadow: 0 8px 20px rgba(13, 148, 136, 0.5);
    transition: transform 0.15s ease-out, box-shadow 0.15s ease-out, opacity 0.15s ease-out;
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(13, 148, 136, 0.6);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* Camera modal – card capture (integrated from camera flow) */
.camera-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 300;
    flex-direction: column;
    gap: 24px;
}

.camera-modal.active {
    display: flex;
}

.camera-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 20;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.2s, border-color 0.2s;
}

.camera-close-btn:hover {
    background: rgba(220, 38, 38, 0.8);
    border-color: rgba(255, 255, 255, 0.8);
}

.camera-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 1080px;
    max-height: 1920px;
    margin: 0 auto;
    background: #000;
    overflow: hidden;
}

#camera-video {
    width: 100%;
    height: auto;
    display: block;
}

#camera-canvas {
    display: none;
}

.camera-instructions {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 18px;
    text-align: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 15px 30px;
    border-radius: 30px;
    z-index: 10;
}

/* Sign form modal – white theme */
.sign-form-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 350;
    padding: 24px;
    box-sizing: border-box;
}

.sign-form-modal.active {
    display: flex;
}

.sign-form-container {
    background: var(--surface-2);
    color: var(--text);
    border-radius: 16px;
    box-shadow: var(--shadow-2);
    width: min(95vw, 1080px);
    height: min(85vh, 1920px);
    max-width: 95vw;
    max-height: 70vh;
    margin: 24px auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sign-form-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sign-form-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--divider);
    flex-shrink: 0;
}

.sign-form-header h3 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-strong);
    margin: 0 0 8px 0;
    text-align: center;
}

.sign-form-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.sign-form-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.sign-form-description {
    font-size: 1.2rem;
    color: var(--muted);
    overflow-wrap: break-word;
}

.sign-form-description :deep(h1),
.sign-form-description :deep(h2) {
    font-size: 1rem;
    margin: 0.5em 0 0.25em 0;
    color: #374151;
}

.sign-form-description :deep(p) {
    margin: 0.25em 0;
}

.sign-form-body {
    padding: 20px 24px;
}

.sign-form-field {
    margin-bottom: 18px;
}

.sign-form-field label {
    display: block;
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-strong);
    margin-bottom: 6px;
}

.sign-form-field label .required {
    color: #dc2626;
}

.sign-form-field.invalid input,
.sign-form-field.invalid textarea {
    border-color: #dc2626;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}

.sign-form-field.invalid input[type="checkbox"] {
    outline: 2px solid #dc2626;
}

.sign-form-field.invalid label {
    color: #b91c1c;
}

.sign-form-field input:not([type="checkbox"]),
.sign-form-field textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 1.2rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    color: #1f2937;
    box-sizing: border-box;
}

.sign-form-field input:not([type="checkbox"]):focus,
.sign-form-field textarea:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.sign-form-field input[type="checkbox"] {
    display: block;
    width: 20px;
    height: 20px;
    margin-top: 8px;
    margin-left: 0;
    cursor: pointer;
    accent-color: #4f46e5;
}

.sign-form-field textarea {
    min-height: 80px;
    resize: vertical;
}

.sign-form-footer {
    padding: 16px 24px 24px;
    border-top: 1px solid var(--divider);
    flex-shrink: 0;
    display: flex;
    gap: 12px;
    justify-content: stretch;
}

.sign-form-footer .btn-close,
.sign-form-footer .btn-submit {
    flex: 1;
    max-width: 100%;
}

.sign-form-modal .btn-close {
    padding: 18px 18px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
}

.sign-form-modal .btn-close:hover {
    background: #f3f4f6;
}

.sign-form-modal .btn-submit {
    padding: 18px 18px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
}

.sign-form-modal .btn-submit:hover:not(:disabled) {
    opacity: 0.95;
    transform: translateY(-1px);
}

.sign-form-modal .btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.sign-form-error {
    padding: 10px 14px;
    margin-bottom: 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #b91c1c;
    font-size: 0.9rem;
}

/* Payment iframe modal (child payment page) */
.payment-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 360;
    padding: 24px;
    box-sizing: border-box;
}

.payment-modal.active {
    display: flex;
}

.payment-modal-container {
    background: var(--surface-2);
    border-radius: 16px;
    box-shadow: var(--shadow-2);
    width: min(95vw, 1080px);
    height: min(85vh, 1920px);
    max-width: 95vw;
    max-height: 85vh;
    margin: 24px auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.payment-modal-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.payment-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-strong);
}

.payment-modal-close {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.payment-modal-close:hover {
    background: #f3f4f6;
}

.payment-iframe-wrap {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.payment-iframe-wrap iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.camera-controls {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
}

.camera-btn {
    padding: 20px 50px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50px;
    background: rgba(200, 200, 200, 0.25);
    backdrop-filter: blur(20px);
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    color: white;
    transition: all 0.3s ease;
}

.camera-btn:hover {
    background: rgba(220, 220, 220, 0.35);
    transform: translateY(-3px);
}

.detection-canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#detection-display-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#detection-processing-canvas {
    display: none;
}

.detection-roi-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 55%;
    border: 3px dashed rgba(255, 255, 255, 0.6);
    border-radius: 15px;
    pointer-events: none;
}

.detection-roi-frame.detected {
    border-color: #10b981;
    border-style: solid;
}

.detection-roi-label {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: #4CAF50;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 20px;
    border-radius: 20px;
}

.upload-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
    z-index: 20;
}

.upload-loading.active {
    display: flex;
}

.upload-loading .spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.upload-loading p {
    color: white;
    font-size: 18px;
}

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


/* Hide zoom controls on small screens (tablets and below) */
@media (max-width: 1024px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .zoom-controls {
        display: none !important;
    }
}

/* State row + Help: responsive for small devices */
@media (max-width: 768px) {
    .zoom-controls {
        bottom: 12px;
        left: 12px;
        gap: 6px;
    }

    .zoom-btn {
        width: 38px;
        height: 38px;
    }

    .zoom-btn i {
        font-size: 1rem;
    }

    .state-row {
        margin-bottom: 20px;
        gap: 10px;
    }

    .state-badge {
        font-size: 1rem;
        padding: 6px 12px;
        gap: 8px;
    }

    .state-badge .state-dot {
        width: 8px;
        height: 8px;
    }

    .btn-help {
        font-size: 1rem;
        padding: 6px 12px;
        gap: 6px;
    }

    .btn-help i {
        font-size: 0.95rem;
    }

    .primary-actions {
        left: 50%;
        right: auto;
        bottom: 20px;
        transform: translateX(-50%);
        justify-content: center;
    }

    .theme-toggle .theme-toggle-label {
        display: none;
    }
}

@media (max-width: 480px) {
    .zoom-controls {
        bottom: 10px;
        left: 10px;
        gap: 5px;
    }

    .theme-toggle {
        top: 22px;
    }

    .zoom-btn {
        width: 36px;
        height: 36px;
    }

    .zoom-btn i {
        font-size: 0.95rem;
    }

    .state-row {
        margin-top: 25px;
        margin-bottom: 15px;
        gap: 8px;
        display: grid;
    }

    .state-badge {
        font-size: 0.9rem;
        padding: 5px 10px;
        gap: 6px;
        width: max-content;
    }

    .state-badge .state-dot {
        width: 6px;
        height: 6px;
    }

    .btn-help {
        font-size: 0.9rem;
        padding: 5px 10px;
        gap: 5px;
    }

    .btn-help i {
        font-size: 0.9rem;
    }

    .primary-actions {
        bottom: 20px;
        gap: 12px;
    }

    .primary-actions button {
        font-size: 1rem;
        padding: 8px 14px;
        gap: 6px;
    }
}

/* =============================================================================
   Medical kiosk UI – Deepgram page only (body.kiosk-ui). Voice/Touch IDs unchanged.
   ============================================================================= */

body.kiosk-ui {
    --kiosk-navy: #0b1220;
    --kiosk-navy-soft: #1e293b;
    --kiosk-blue: #1d4ed8;
    --kiosk-slate: #64748b;
    --kiosk-line: rgba(15, 23, 42, 0.12);
    --kiosk-card-shadow: 0 14px 44px rgba(15, 23, 42, 0.09);
    --kiosk-assistant-bubble: #0a0f18;
    --kiosk-user-bubble: #ebe8f4;
    --kiosk-user-bubble-border: rgba(15, 23, 42, 0.09);
    --kiosk-footer-h: 92px;
    --kiosk-top-h: 64px;
}

/* Soft wave/light gray stage + dark footer band */
html[data-theme="light"] body.kiosk-ui .app-stage-bg {
    background:
        radial-gradient(ellipse 140% 90% at 50% -20%, rgba(255, 255, 255, 0.95) 0%, transparent 50%),
        radial-gradient(ellipse 80% 50% at 20% 60%, rgba(241, 245, 249, 0.9) 0%, transparent 45%),
        radial-gradient(ellipse 70% 45% at 85% 40%, rgba(248, 250, 252, 0.85) 0%, transparent 40%),
        linear-gradient(180deg, #f7f8fb 0%, #eef1f6 72%, #e6eaf0 100%);
}

html[data-theme="light"] body.kiosk-ui .app-stage {
    background: linear-gradient(
        180deg,
        transparent 0%,
        transparent calc(100% - var(--kiosk-footer-h)),
        #0d1117 calc(100% - var(--kiosk-footer-h)),
        #0d1117 100%
    );
}

html[data-theme="dark"] body.kiosk-ui .app-stage-bg {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 78%, #020617 100%);
}

html[data-theme="dark"] body.kiosk-ui .app-stage {
    background: linear-gradient(
        180deg,
        transparent 0%,
        transparent calc(100% - var(--kiosk-footer-h)),
        #020617 calc(100% - var(--kiosk-footer-h)),
        #020617 100%
    );
}

body.kiosk-ui .kiosk-top-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 10px clamp(14px, 3vw, 28px);
    pointer-events: none;
}

body.kiosk-ui .kiosk-top-bar > * {
    pointer-events: auto;
}

body.kiosk-ui .kiosk-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Assembly / kiosk header: Help sits next to theme toggle (same row as kiosk-top-actions) */
body.kiosk-ui .kiosk-top-actions .kiosk-top-help-row {
    order: -1;
    margin: 0;
    position: relative;
    z-index: 2110;
}

body.kiosk-ui .kiosk-top-actions .kiosk-header-help-btn {
    padding: 10px 16px;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.85);
    background: #0f172a;
    color: #f8fafc;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.15);
}

html[data-theme="dark"] body.kiosk-ui .kiosk-top-actions .kiosk-header-help-btn {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(148, 163, 184, 0.4);
    color: #f1f5f9;
}

html[data-theme="light"] body.kiosk-ui .kiosk-top-actions .kiosk-header-help-btn {
    background: #0f172a;
    border-color: rgba(15, 23, 42, 0.85);
    color: #f8fafc;
}

body.kiosk-ui .theme-toggle.kiosk-theme-toggle {
    position: static;
    top: auto;
    right: auto;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.85);
    background: #0f172a;
    color: #f8fafc;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.15);
    padding: 10px 12px;
    font-size: clamp(0.95rem, 2.2vw, 1.05rem);
    font-weight: 600;
    z-index: 2100;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
}

html[data-theme="dark"] body.kiosk-ui .theme-toggle.kiosk-theme-toggle {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(148, 163, 184, 0.4);
    color: #f1f5f9;
}

/* Zoom: bottom-left (above safe area / footer band) */
body.kiosk-ui .zoom-controls {
    top: auto;
    right: auto;
    left: max(16px, env(safe-area-inset-left, 0px));
    bottom: max(20px, env(safe-area-inset-bottom, 0px));
    flex-direction: column;
    z-index: 2200;
}

body.kiosk-ui .landing-logo-image {
    display: block;
    width: auto;
    max-width: min(420px, 88vw);
    height: auto;
    margin: 0 auto clamp(0.75rem, 2vh, 1.25rem);
    object-fit: contain;
}

body.kiosk-ui .landing {
    padding: calc(var(--kiosk-top-h) + 8px) clamp(16px, 4vw, 28px) max(100px, calc(var(--kiosk-footer-h) + 56px));
    min-height: 100vh;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.kiosk-ui .landing-zoom-wrap {
    min-height: calc(100vh - var(--kiosk-top-h));
    width: 100%;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.kiosk-ui #landing-zoom-box {
    min-height: calc(100vh - var(--kiosk-top-h));
    width: 100%;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.kiosk-ui .landing-card {
    gap: clamp(1rem, 3vw, 1.5rem);
    justify-content: center;
    align-items: center;
    padding-top: 0;
    width: 100%;
    max-width: min(560px, 100%);
    height: auto;
    min-height: 0;
}

body.kiosk-ui .landing-title {
    font-size: clamp(1.65rem, 5vw, 2.35rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--kiosk-navy);
    max-width: 22ch;
    line-height: 1.15;
    text-align: center;
}

html[data-theme="dark"] body.kiosk-ui .landing-title {
    color: var(--text-strong);
}

body.kiosk-ui .landing-subtitle {
    max-width: 28ch;
    font-size: clamp(0.95rem, 2.8vw, 1.12rem);
    color: var(--kiosk-slate);
    line-height: 1.45;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

body.kiosk-ui .landing-mode-choice {
    max-width: min(540px, 100%);
    width: 100%;
    gap: clamp(12px, 2.5vw, 18px);
    align-items: stretch;
}

body.kiosk-ui .landing-mode-choice .landing-mode-btn.landing-mode-card {
    border-radius: clamp(18px, 3vw, 24px);
    border: 1px solid var(--kiosk-line);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: var(--kiosk-card-shadow);
    min-height: clamp(100px, 22vw, 128px);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

body.kiosk-ui .landing-mode-choice .landing-mode-btn.landing-mode-card:hover {
    transform: translateY(-3px);
}

body.kiosk-ui .landing-mode-btn-inner {
    align-items: center;
    gap: clamp(12px, 3vw, 18px);
    padding: clamp(16px, 3.5vw, 22px) clamp(16px, 3vw, 22px);
    padding-right: clamp(52px, 14vw, 64px);
    position: relative;
}

body.kiosk-ui .landing-mode-btn-icon {
    width: clamp(52px, 12vw, 64px);
    height: clamp(52px, 12vw, 64px);
    min-width: clamp(52px, 12vw, 64px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.kiosk-ui .landing-mode-btn-icon i {
    font-size: clamp(1.25rem, 3.5vw, 1.5rem);
}

body.kiosk-ui .landing-mode-btn-content {
    gap: 6px;
}

body.kiosk-ui .landing-mode-btn-title {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: inherit;
    font-weight: inherit;
    line-height: 1.15;
}

body.kiosk-ui .landing-mode-title-pre {
    font-size: clamp(0.68rem, 2vw, 0.78rem);
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    line-height: 1.2;
}

body.kiosk-ui .landing-mode-title-word {
    font-size: clamp(1.35rem, 5vw, 1.85rem);
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1.1;
}

body.kiosk-ui .landing-mode-btn-desc {
    font-size: clamp(0.8rem, 2.4vw, 0.95rem);
    line-height: 1.4;
    margin-top: 2px;
}

/* Voice – primary blue gradient */
body.kiosk-ui #landing-voice-btn {
    background: linear-gradient(90deg, #2F4FA3 0%, #4b649f 50%, #022077 100%);
    border: none;
    color: #fff;
}

body.kiosk-ui #landing-voice-btn:hover {
    box-shadow: 0 20px 50px rgba(37, 99, 235, 0.35);
}

body.kiosk-ui #landing-voice-btn .landing-mode-title-pre {
    color: rgba(255, 255, 255, 0.88);
}

body.kiosk-ui #landing-voice-btn .landing-mode-title-word {
    color: #fff;
}

body.kiosk-ui #landing-voice-btn .landing-mode-btn-desc {
    color: rgba(191, 219, 254, 0.95);
}

body.kiosk-ui #landing-voice-btn .landing-mode-btn-icon {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

body.kiosk-ui #landing-voice-btn .landing-mode-btn-icon i {
    color: #fff;
}

/* Touch – white secondary */
body.kiosk-ui #landing-touch-btn {
    background: #fff;
    background-image: none;
    border: 1px solid var(--kiosk-line);
}

body.kiosk-ui #landing-touch-btn:hover {
    background: #fafbfc;
    border-color: rgba(15, 23, 42, 0.16);
}

body.kiosk-ui #landing-touch-btn .landing-mode-title-pre {
    color: var(--kiosk-slate);
}

body.kiosk-ui #landing-touch-btn .landing-mode-title-word {
    color: var(--kiosk-navy);
}

body.kiosk-ui #landing-touch-btn .landing-mode-btn-desc {
    color: var(--kiosk-slate);
}

body.kiosk-ui #landing-touch-btn .landing-mode-btn-icon {
    background: #f1f5f9;
    border: 1px solid var(--kiosk-line);
}

body.kiosk-ui #landing-touch-btn .landing-mode-btn-icon i {
    color: var(--kiosk-navy-soft);
}

/* Chevron */
body.kiosk-ui .landing-mode-btn-inner::after {
    content: "\f054";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: clamp(14px, 3vw, 20px);
    top: 50%;
    transform: translateY(-50%);
    width: clamp(36px, 9vw, 44px);
    height: clamp(36px, 9vw, 44px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #fff;
}

body.kiosk-ui #landing-touch-btn .landing-mode-btn-inner::after {
    background: #f1f5f9;
    border-color: var(--kiosk-line);
    color: var(--kiosk-navy);
}

/* Voice flow: locked touch looks exactly like the normal (non-hover) card — no lift, no hover tint */
body.kiosk-ui #landing-touch-btn.landing-touch-locked,
body.kiosk-ui #landing-touch-btn.landing-touch-locked:hover,
body.kiosk-ui #landing-touch-btn.landing-touch-locked:focus-visible {
    pointer-events: none;
    cursor: pointer;
    transform: none;
    box-shadow: var(--kiosk-card-shadow);
    background: #fff;
    background-image: none;
    border: 1px solid var(--kiosk-line);
    border-color: var(--kiosk-line);
    opacity: 1;
    filter: none;
}


/* Status pill */
body.kiosk-ui .landing-status {
    margin-top: clamp(0.5rem, 2vh, 1rem);
    margin-left: auto;
    margin-right: auto;
    padding: 12px 22px;
    min-height: 48px;
    background: #f1f5f9;
    border: 1px solid var(--kiosk-line);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05);
    color: var(--kiosk-navy);
    font-weight: 500;
    font-size: clamp(0.88rem, 2.5vw, 1rem);
}

body.kiosk-ui .landing-status::before {
    background: #16a34a;
    box-shadow: none;
    width: 10px;
    height: 10px;
}

html[data-theme="dark"] body.kiosk-ui .landing-status {
    background: rgba(30, 41, 59, 0.65);
    color: var(--text-strong);
    border-color: rgba(148, 163, 184, 0.25);
}

/* App / conversation */
html[data-theme="light"] body.kiosk-ui #app-view.layout {
    background: transparent;
}

body.kiosk-ui .voice-panel {
    background: transparent;
    padding: calc(var(--kiosk-top-h) + 8px) clamp(12px, 3vw, 20px) calc(var(--kiosk-footer-h) + 28px);
}

body.kiosk-ui .voice-panel-inner {
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
}

/* Voice: one full-width column (otherwise voice-panel sits in 3fr of 3fr+2.2fr grid → left-heavy) */
body.kiosk-ui #app-view.voice-mode.layout {
    grid-template-columns: 1fr;
    max-width: 100%;
    height: 100%;
    min-height: 100%;
    box-sizing: border-box;
}

body.kiosk-ui #app-view.voice-mode .chat-panel {
    display: none !important;
}

body.kiosk-ui #app-view.voice-mode .voice-panel {
    justify-content: center;
    align-items: center;
    min-height: 0;
    height: 100%;
    align-self: stretch;
}

body.kiosk-ui #app-view.voice-mode .voice-panel-inner {
    width: min(100%, 760px);
    max-width: 100%;
}

body.kiosk-ui .kiosk-barge-hint {
    width: max-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: 0;
    align-self: flex-end;
    padding: 8px 14px;
    text-align: center;
    font-size: clamp(0.78rem, 2vw, 0.88rem);
    font-weight: 500;
    color: var(--kiosk-slate);
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid var(--kiosk-line);
    border-radius: 999px;
    box-sizing: border-box;
}

body.kiosk-ui #app-view.touch-mode .kiosk-barge-hint {
    display: none;
}

html[data-theme="dark"] body.kiosk-ui .kiosk-barge-hint {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(148, 163, 184, 0.25);
}

body.kiosk-ui .state-row {
    justify-content: end;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 6px;
}

/* Status pill hidden on kiosk (JS still updates #state-badge for debugging / a11y tree). */
body.kiosk-ui .state-badge {
    display: none !important;
}

/* Remove empty row spacing when state-row only contained the badge (e.g. assembly_voice_ui header layout). */
body.kiosk-ui .state-row:has(> #state-badge:only-child) {
    display: none !important;
}

/* Clinic logo above AI Assistant card (outside white box; zooms with #orb-boxes-zoom-box) */
body.kiosk-ui .kiosk-chat-brand {
    width: 100%;
    max-width: min(721px, 100%);
    margin: 0 auto 16px;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

body.kiosk-ui .kiosk-chat-logo {
    display: block;
    height: clamp(40px, 6vw, 52px);
    width: auto;
    max-width: min(280px, 88vw);
    object-fit: contain;
    object-position: left center;
}

body.kiosk-ui .orb-box.orb-box-conversation {
    border-radius: clamp(18px, 3vw, 24px);
    border: 1px solid var(--kiosk-line);
    background: #fff;
    box-shadow: var(--kiosk-card-shadow);
    overflow: hidden;
}

html[data-theme="dark"] body.kiosk-ui .orb-box.orb-box-conversation {
    background: rgba(15, 23, 42, 0.94);
    border-color: rgba(148, 163, 184, 0.22);
}

body.kiosk-ui .orb-box-conversation .orb-box-title.kiosk-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 18px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--kiosk-navy);
    border-bottom: 1px solid var(--kiosk-line);
    background: #fafbfc;
}

html[data-theme="dark"] body.kiosk-ui .orb-box-conversation .orb-box-title.kiosk-chat-head {
    background: rgba(15, 23, 42, 0.98);
    color: #e2e8f0;
    border-bottom-color: rgba(148, 163, 184, 0.2);
}

body.kiosk-ui .kiosk-chat-head-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: none;
    font-size: clamp(0.75rem, 2vw, 0.82rem);
    color: var(--kiosk-slate);
}

body.kiosk-ui .kiosk-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #16a34a;
    flex-shrink: 0;
}

body.kiosk-ui .orb-box-conversation .orb-box-conversation-content {
    background: #f8fafc;
    scrollbar-color: rgba(37, 99, 235, 0.35) #f1f5f9;
}

html[data-theme="dark"] body.kiosk-ui .orb-box-conversation .orb-box-conversation-content {
    background: rgba(15, 23, 42, 0.45);
}

body.kiosk-ui .orb-box-conversation .orb-box-conversation-content::-webkit-scrollbar-track {
    background: #f1f5f9;
}

body.kiosk-ui .orb-box-conversation .orb-box-conversation-content::-webkit-scrollbar-thumb {
    background: rgba(37, 99, 235, 0.35);
}

/* Messages: .conv-bubble wraps label+body (JS); avatars stay outside */
body.kiosk-ui .conv-entry {
    border-radius: 0;
    padding: 0;
    font-size: clamp(0.95rem, 2.8vw, 1.08rem);
    line-height: 1.45;
}

body.kiosk-ui .conv-entry .conv-bubble {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
}

/* Light theme: don’t paint old green/purple strip on kiosk rows */
html[data-theme="light"] body.kiosk-ui .conv-entry.conv-assistant,
html[data-theme="light"] body.kiosk-ui .conv-entry.conv-user {
    background: transparent !important;
    border-left: none !important;
    border-right: none !important;
    box-shadow: none !important;
    color: inherit;
}

/* Assistant: avatar | .conv-bubble (navy, label + body inside) */
body.kiosk-ui .conv-entry.conv-assistant {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    column-gap: 12px;
    align-items: start;
    background: transparent;
    border: none;
    box-shadow: none;
}

body.kiosk-ui .conv-entry.conv-assistant::before {
    content: "";
    grid-column: 1;
    grid-row: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    align-self: start;
    justify-self: start;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.12);
    background-image:
        radial-gradient(circle at 35% 38%, rgba(255, 255, 255, 0.95) 2px, transparent 2px),
        radial-gradient(circle at 65% 38%, rgba(255, 255, 255, 0.95) 2px, transparent 2px),
        linear-gradient(145deg, #0d9488, #115e59);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    z-index: 1;
}

body.kiosk-ui .conv-entry.conv-assistant:not(.conv-typing)::after {
    content: none;
}

body.kiosk-ui .conv-entry.conv-assistant .conv-bubble {
    grid-column: 2;
    grid-row: 1;
    background: var(--kiosk-assistant-bubble);
    border-radius: 10px 20px 20px 20px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

body.kiosk-ui .conv-entry.conv-assistant .conv-bubble .conv-label {
    color: #2dd4bf;
    font-size: 0.95rem;
    margin: 0;
    padding: 10px 16px 2px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

body.kiosk-ui .conv-entry.conv-assistant .conv-bubble > div:not(.conv-label) {
    color: #f8fafc;
    padding: 0 16px 12px;
    margin: 0;
    font-weight: 400;
    word-break: break-word;
}

/* User: .conv-bubble | avatar */
body.kiosk-ui .conv-entry.conv-user {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px;
    column-gap: 10px;
    align-items: start;
    background: transparent;
    border: none;
    box-shadow: none;
    color: var(--kiosk-navy);
    align-self: flex-end;
    max-width: 94%;
}

body.kiosk-ui .conv-entry.conv-user::before {
    display: none;
}

body.kiosk-ui .conv-entry.conv-user .conv-bubble {
    grid-column: 1;
    grid-row: 1;
    background: var(--kiosk-user-bubble);
    border: 1px solid var(--kiosk-user-bubble-border, rgba(15, 23, 42, 0.09));
    border-radius: 20px 20px 8px 20px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.07);
    position: relative;
}

/* Tail → avatar */
body.kiosk-ui .conv-entry.conv-user .conv-bubble .conv-label::before {
    content: "";
    position: absolute;
    right: -9px;
    top: 14px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 0 8px 11px;
    border-color: transparent transparent transparent var(--kiosk-user-bubble);
    z-index: 2;
    pointer-events: none;
}

body.kiosk-ui .conv-entry.conv-user::after {
    content: "";
    grid-column: 2;
    grid-row: 1;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    align-self: start;
    justify-self: end;
    z-index: 1;
    background-color: #1e3a8a;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath fill='%23ffffff' d='M224 256A128 128 0 1 0 224 0a128 128 0 1 0 0 256zm-45.7 48C79.8 304 0 383.8 0 482.3C0 498.7 13.3 512 29.7 512H418.3c16.4 0 29.7-13.3 29.7-29.7C448 383.8 368.2 304 269.7 304H178.3z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 52% 52%;
    box-shadow: 0 3px 10px rgba(30, 58, 138, 0.35);
}

body.kiosk-ui .conv-entry.conv-user .conv-bubble .conv-label {
    position: relative;
    font-size: 0;
    margin: 0;
    padding: 12px 16px 0;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
    text-align: right;
}

body.kiosk-ui .conv-entry.conv-user .conv-bubble .conv-label::after {
    content: "YOU";
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    display: block;
    color: var(--kiosk-navy);
    text-align: right;
    line-height: 1.15;
    text-transform: uppercase;
}

body.kiosk-ui .conv-entry.conv-user .conv-bubble > div:not(.conv-label) {
    text-align: right;
    padding: 2px 16px 12px;
    margin: 0;
    color: var(--kiosk-navy);
    font-weight: 400;
    word-break: break-word;
}

/* Typing row (no .conv-bubble): navy plate + dots */
body.kiosk-ui .conv-entry.conv-assistant.conv-typing {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    column-gap: 12px;
    align-items: stretch;
}

body.kiosk-ui .conv-entry.conv-assistant.conv-typing::before {
    grid-column: 1;
    grid-row: 1;
    background-image: linear-gradient(145deg, #0d9488, #115e59);
}

body.kiosk-ui .conv-entry.conv-assistant.conv-typing::after {
    content: "";
    grid-column: 2;
    grid-row: 1;
    background: var(--kiosk-assistant-bubble);
    border-radius: 10px 20px 20px 20px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
    z-index: 0;
    min-height: 44px;
}

body.kiosk-ui .conv-entry.conv-assistant.conv-typing .typing {
    grid-column: 2;
    grid-row: 1;
    position: relative;
    z-index: 1;
    align-self: center;
    padding: 14px 16px;
    margin: 0;
}

body.kiosk-ui .mic-circle {
    border: 2px solid rgba(148, 163, 184, 0.45);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.07);
}

body.kiosk-ui .mic-circle.listening,
body.kiosk-ui .mic-circle.speaking,
body.kiosk-ui .mic-circle.barge-in {
    animation: none;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.18);
}

body.kiosk-ui .mic-circle .inner-glow {
    opacity: 0.3;
}

body.kiosk-ui .touch-mode-input-inline {
    border-radius: 999px;
    border: 1px solid var(--kiosk-line);
    background: #fff;
    min-height: 52px;
    padding: 8px 8px 8px 16px;
}

body.kiosk-ui .touch-mode-input-inline textarea {
    font-size: clamp(0.95rem, 2.5vw, 1.05rem);
}

/* Kiosk touch field stays white in both themes; dark theme tokens use light --text, so force readable ink on the pill. */
html[data-theme="dark"] body.kiosk-ui .touch-mode-input-inline textarea {
    color: #0f172a;
}

html[data-theme="dark"] body.kiosk-ui .touch-mode-input-inline textarea::placeholder {
    color: #64748b;
}

html[data-theme="light"] body.kiosk-ui .touch-mode-input-inline textarea {
    color: var(--text-strong);
}

html[data-theme="light"] body.kiosk-ui .touch-mode-input-inline textarea::placeholder {
    color: var(--muted);
}

body.kiosk-ui .touch-mode-send-btn {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(145deg, #2563eb, #1d4ed8);
    color: #fff;
    border: none;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.32);
}

html[data-theme="light"] body.kiosk-ui .touch-mode-form:focus-within .touch-mode-input-inline {
    border-color: rgba(37, 99, 235, 0.4);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

body.kiosk-ui .primary-actions {
    position: fixed;
    left: 50%;
    right: auto;
    bottom: max(18px, calc(var(--kiosk-footer-h) / 2 - 26px));
    transform: translateX(-50%);
    z-index: 600;
}

body.kiosk-ui .primary-actions .btn-end {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    background: rgba(15, 23, 42, 0.55);
    color: #f8fafc;
    border: 1px solid rgba(96, 165, 250, 0.55);
    padding: 14px 26px;
    font-size: clamp(0.8rem, 2.2vw, 0.92rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    backdrop-filter: none;
}

body.kiosk-ui .primary-actions .btn-end:hover {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgba(147, 197, 253, 0.85);
}

body.kiosk-ui .touch-mode-end-btn {
    background: rgba(15, 23, 42, 0.55);
    color: #f8fafc;
    border: 1px solid rgba(96, 165, 250, 0.55);
    padding: 14px 26px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    backdrop-filter: none;
    font-size: clamp(0.8rem, 2.2vw, 0.92rem);
}

body.kiosk-ui .touch-mode-end-btn:hover {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgba(147, 197, 253, 0.85);
}

html[data-theme="light"] body.kiosk-ui .touch-mode-end-btn {
    background: rgba(15, 23, 42, 0.55);
    color: #f8fafc;
    border-color: rgba(96, 165, 250, 0.55);
}

body.kiosk-ui #app-view.touch-mode .touch-mode-end-row {
    position: fixed;
    left: 50%;
    bottom: max(18px, calc(var(--kiosk-footer-h) / 2 - 26px));
    transform: translateX(-50%);
    z-index: 600;
    margin: 0;
    width: auto;
    max-width: none;
}

body.kiosk-ui #app-view.touch-mode .touch-mode-only {
    padding-bottom: calc(var(--kiosk-footer-h) + 12px);
}

body.kiosk-ui .btn-help {
    border-radius: 999px;
    border: 1px solid var(--kiosk-line);
    font-weight: 600;
}

body.kiosk-ui .sign-form-container {
    border-radius: 22px;
    border: 1px solid var(--kiosk-line);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.14);
}

html[data-theme="light"] body.kiosk-ui .sign-form-field input:not([type="checkbox"]),
html[data-theme="light"] body.kiosk-ui .sign-form-field textarea {
    border-radius: 14px;
    border: 1px solid var(--kiosk-line);
    padding: 14px 16px;
    font-size: clamp(0.95rem, 2.5vw, 1.05rem);
}

html[data-theme="light"] body.kiosk-ui .sign-form-modal .btn-submit {
    border-radius: 999px;
    background: linear-gradient(145deg, #2563eb, #1d4ed8);
    font-weight: 600;
    padding: 14px 26px;
}

html[data-theme="light"] body.kiosk-ui .sign-form-modal .btn-close {
    border-radius: 999px;
    border: 1px solid var(--kiosk-line);
}

body.kiosk-ui .end-session-popup,
body.kiosk-ui .inactivity-popup,
body.kiosk-ui .payment-complete-popup {
    border-radius: 18px;
}

/* Portrait Screen */
@media (orientation: portrait) {
    .orb-box-conversation .orb-box-conversation-content {
        height: 900px;
        min-height: 880px;
        max-height: 880px;
    }
}
/* Narrow portrait (phones): reserve less vertical chrome so pane stays usable */
@media (orientation: portrait) and (max-width: 540px) {
    .orb-box-conversation .orb-box-conversation-content {
        height: unset;
        max-height: 400px;
        min-height: 400px;
    }
}

@media (max-width: 480px) {
    body.kiosk-ui .kiosk-top-bar {
        flex-wrap: wrap;
        min-height: auto;
        padding-bottom: 8px;
    }

    body.kiosk-ui .landing {
        padding-top: calc(var(--kiosk-top-h) + 12px);
    }

    body.kiosk-ui .zoom-controls {
        left: max(12px, env(safe-area-inset-left, 0px));
        bottom: max(16px, env(safe-area-inset-bottom, 0px));
    }

    body.kiosk-ui .landing-mode-btn-inner::after {
        right: 10px;
        width: 34px;
        height: 34px;
        font-size: 0.72rem;
    }
}