:root {
    --bg: #edf5ff;
    --bg-strong: #ffffff;
    --bg-soft: #eaf3ff;
    --line: rgba(59, 130, 246, 0.14);
    --line-strong: rgba(59, 130, 246, 0.24);
    --text: #202123;
    --muted: rgba(32, 33, 35, 0.56);
    --muted-strong: rgba(32, 33, 35, 0.72);
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.1);
    --shadow: 0 18px 42px rgba(37, 99, 235, 0.12);
    --composer-shadow: 0 -24px 48px rgba(37, 99, 235, 0.12);
    --font-display: 'Fraunces', 'Noto Sans JP', serif;
    --font-ui: 'Inter', 'Noto Sans JP', sans-serif;
    --font-body: 'Inter', 'Noto Sans JP', sans-serif;
}

html[data-agent-theme='warm-brown'] {
    --bg: #f4efe7;
    --bg-strong: #fffdfa;
    --bg-soft: #f4ece3;
    --line: rgba(128, 98, 71, 0.18);
    --line-strong: rgba(128, 98, 71, 0.32);
    --text: #2f2a23;
    --muted: rgba(47, 42, 35, 0.58);
    --muted-strong: rgba(47, 42, 35, 0.76);
    --accent: #8f6b46;
    --accent-soft: rgba(143, 107, 70, 0.13);
    --shadow: 0 18px 42px rgba(48, 35, 22, 0.1);
    --composer-shadow: 0 -24px 48px rgba(48, 35, 22, 0.1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    background:
        radial-gradient(circle at top center, rgba(147, 197, 253, 0.45), transparent 34%),
        linear-gradient(180deg, #f7fbff 0%, var(--bg) 100%);
    color: var(--text);
    font-family: var(--font-body);
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-y: hidden;
}

html[data-agent-theme='warm-brown'],
html[data-agent-theme='warm-brown'] body {
    background:
        radial-gradient(circle at top center, rgba(240, 230, 216, 0.7), transparent 35%),
        linear-gradient(180deg, #fffdfa 0%, var(--bg) 100%);
}

html[data-agent-theme='warm-brown'] .topbar {
    background: rgba(255, 253, 250, 0.78);
}

html[data-agent-theme='warm-brown'] .topbar-status {
    color: #4cd137;
}

html[data-agent-theme='warm-brown'] .topbar-status-dot {
    background: #4cd137;
    box-shadow: 0 0 8px rgba(76, 209, 55, 0.5);
}

html[data-agent-theme='warm-brown'] .topbar-meta-separator {
    background: rgba(128, 98, 71, 0.28);
}

html[data-agent-theme='warm-brown'] .topbar-multilingual {
    color: rgba(47, 42, 35, 0.84);
}

html[data-agent-theme='warm-brown'] .topbar-brand {
    color: rgba(107, 99, 91, 0.86);
}

button,
textarea {
    font: inherit;
}

button {
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.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;
}

.agent-app {
    width: 100%;
    max-width: min(920px, 100vw);
    margin: 0 auto;
    height: 100vh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

@supports (height: 100dvh) {
    .agent-app {
        height: 100dvh;
        min-height: 100dvh;
    }
}

.topbar {
    position: relative;
    display: block;
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(18px);
}

.brand-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
}

.brand-lockup {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    min-width: 0;
    flex-wrap: wrap;
    padding-right: 126px;
}

.brand-mark {
    display: none;
}

.brand-name {
    font-family: var(--font-ui);
    font-size: 1.9rem;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.topbar-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-wrap: nowrap;
}

.topbar-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #4cd137;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.topbar-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: #4cd137;
    box-shadow: 0 0 8px rgba(76, 209, 55, 0.5);
    flex: 0 0 9px;
    animation: online-status-pulse 2s infinite;
}

.topbar-meta-separator {
    width: 1px;
    height: 14px;
    background: rgba(113, 113, 122, 0.35);
    flex-shrink: 0;
}

.topbar-multilingual,
.topbar-brand {
    display: inline-flex;
    align-items: center;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
}

.topbar-multilingual {
    gap: 5px;
    color: rgba(24, 24, 27, 0.84);
}

.topbar-multilingual-icon {
    font-size: 0.84rem;
    line-height: 1;
}

.topbar-brand {
    font-size: 0.75rem;
    color: rgba(82, 82, 91, 0.82);
}

.topbar-actions {
    position: absolute;
    top: 20px;
    right: 22px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
}

.topbar-actions .language-menu {
    transform: translateY(2.25px);
}

.topbar-role-badge {
    --topbar-role-badge-color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 82px;
    height: 28px;
    padding: 0 14px;
    border: 1px solid var(--topbar-role-badge-color);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.64);
    color: var(--topbar-role-badge-color);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
    transform: translateY(-7.25px);
}

.topbar-role-badge[hidden] {
    display: none;
}

.topbar-role-badge[data-tone='guide'] {
    --topbar-role-badge-color: #007c80;
}

.topbar-role-badge[data-tone='concierge'] {
    --topbar-role-badge-color: #9a641a;
    min-width: 108px;
}

.conversation-shell {
    width: 100%;
    min-width: 0;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-log {
    width: 100%;
    min-width: 0;
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 24px 22px 28px;
}

.message-cluster + .message-cluster {
    margin-top: 22px;
}

.message-cluster--intro {
    margin-top: 6px;
}

.message-cluster--user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.query-pill {
    width: fit-content;
    max-width: min(82%, 640px);
    padding: 16px 22px;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: var(--bg-soft);
    color: var(--text);
    font-size: 1.02rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    text-align: left;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.trace-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.3;
    margin: 0 0 12px;
}

.trace-indicator {
    position: relative;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    animation: trace-orbit-spin 1.65s linear infinite reverse;
}

.trace-dot {
    --size: 2px;
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--size);
    height: var(--size);
    margin-top: calc(var(--size) / -2);
    margin-left: calc(var(--size) / -2);
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.32);
    transform:
        rotate(calc(var(--trace-index) * 60deg))
        translateY(-7px);
    animation: trace-dot-pulse 1.65s ease-in-out infinite;
    animation-delay: calc(var(--trace-index) * -0.14s);
}

