:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --ink: #14212b;
    --muted: #5f6f7a;
    --surface: #ffffff;
    --surface-alt: #eef6f4;
    --line: #d8e1e5;
    --teal: #0f766e;
    --teal-dark: #0b5f59;
    --blue: #2357c6;
    --navy: #172554;
    --green: #2f855a;
    --amber: #b7791f;
    --red: #cf3f3b;
    --shadow: 0 18px 42px rgba(23, 37, 84, 0.10);
    --radius: 8px;
    --mobile-nav-height: 74px;
    --mobile-nav-visual-offset: 0px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    letter-spacing: 0;
    overflow-x: hidden;
}

body[dir="rtl"] {
    font-family: Tahoma, Arial, sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.7;
    cursor: wait;
}

.site-shell {
    width: min(1240px, 100%);
    margin: 0 auto;
    padding: 18px 18px 28px;
    min-width: 0;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 14px;
    align-items: center;
    min-height: 70px;
    padding: 10px 0 14px;
    background: rgba(245, 247, 248, 0.86);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    background:
        linear-gradient(#fff, #fff) center / 6px 21px no-repeat,
        linear-gradient(#fff, #fff) center / 21px 6px no-repeat,
        linear-gradient(135deg, var(--teal), var(--blue));
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.22);
    flex: 0 0 auto;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 1.08rem;
    line-height: 1.1;
}

.brand small {
    max-width: 240px;
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.desktop-nav,
.header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.desktop-nav {
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
}

.nav-link,
.mobile-link,
.segment,
.lang-button,
.primary-button,
.secondary-button,
.icon-button {
    border: 0;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 850;
    border-radius: var(--radius);
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.nav-link {
    min-width: 94px;
    padding: 8px 13px;
    border-radius: 999px;
    color: #415463;
    background: transparent;
}

.nav-link.active {
    color: #fff;
    background: var(--teal);
}

.lang-button {
    min-width: 84px;
    padding: 8px 12px;
    color: var(--teal-dark);
    border: 1px solid rgba(15, 118, 110, 0.22);
    background: #e7f5f1;
}

.primary-button,
.secondary-button {
    padding: 11px 15px;
    white-space: nowrap;
}

.primary-button {
    color: #fff;
    background: var(--teal);
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.20);
}

.secondary-button {
    color: var(--navy);
    border: 1px solid rgba(35, 87, 198, 0.20);
    background: #edf4ff;
}

.compact {
    min-height: 40px;
    padding: 9px 12px;
}

.wide {
    width: 100%;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.hero {
    position: relative;
    min-height: min(620px, calc(100vh - 112px));
    display: grid;
    align-items: end;
    overflow: hidden;
    border-radius: var(--radius);
    background:
        linear-gradient(90deg, rgba(9, 31, 42, 0.86), rgba(9, 31, 42, 0.55) 42%, rgba(9, 31, 42, 0.12)),
        url("/assets/clinic-hero.png") center / cover no-repeat;
    box-shadow: var(--shadow);
}

.hero-content {
    width: min(690px, 100%);
    display: grid;
    gap: 16px;
    padding: clamp(26px, 6vw, 64px);
    color: #fff;
}

.eyebrow {
    color: var(--teal-dark);
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
}

.hero .eyebrow {
    color: #a7f3d0;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    max-width: 760px;
    font-size: clamp(2.3rem, 6.5vw, 5.25rem);
    line-height: 0.96;
}

h2 {
    font-size: clamp(1.45rem, 3.4vw, 2.45rem);
    line-height: 1.05;
}

h3 {
    font-size: 1rem;
}

.hero p,
.page-title p,
.chat-intro p {
    color: rgba(255, 255, 255, 0.88);
    font-size: 1.04rem;
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}

.service-status {
    position: absolute;
    inset-inline-end: 18px;
    bottom: 18px;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink);
    font-size: 0.83rem;
    font-weight: 850;
}

.status-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #38a169;
    box-shadow: 0 0 0 0 rgba(56, 161, 105, 0.7);
    animation: pulse 1.9s infinite;
}

@keyframes pulse {
    70% {
        box-shadow: 0 0 0 11px rgba(56, 161, 105, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(56, 161, 105, 0);
    }
}

.quick-band {
    display: grid;
    grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1fr);
    gap: 18px;
    align-items: end;
    padding: 28px 0;
}

.section-heading {
    display: grid;
    gap: 8px;
}

.section-heading h2 {
    color: var(--ink);
}

.quick-search {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
}

input,
select,
textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 13px;
    border-radius: var(--radius);
    border: 1px solid #cfd9df;
    background: #fbfdfe;
    color: var(--ink);
    outline: none;
}

