:root {
    color-scheme: light;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI",
        sans-serif;
    color: #182632;
    background: #f3f6f8;
    font-synthesis: none;
    text-rendering: optimizeLegibility;

    --color-text: #182632;
    --color-muted: #687986;
    --color-border: #dce4e9;
    --color-surface: #ffffff;
    --color-surface-subtle: #f7f9fa;
    --color-primary: #176b70;
    --color-primary-hover: #12575b;
    --color-primary-soft: #e9f4f3;
    --color-danger: #8b3030;
    --radius-card: 12px;
    --radius-control: 8px;
    --shadow-card: 0 2px 8px rgb(24 38 50 / 4%);
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    line-height: 1.5;
    -webkit-overflow-scrolling: touch;
}

button,
input,
textarea {
    font: inherit;
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-control);
    background: var(--color-primary);
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 650;
    cursor: pointer;
    transition:
        background-color 150ms ease,
        border-color 150ms ease,
        box-shadow 150ms ease;
}

button:hover:not(:disabled) {
    border-color: var(--color-primary-hover);
    background: var(--color-primary-hover);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
a:focus-visible {
    outline: 3px solid #7bbbc0;
    outline-offset: 3px;
}

button:disabled {
    cursor: wait;
    opacity: 0.6;
}

button.secondary {
    border-color: var(--color-border);
    background: #ffffff;
    color: var(--color-text);
}

button.secondary:hover:not(:disabled) {
    border-color: #aab9c2;
    background: var(--color-surface-subtle);
}

input,
textarea {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 11px 12px;
    border: 1px solid #cbd6dd;
    border-radius: var(--radius-control);
    background: #ffffff;
    color: var(--color-text);
    font-size: 0.92rem;
    line-height: 1.5;
    transition:
        border-color 150ms ease,
        box-shadow 150ms ease;
}

input:hover,
textarea:hover {
    border-color: #aabac4;
}

input:focus,
textarea:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgb(23 107 112 / 12%);
}

textarea {
    resize: vertical;
}

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

.masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--color-primary);
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.13em;
    line-height: 1.4;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 7px;
    font-size: clamp(1.9rem, 4vw, 2.65rem);
    font-weight: 720;
    letter-spacing: -0.045em;
    line-height: 1.12;
}

h2 {
    margin-bottom: 0;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

h3 {
    margin-bottom: 8px;
    font-size: 1.05rem;
}

.subtitle {
    margin-bottom: 0;
    color: var(--color-muted);
    font-size: 1rem;
}

.status {
    flex-shrink: 0;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: #ffffff;
    color: var(--color-muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.status.online {
    border-color: #b7d9cc;
    background: #edf8f2;
    color: #246647;
}

.status.offline {
    border-color: #e5c2c2;
    background: #fff2f1;
    color: var(--color-danger);
}

.state-panel {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    padding: 22px 24px;
    margin-bottom: 22px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
}

.state-panel > div {
    min-width: 0;
}

.field-label {
    display: block;
    margin-bottom: 6px;
    color: var(--color-muted);
    font-size: 0.78rem;
    font-weight: 550;
}

.state-panel strong {
    display: block;
    overflow-wrap: anywhere;
    color: var(--color-text);
    font-size: 0.94rem;
    font-weight: 650;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.85fr);
    gap: 22px;
    align-items: start;
}

.intelligence-panel,
.context-panel > details,
.notice-panel {
    min-width: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
}

.intelligence-panel {
    overflow: hidden;
}

.section-heading {
    padding: 22px 24px;
    border-bottom: 1px solid var(--color-border);
}

#messages {
    display: flex;
    min-height: 340px;
    max-height: 58vh;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: auto;
}

.empty-state {
    width: min(100%, 390px);
    margin: auto;
    padding: 36px 12px;
    color: var(--color-muted);
    text-align: center;
}

.empty-state h3 {
    color: var(--color-text);
}

.empty-state p {
    margin-bottom: 0;
    font-size: 0.92rem;
    line-height: 1.65;
}

.message {
    max-width: 92%;
    margin-bottom: 4px;
    padding: 14px 16px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-surface-subtle);
    color: var(--color-text);
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message.traveler {
    align-self: flex-end;
    border-color: #c4dddf;
    background: var(--color-primary-soft);
}

.message.cyaneception {
    align-self: flex-start;
    background: #ffffff;
}

.message.system {
    max-width: 100%;
    border-style: dashed;
    background: #f7f9fa;
    color: var(--color-muted);
    font-size: 0.86rem;
}

.message.error {
    border-color: #e5c2c2;
    background: #fff2f1;
    color: var(--color-danger);
}

.message-label {
    display: block;
    margin-bottom: 7px;
    color: var(--color-muted);
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

#conversation-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 18px;
    border-top: 1px solid var(--color-border);
    background: #ffffff;
}

#message {
    min-height: 48px;
    max-height: 220px;
}

#conversation-form button {
    flex-shrink: 0;
    min-width: 104px;
}

.helper {
    margin: 0;
    padding: 0 20px 18px;
    color: var(--color-muted);
    font-size: 0.78rem;
}

.context-panel {
    display: grid;
    gap: 16px;
}

.context-panel > details {
    padding: 20px;
}

summary {
    color: var(--color-text);
    font-size: 0.96rem;
    font-weight: 700;
    cursor: pointer;
}

details[open] > summary {
    margin-bottom: 18px;
}

#itinerary-settings label,
#import-panel label {
    display: block;
    margin: 15px 0 7px;
    color: #40525f;
    font-size: 0.82rem;
    font-weight: 650;
}

.button-stack {
    display: grid;
    gap: 10px;
    margin-top: 20px;
}

#import-panel textarea {
    min-height: 150px;
    margin-bottom: 12px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.82rem;
}

#import-panel button {
    width: 100%;
}

.notice-panel {
    padding: 20px;
    background: #f9fbfc;
    box-shadow: none;
}

.notice-panel .eyebrow {
    margin-bottom: 10px;
}

.notice-panel p:last-child {
    margin-bottom: 0;
    color: var(--color-muted);
    font-size: 0.86rem;
    line-height: 1.65;
}

footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 24px;
    padding: 0 2px;
    color: var(--color-muted);
    font-size: 0.78rem;
}

#activity-status {
    overflow-wrap: anywhere;
    text-align: right;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 900px) {
    .shell {
        width: min(100% - 36px, 760px);
        padding-top: 28px;
    }

    .workspace {
        grid-template-columns: minmax(0, 1fr);
    }

    .context-panel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }

    .notice-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 600px) {
    .shell {
        width: calc(100% - 28px);
        padding-top: 22px;
    }

    .masthead {
        align-items: flex-start;
        flex-direction: column;
        gap: 16px;
        margin-bottom: 22px;
    }

    .status {
        align-self: flex-start;
    }

    .state-panel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px 14px;
        padding: 18px;
    }

    .workspace {
        gap: 16px;
    }

    .section-heading {
        padding: 19px;
    }

    #messages {
        min-height: 220px;
        max-height: none;
        overflow-y: visible;
        padding: 18px;
    }

    .message {
        max-width: 100%;
    }

    #conversation-form {
        align-items: stretch;
        flex-direction: column;
        padding: 14px;
    }

    #conversation-form button {
        width: 100%;
    }

    .helper {
        padding: 0 14px 15px;
    }

    .context-panel {
        grid-template-columns: minmax(0, 1fr);
    }

    .notice-panel {
        grid-column: auto;
    }

    footer {
        flex-direction: column;
        gap: 6px;
    }

    #activity-status {
        text-align: left;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