html[data-agent-theme='warm-brown'] .trace-dot {
    background: rgba(143, 107, 70, 0.34);
}

.trace-dot:nth-child(1) {
    --size: 5px;
    background: rgba(37, 99, 235, 0.92);
}

html[data-agent-theme='warm-brown'] .trace-dot:nth-child(1) {
    background: rgba(143, 107, 70, 0.94);
}

.trace-dot:nth-child(2) {
    --size: 4px;
    background: rgba(37, 99, 235, 0.72);
}

html[data-agent-theme='warm-brown'] .trace-dot:nth-child(2) {
    background: rgba(143, 107, 70, 0.74);
}

.trace-dot:nth-child(3) {
    --size: 3.5px;
    background: rgba(37, 99, 235, 0.58);
}

html[data-agent-theme='warm-brown'] .trace-dot:nth-child(3) {
    background: rgba(143, 107, 70, 0.58);
}

.trace-dot:nth-child(4) {
    --size: 3px;
}

.trace-dot:nth-child(5) {
    --size: 2.5px;
}

.trace-dot:nth-child(6) {
    --size: 2px;
}

.trace-label:empty {
    display: none;
}

.trace-row--has-label .trace-label {
    display: inline;
}

.trace-row--intro {
    display: none;
}

.trace-row--collapsed {
    margin-bottom: 12px;
    color: var(--muted-strong);
}

.trace-meta:empty {
    display: none;
}

@keyframes trace-orbit-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(-360deg);
    }
}

@keyframes trace-dot-pulse {
    0%,
    100% {
        opacity: 0.3;
        filter: saturate(0.9);
    }
    35% {
        opacity: 1;
        filter: saturate(1.1);
    }
}

@keyframes online-status-pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(76, 209, 55, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(76, 209, 55, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(76, 209, 55, 0);
    }
}

.answer-card {
    width: 100%;
    min-width: 0;
    background: transparent;
}