textarea {
    min-height: 104px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
    background: #fff;
}

.home-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.42fr);
    gap: 18px;
    align-items: stretch;
    padding: 8px 0 32px;
}

.trust-panel,
.source-panel,
.tool-panel,
.answer-panel,
.chat-shell {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.trust-panel,
.source-panel {
    padding: 22px;
}

.trust-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.trust-list article {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfdfe;
}

.trust-list svg,
.feature-icon {
    color: var(--teal);
}

.trust-list p,
.source-panel p,
.source-item p,
.answer-section p,
.answer-section li,
.site-footer {
    color: var(--muted);
    line-height: 1.55;
}

.source-panel {
    display: grid;
    align-content: start;
    gap: 12px;
}

.compact-sources {
    display: grid;
    gap: 8px;
}

.compact-sources span {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: var(--surface-alt);
    color: var(--teal-dark);
    font-weight: 850;
}

.page-title {
    min-height: 260px;
    display: grid;
    align-content: end;
    gap: 12px;
    padding: 38px 0 28px;
}

.page-title .eyebrow,
.chat-intro .eyebrow {
    color: var(--teal-dark);
}

.page-title p,
.chat-intro p {
    max-width: 760px;
    color: var(--muted);
}

.tool-layout {
    display: grid;
    grid-template-columns: minmax(350px, 0.88fr) minmax(0, 1.12fr);
    gap: 16px;
    align-items: start;
}

.tool-panel,
.answer-panel,
.chat-shell {
    padding: 18px;
}

.simple-form {
    display: grid;
    gap: 13px;
}

.simple-form label {
    display: grid;
    gap: 7px;
}

.simple-form label span,
.chip-field legend {
    color: #314253;
    font-size: 0.86rem;
    font-weight: 850;
}

.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.severity-line {
    display: grid;
    grid-template-columns: auto 1fr 44px;
    gap: 10px;
    align-items: center;
    min-height: 48px;
}

.severity-line label {
    color: #314253;
    font-weight: 850;
}

input[type="range"] {
    min-height: 30px;
    padding: 0;
    accent-color: var(--teal);
    background: transparent;
    box-shadow: none;
}

output {
    display: grid;
    place-items: center;
    min-height: 34px;
    border-radius: var(--radius);
    background: var(--surface-alt);
    color: var(--teal-dark);
    font-weight: 900;
}

.chip-field {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
}

.chip-field legend {
    grid-column: 1 / -1;
}

.chip-field label {
    display: block;
}

.chip-field input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.chip-field span {
    display: grid;
    place-items: center;
    min-height: 38px;
    padding: 7px 9px;
    border: 1px solid #cfd9df;
    border-radius: 999px;
    color: #425466;
    background: #fff;
    font-size: 0.82rem;
    font-weight: 800;
    text-align: center;
}

.chip-field input:checked + span {
    color: #9b2c2c;
    border-color: rgba(207, 63, 59, 0.30);
    background: #fff1f1;
}

.photo-card {
    display: grid;
    gap: 10px;
}

.upload-tile {
    min-height: 84px;
    display: grid;
    place-items: center;
    gap: 6px;
    border-radius: var(--radius);
    border: 1px dashed #aebec7;
    background: #f9fbfd;
    color: var(--teal-dark);
    font-weight: 850;
}

.upload-tile input {
    display: none;
}

.photo-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-radius: var(--radius);
    background: #e5edf1;
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.icon-button {
    width: 42px;
    height: 42px;
    color: var(--teal-dark);
    background: #fff;
    border: 1px solid var(--line);
}

.photo-preview .icon-button {
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
}

.panel-head {
    display: grid;
    gap: 5px;
    margin-bottom: 14px;
}

.panel-head.row {
    grid-template-columns: 1fr auto;
    align-items: start;
}

.mini-chip,
.triage-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 900;
    white-space: nowrap;
}