.answer-body {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.markdown-body {
    font-size: clamp(1.08rem, 1.8vw, 1.26rem);
    line-height: 1.84;
    letter-spacing: -0.015em;
}

.markdown-body p {
    margin: 0;
}

.markdown-body p + p,
.markdown-body ul + p,
.markdown-body ol + p,
.markdown-body p + ul,
.markdown-body p + ol,
.markdown-body hr + p,
.markdown-body h2 + p,
.markdown-body h3 + p {
    margin-top: 18px;
}

.markdown-body ul,
.markdown-body ol {
    margin: 0;
    padding-left: 1.3em;
}

.markdown-body li + li {
    margin-top: 10px;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    margin: 0 0 14px;
    font-family: var(--font-display);
    line-height: 1.22;
    letter-spacing: -0.02em;
}

.markdown-body h2 {
    font-size: clamp(1.56rem, 2.4vw, 1.98rem);
}

.markdown-body h3 {
    font-size: clamp(1.24rem, 2vw, 1.56rem);
}

.markdown-body h4 {
    font-size: 1.12rem;
}

.markdown-body hr {
    margin: 22px 0;
    border: none;
    border-top: 1px solid var(--line);
}

.markdown-body strong {
    font-weight: 700;
}

.markdown-body code {
    padding: 0.12em 0.42em;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.92em;
}

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

.agent-inline-image {
    margin: 0;
}

.agent-inline-image img {
    display: block;
    width: 100%;
    max-width: min(560px, 100%);
    height: auto;
    border-radius: 18px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.agent-inline-image--qr {
    width: min(240px, 72vw, 100%);
}

.agent-inline-image--qr img {
    max-width: 100%;
}

.agent-inline-image figcaption {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.starter-actions,
.followup-list {
    width: 100%;
    min-width: 0;
    display: grid;
    gap: 10px;
    margin-top: 22px;
}

.starter-actions.is-hidden {
    display: none;
}

.starter-chip,
.followup-item {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text);
    text-align: left;
    font-size: 1rem;
    line-height: 1.4;
    text-decoration: none;
    -webkit-text-fill-color: var(--text);
}

.starter-chip {
    width: fit-content;
    max-width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
}

.followup-item {
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

@media (hover: hover) and (pointer: fine) {
    .followup-item:hover,
    .starter-chip:hover {
        color: var(--accent);
    }
}

.starter-chip:focus,
.starter-chip:active,
.followup-item:focus,
.followup-item:active,
.starter-chip:visited,
.followup-item:visited {
    color: var(--text);
    -webkit-text-fill-color: var(--text);
}

.starter-chip:focus-visible,
.followup-item:focus-visible {
    outline: none;
}

.message-meta {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.9rem;
}

.chat-disclaimer-bar {
    width: 100%;
    min-width: 0;
    padding: 0 22px 10px;
}

.composer-dock {
    width: 100%;
    min-width: 0;
    padding: 0 18px 18px;
    background: linear-gradient(180deg, rgba(237, 245, 255, 0) 0%, rgba(237, 245, 255, 0.72) 20%, rgba(237, 245, 255, 0.96) 42%);
}

html[data-agent-theme='warm-brown'] .composer-dock {
    background: linear-gradient(180deg, rgba(244, 239, 231, 0) 0%, rgba(244, 239, 231, 0.72) 20%, rgba(244, 239, 231, 0.96) 42%);
}

.ghost-tool {
    min-width: 48px;
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.82);
    color: var(--muted-strong);
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
}

.ghost-tool:hover {
    background: #ffffff;
    border-color: var(--line-strong);
    color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.16);
}

html[data-agent-theme='warm-brown'] .ghost-tool:hover {
    box-shadow: 0 10px 22px rgba(48, 35, 22, 0.14);
}

.ghost-tool:focus-visible {
    outline: none;
    border-color: rgba(37, 99, 235, 0.38);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

html[data-agent-theme='warm-brown'] .ghost-tool:focus-visible {
    border-color: rgba(143, 107, 70, 0.42);
    box-shadow: 0 0 0 4px rgba(143, 107, 70, 0.15);
}

.composer-shell {
    width: 100%;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.92);
    padding: 14px 16px 12px;
    box-shadow: var(--shadow);
}

.attachment-strip {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.attachment-strip.has-items {
    display: flex;
}

.attachment-chip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 2px 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.82);
    min-width: 180px;
}

.attachment-chip__preview {
    grid-column: 1 / 2;
    grid-row: 1 / 3;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
    background: rgba(15, 23, 42, 0.06);
}

.composer-main {
    width: 100%;
    min-width: 0;
}

.attachment-chip__label {
    grid-column: 2 / 3;
    min-width: 0;
    font-size: 0.92rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-chip__meta {
    grid-column: 2 / 3;
    color: var(--muted);
    font-size: 0.76rem;
}

.attachment-chip__remove {
    grid-column: 3 / 4;
    grid-row: 1 / 3;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
}

#user-input {
    width: 100%;
    max-width: 100%;
    min-height: 56px;
    max-height: 180px;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 1.12rem;
    line-height: 1.6;
    padding: 0;
    display: block;
    overflow-y: auto;
}