.result-box {
    display: grid;
    gap: 13px;
}

.result-box.empty {
    min-height: 310px;
    place-items: center;
    align-content: center;
    text-align: center;
    color: var(--muted);
    border: 1px dashed #c8d5dc;
    border-radius: var(--radius);
    background: #f9fbfd;
    padding: 18px;
}

.result-box.empty svg {
    width: 44px;
    height: 44px;
    color: var(--teal);
}

.triage-pill.emergency,
.triage-pill.urgent {
    color: #9b2c2c;
    background: #fff1f1;
    border-color: rgba(207, 63, 59, 0.28);
}

.triage-pill.self_care {
    color: var(--green);
    background: #edf8f0;
    border-color: rgba(47, 133, 90, 0.24);
}

.triage-pill.information,
.triage-pill.soon {
    color: var(--blue);
    background: #eff6ff;
    border-color: rgba(35, 87, 198, 0.22);
}

.answer-section {
    display: grid;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.answer-section:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.answer-section h3 {
    color: #273746;
}

.answer-section ul {
    margin: 0;
    padding-inline-start: 20px;
}

.alert {
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid rgba(207, 63, 59, 0.24);
    background: #fff1f1;
    color: #8f2d2d;
    font-weight: 850;
}

.source-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.source-item {
    padding: 10px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fbfdfe;
}

.source-item a {
    color: var(--teal-dark);
    font-weight: 850;
    text-decoration: none;
}

.source-service {
    display: inline-block;
    margin-bottom: 6px;
    padding: 4px 7px;
    border-radius: 999px;
    background: var(--surface-alt);
    color: var(--teal-dark);
    font-size: 0.68rem;
    font-weight: 900;
}

.chat-page {
    display: grid;
    grid-template-columns: minmax(280px, 0.42fr) minmax(0, 0.58fr);
    gap: 18px;
    align-items: start;
    padding-top: 48px;
}

.chat-intro {
    position: sticky;
    top: 92px;
    display: grid;
    gap: 12px;
}

.chat-shell {
    min-height: min(720px, calc(100vh - 150px));
    display: grid;
    grid-template-rows: auto minmax(360px, 1fr) auto;
    gap: 12px;
}

.chat-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.segmented {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(118px, 1fr));
    gap: 5px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f7fafb;
}

.segment {
    min-height: 38px;
    padding: 7px 10px;
    border-radius: 999px;
    color: #415463;
    background: transparent;
}

.segment.active {
    background: var(--navy);
    color: #fff;
}

.chat-log {
    display: grid;
    align-content: start;
    gap: 10px;
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #f8fbfd;
}

.chat-message {
    max-width: min(86%, 680px);
    display: grid;
    gap: 6px;
    padding: 11px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
    color: #263746;
    line-height: 1.55;
}

.chat-message.user {
    justify-self: end;
    color: #fff;
    background: var(--teal);
    border-color: var(--teal);
}

.chat-message.assistant {
    justify-self: start;
}

.chat-message small {
    color: var(--muted);
    font-weight: 800;
}

.chat-message.user small {
    color: rgba(255, 255, 255, 0.78);
}

.chat-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: end;
}

.chat-form textarea {
    min-height: 62px;
    max-height: 180px;
}

.send-button {
    min-height: 62px;
}