#user-input::placeholder {
    color: rgba(32, 33, 35, 0.42);
}

.composer-row {
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 10px;
}

.composer-row--actions {
    margin-top: 10px;
    gap: 16px;
}

.composer-tools {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.language-menu {
    position: static;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.language-menu__item {
    min-width: 40px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--muted-strong);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.language-menu__item[aria-selected='true'] {
    border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
    background: var(--accent-soft);
    color: var(--accent);
}

.language-menu__item:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

html[data-agent-theme='warm-brown'] .language-menu__item:focus-visible {
    box-shadow: 0 0 0 3px rgba(143, 107, 70, 0.15);
}

.composer-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.45;
}

.send-btn {
    min-width: 48px;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
    color: #ffffff;
    font-size: 1.08rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
}

html[data-agent-theme='warm-brown'] .send-btn {
    background: linear-gradient(135deg, #6f5035, #8f6b46);
    color: #fffdfa;
}

.send-btn[data-mode='stop'] {
    min-width: 48px;
    width: 48px;
    height: 48px;
    padding: 0;
}

.query-attachments {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.query-attachment-preview {
    width: min(220px, 58vw);
    height: auto;
    max-height: 220px;
    border-radius: 14px;
    object-fit: cover;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.78);
    display: block;
}

.query-attachment-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    font-size: 0.8rem;
    color: var(--muted-strong);
}

@media (max-width: 700px) {
    .agent-app {
        min-height: 100svh;
    }

    @supports (height: 100dvh) {
        .agent-app {
            height: 100dvh;
            min-height: 100dvh;
        }
    }

    .topbar {
        padding: 18px 16px 16px;
    }

    .brand-name {
        font-size: 1.55rem;
    }

    .brand-lockup {
        gap: 4px;
        padding-right: 112px;
    }

    .brand-stack {
        gap: 5px;
    }

    .topbar-meta-row {
        gap: 7px;
    }

    .topbar-status,
    .topbar-multilingual,
    .topbar-brand,
    .topbar-role-badge {
        font-size: 0.74rem;
    }

    .topbar-meta-separator {
        height: 12px;
    }

    .topbar-brand {
        font-size: 0.7rem;
    }

    .topbar-actions {
        top: 18px;
        right: 16px;
    }

    .topbar-actions .language-menu {
        transform: translateY(-0.92px);
    }

    .topbar-role-badge {
        min-width: 74px;
        height: 26px;
        padding: 0 12px;
        transform: translateY(-7.42px);
    }

    .topbar-role-badge[data-tone='concierge'] {
        min-width: 86px;
        padding-inline: 10px;
    }

    .chat-log {
        padding: 18px 18px 24px;
    }

    .query-pill {
        max-width: 90%;
        font-size: 0.98rem;
        padding: 15px 20px;
    }

    .markdown-body {
        font-size: 1rem;
        line-height: 1.78;
    }

    .chat-disclaimer-bar {
        padding: 0 18px calc(6px + env(safe-area-inset-bottom, 0px));
    }

    .composer-dock {
        padding: 0 10px calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .composer-shell {
        border-radius: 22px;
        padding: 8px 8px 8px;
    }

    #user-input {
        min-height: 24px;
        font-size: 16px;
        line-height: 1.42;
        padding: 2px 4px 0;
    }

    .composer-row {
        align-items: center;
        gap: 12px;
        margin-top: 8px;
    }

    .ghost-tool {
        min-width: 32px;
        width: 32px;
        height: 32px;
        flex-basis: 32px;
    }

    .language-menu {
        gap: 3px;
        padding: 4px;
    }

    .language-menu__item {
        min-width: 34px;
        height: 27px;
        padding: 0 8px;
        font-size: 0.72rem;
    }

    .send-btn {
        min-width: 34px;
        width: 34px;
        height: 34px;
        font-size: 0.96rem;
        flex-basis: 34px;
    }

    .composer-note {
        font-size: 0.68rem;
        line-height: 1.35;
    }
}

@media (min-width: 701px) {
    .agent-app {
        max-width: 920px;
    }
}