.loader {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--teal-dark);
    font-weight: 900;
}

.loader::before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid rgba(15, 118, 110, 0.2);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

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

.site-footer {
    margin-top: 32px;
    padding: 18px 0 0;
    border-top: 1px solid var(--line);
    font-size: 0.88rem;
}

.mobile-nav {
    display: none;
}

.primary-button:hover,
.secondary-button:hover,
.nav-link:hover,
.lang-button:hover,
.segment:hover,
.icon-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(36, 48, 63, 0.12);
}

svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

@media (max-width: 980px) {
    .site-shell {
        padding: 12px 12px calc(var(--mobile-nav-height) + 34px + env(safe-area-inset-bottom) + var(--mobile-nav-visual-offset));
    }

    .site-header {
        grid-template-columns: 1fr auto;
    }

    .desktop-nav {
        display: none;
    }

    .header-actions .primary-button {
        display: none;
    }

    .hero {
        min-height: 560px;
        background:
            linear-gradient(180deg, rgba(9, 31, 42, 0.70), rgba(9, 31, 42, 0.70)),
            url("/assets/clinic-hero.png") 58% center / cover no-repeat;
    }

    .service-status {
        position: static;
        margin: 0 clamp(20px, 6vw, 36px) 20px;
        justify-self: start;
        align-self: end;
    }

    .quick-band,
    .home-layout,
    .tool-layout,
    .chat-page {
        grid-template-columns: 1fr;
    }

    .quick-search {
        grid-template-columns: 1fr;
    }

    .trust-list {
        grid-template-columns: 1fr;
    }

    .chat-intro {
        position: static;
    }

    .mobile-nav {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 10px;
        inset-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right));
        bottom: calc(10px + env(safe-area-inset-bottom) + var(--mobile-nav-visual-offset));
        z-index: 999;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 5px;
        padding: 5px;
        min-height: var(--mobile-nav-height);
        border: 1px solid var(--line);
        border-radius: 18px;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(18px);
        box-shadow: 0 16px 42px rgba(23, 37, 84, 0.22);
        transform: translateZ(0);
        will-change: transform;
        contain: layout paint;
    }

    .mobile-link {
        min-width: 0;
        min-height: 58px;
        display: grid;
        gap: 2px;
        padding: 6px 4px;
        color: #52606d;
        background: transparent;
        font-size: 0.72rem;
        line-height: 1.1;
        touch-action: manipulation;
        transform: none;
        box-shadow: none;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-link:hover,
    .mobile-link:focus,
    .mobile-link:active {
        transform: none;
        box-shadow: none;
    }

    .mobile-link span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-link.active {
        color: #fff;
        background: var(--teal);
        box-shadow: none;
    }
}

@media (max-width: 560px) {
    .brand small {
        display: none;
    }

    .brand-mark {
        width: 38px;
        height: 38px;
    }

    .lang-button {
        min-width: 74px;
        padding-inline: 9px;
    }

    .hero {
        min-height: min(520px, calc(100dvh - 104px));
    }

    .hero-content {
        padding: 24px;
    }

    h1 {
        font-size: clamp(2.05rem, 12vw, 2.55rem);
    }

    .hero-actions,
    .two-col,
    .chat-form {
        grid-template-columns: 1fr;
        display: grid;
    }

    .hero-actions .primary-button,
    .hero-actions .secondary-button,
    .chat-form .send-button {
        width: 100%;
    }

    .page-title {
        min-height: 210px;
        padding-top: 26px;
    }

    .tool-panel,
    .answer-panel,
    .chat-shell,
    .trust-panel,
    .source-panel {
        padding: 14px;
    }

    .chip-field {
        grid-template-columns: 1fr;
    }

    .severity-line {
        grid-template-columns: 1fr 1fr 44px;
    }

    .chat-shell {
        min-height: calc(100dvh - var(--mobile-nav-height) - 132px);
    }

    .chat-message {
        max-width: 94%;
    }
}
