:root {
    --bg: #272727;
    --bg-soft: #303030;
    --panel: #202020;
    --panel-strong: #2b2b2b;
    --text: #f2f4f0;
    --muted: #a7ada8;
    --line: rgba(255, 255, 255, 0.1);
    --button: #f2f4f0;
    --button-text: #080908;
    --shadow: rgba(0, 0, 0, 0.28);
}

/* Full-screen administration workspace. */
body.admin-shell-mode {
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
}

.admin-shell-mode .app-navbar {
    position: fixed;
    top: 14px;
    right: 18px;
    left: auto;
    z-index: 1080;
    display: flex;
    width: auto;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

.admin-shell-mode .app-navbar .container {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
}

.admin-shell-mode .navbar-toggler {
    display: none;
}

.admin-shell-mode .navbar-collapse,
.admin-shell-mode .auth-nav {
    display: flex !important;
    flex: 0 0 auto;
    align-items: center;
}

.admin-shell-mode .auth-nav {
    gap: 8px;
    margin: 0;
    padding: 0;
}

.admin-shell-mode .theme-toggle,
.admin-shell-mode .user-menu-button {
    min-height: 42px;
    border: 1px solid var(--line);
    background: rgba(39, 39, 39, 0.94);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(14px);
}

html[data-theme="light"] .admin-shell-mode .theme-toggle,
html[data-theme="light"] .admin-shell-mode .user-menu-button {
    background: rgba(242, 243, 240, 0.96);
}

.admin-shell-mode .body-content {
    width: 100%;
    max-width: none;
    height: 100vh;
    margin: 0;
    padding: 0;
}

.admin-shell-mode .app-footer {
    display: none;
}

.admin-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: 238px minmax(0, 1fr);
    overflow: hidden;
    background: var(--bg);
}

.admin-sidebar {
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 28px 20px 24px;
    border-right: 1px solid var(--line);
    background: #181918;
}

html[data-theme="light"] .admin-sidebar {
    background: #e9ebe7;
}

.admin-brand {
    color: var(--text);
    font-size: 1.35rem;
    font-weight: 800;
    text-decoration: none;
}

.admin-brand:hover,
.admin-brand:focus {
    color: var(--text);
    text-decoration: none;
}

.admin-role {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.admin-nav {
    display: grid;
    gap: 6px;
    margin-top: 44px;
}

.admin-nav a {
    position: relative;
    min-height: 42px;
    display: flex;
    align-items: center;
    border-radius: 7px;
    padding: 10px 12px 10px 30px;
    color: var(--muted);
    text-decoration: none;
    transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.admin-nav a::before {
    content: "";
    position: absolute;
    left: 12px;
    width: 7px;
    height: 7px;
    border: 1px solid currentColor;
    border-radius: 2px;
}

.admin-nav a:hover,
.admin-nav a:focus,
.admin-nav a.active {
    background: var(--panel-strong);
    color: var(--text);
    transform: translateX(2px);
}

.admin-nav a.active::before {
    border-color: #67d7a0;
    background: #67d7a0;
}

.admin-sidebar-note {
    margin: auto 0 0;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.55;
}

.admin-workspace {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    padding: 34px 34px 48px;
    scrollbar-color: #747774 transparent;
    scrollbar-width: thin;
}

.admin-page-heading {
    min-height: 86px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding-right: 230px;
}

.admin-page-heading h1 {
    margin: 3px 0 5px;
    font-size: 2rem;
    font-weight: 500;
}

.admin-page-heading p {
    margin-bottom: 0;
    color: var(--muted);
}

.admin-metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 28px;
}

.admin-metric-card,
.admin-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.admin-metric-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    padding: 20px;
}

.admin-metric-card::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: var(--metric-accent);
}

.admin-metric-card.accent-green { --metric-accent: #67d7a0; }
.admin-metric-card.accent-blue { --metric-accent: #6daee8; }
.admin-metric-card.accent-amber { --metric-accent: #e8bd68; }
.admin-metric-card.accent-coral { --metric-accent: #df7d72; }

.admin-metric-card span,
.admin-panel header span,
.admin-table-heading span {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
}

.admin-metric-card strong {
    display: block;
    margin: 11px 0 8px;
    color: var(--text);
    font-size: 2rem;
    font-weight: 500;
}

.admin-metric-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.admin-insight-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.75fr);
    gap: 14px;
    margin-top: 14px;
}

.admin-panel {
    padding: 22px;
}

.admin-panel > header,
.admin-table-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.admin-panel h2,
.admin-table-heading h2 {
    margin: 4px 0 0;
    color: var(--text);
    font-size: 1rem;
    font-weight: 650;
}

.admin-live-status {
    border: 1px solid rgba(103, 215, 160, 0.38);
    border-radius: 999px;
    padding: 5px 8px;
    color: #67d7a0 !important;
    font-size: 0.65rem !important;
}

.admin-bar-chart {
    height: 220px;
    display: grid;
    grid-template-columns: repeat(7, minmax(30px, 1fr));
    align-items: end;
    gap: 14px;
    margin-top: 24px;
    padding-top: 12px;
    border-bottom: 1px solid var(--line);
}

.admin-bar-item {
    height: 100%;
    display: grid;
    grid-template-rows: 20px minmax(0, 1fr) 24px;
    justify-items: center;
    gap: 6px;
}

.admin-bar-value,
.admin-bar-item time {
    color: var(--muted);
    font-size: 0.7rem;
}

.admin-bar-track {
    position: relative;
    width: min(30px, 70%);
    height: 100%;
    overflow: hidden;
    border-radius: 5px 5px 0 0;
    background: var(--panel-strong);
}

.admin-bar-fill {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    min-height: 6px;
    border-radius: 5px 5px 0 0;
    background: #67d7a0;
    transition: height 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.admin-status-list {
    display: grid;
    margin-top: 18px;
}

.admin-status-list > div {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.admin-status-list > div:last-child {
    border-bottom: 0;
}

.admin-status-list span,
.admin-status-list strong {
    font-size: 0.78rem;
}

.admin-status-list strong {
    color: var(--muted);
    font-weight: 600;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.status-dot.online { background: #67d7a0; }
.status-dot.external { background: #e8bd68; }

.admin-recent-panel {
    margin-top: 14px;
}

.admin-recent-panel header a {
    color: var(--text);
    font-size: 0.8rem;
}

.admin-recent-list {
    display: grid;
    margin-top: 14px;
}

.admin-recent-row {
    min-width: 0;
    display: grid;
    grid-template-columns: 34px minmax(160px, 1fr) 130px 90px;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.admin-user-initial {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--panel-strong);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 700;
}

.admin-user-copy {
    min-width: 0;
    display: grid;
}

.admin-user-copy strong,
.admin-user-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-user-copy strong {
    font-size: 0.84rem;
}

.admin-user-copy small,
.admin-recent-row time,
.admin-prompt-count {
    color: var(--muted);
    font-size: 0.72rem;
}

.admin-prompt-count {
    text-align: right;
}

.admin-alert {
    margin-top: 18px;
}

.admin-table-wrap {
    margin-top: 24px;
    padding: 20px;
}

.admin-table-heading {
    margin-bottom: 14px;
}

.admin-table {
    min-width: 940px;
    border-collapse: collapse;
    border-spacing: 0;
}

.admin-table th {
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.admin-table td {
    border-bottom: 1px solid var(--line);
}

.admin-table tr {
    background: transparent;
}

.admin-table tr:hover td {
    background: var(--panel-strong);
}

.admin-table a {
    border-radius: 5px;
    padding: 6px 8px;
    background: var(--panel-strong);
    text-decoration: none;
}

.admin-table a:hover,
.admin-table a:focus {
    background: var(--button);
    color: var(--button-text);
}

@media screen and (max-width: 1100px) {
    .admin-metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-insight-grid {
        grid-template-columns: 1fr;
    }
}

@media screen and (max-width: 760px) {
    body.admin-shell-mode {
        overflow: auto;
    }

    .admin-shell-mode .body-content,
    .admin-shell {
        height: auto;
        min-height: 100vh;
    }

    .admin-shell {
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .admin-sidebar {
        min-height: auto;
        padding: 20px 16px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .admin-role,
    .admin-sidebar-note {
        display: none;
    }

    .admin-nav {
        grid-template-columns: repeat(4, max-content);
        overflow-x: auto;
        margin-top: 18px;
    }

    .admin-nav a {
        padding-right: 12px;
    }

    .admin-workspace {
        overflow: visible;
        padding: 82px 16px 32px;
    }

    .admin-page-heading {
        align-items: flex-start;
        flex-direction: column;
        padding-right: 0;
    }

    .admin-metric-grid {
        grid-template-columns: 1fr 1fr;
    }

    .admin-recent-row {
        grid-template-columns: 34px minmax(0, 1fr) auto;
    }

    .admin-recent-row time {
        display: none;
    }
}

/* Contact form */
.contact-page {
    padding: 64px 0 20px;
}

.contact-heading {
    max-width: 760px;
    padding-bottom: 42px;
}

.contact-heading h1 {
    margin: 0;
    color: var(--text);
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 300;
    line-height: 1;
}

.contact-heading > p:last-child {
    max-width: 640px;
    margin: 18px 0 0;
    color: var(--muted);
    line-height: 1.7;
}

.contact-layout {
    display: grid;
    grid-template-columns: minmax(240px, 0.72fr) minmax(0, 1.28fr);
    gap: 56px;
    border-top: 1px solid var(--line);
    padding-top: 42px;
}

.contact-details h2,
.contact-form-section h2 {
    margin: 0 0 24px;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 700;
}

.contact-details dl {
    display: grid;
    gap: 22px;
    margin: 0;
}

.contact-details dl > div {
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
}

.contact-details dt {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
}

.contact-details dd {
    margin: 0;
    color: var(--text);
}

.contact-details a {
    text-decoration-color: var(--line);
    text-underline-offset: 4px;
}

.contact-form-section {
    border-left: 1px solid var(--line);
    padding-left: 56px;
}

.contact-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.contact-field {
    min-width: 0;
}

.contact-field-wide {
    grid-column: 1 / -1;
}

.contact-field label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 650;
}

.contact-input {
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--bg-soft);
    color: var(--text);
}

.contact-input:focus {
    border-color: var(--muted);
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--line) 70%, transparent);
}

.contact-message-input {
    min-height: 170px;
    resize: vertical;
}

.contact-submit {
    display: grid;
    justify-items: start;
    gap: 8px;
}

.contact-submit .auth-alert,
.contact-submit .auth-message {
    max-width: 100%;
}

@media screen and (max-width: 760px) {
    .contact-page {
        padding-top: 40px;
    }

    .contact-layout,
    .contact-form {
        grid-template-columns: 1fr;
    }

    .contact-layout {
        gap: 34px;
    }

    .contact-form-section {
        border-top: 1px solid var(--line);
        border-left: 0;
        padding-top: 32px;
        padding-left: 0;
    }

    .contact-field-wide {
        grid-column: auto;
    }
}

@media screen and (max-width: 480px) {
    .admin-metric-grid {
        grid-template-columns: 1fr;
    }

    .admin-bar-chart {
        gap: 7px;
    }

    .admin-recent-row {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .admin-prompt-count {
        display: none;
    }
}

html[data-theme="light"] {
    --bg: #f4f4f1;
    --bg-soft: #e8e8e2;
    --panel: #ffffff;
    --panel-strong: #f8f8f4;
    --text: #111412;
    --muted: #5f6761;
    --line: rgba(17, 20, 18, 0.12);
    --button: #111412;
    --button-text: #ffffff;
    --shadow: rgba(17, 20, 18, 0.1);
}

* {
    transition: background-color 220ms ease, color 220ms ease, border-color 220ms ease, box-shadow 220ms ease, transform 220ms ease, opacity 220ms ease;
}

html {
    background: var(--bg);
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Arial, sans-serif;
    opacity: 0;
    transform: translateY(6px);
}

body.page-ready {
    opacity: 1;
    transform: translateY(0);
}

a {
    color: inherit;
}

.app-navbar {
    position: sticky;
    top: 0;
    z-index: 1040;
    background: rgba(39, 39, 39, 0.94);
    border-bottom: 0;
    backdrop-filter: blur(16px);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .app-navbar {
    background: rgba(244, 244, 241, 0.82);
}

.navbar-brand {
    color: var(--text) !important;
    font-weight: 700;
    letter-spacing: 0;
}

.app-navbar .navbar-nav .nav-link {
    min-width: 72px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted) !important;
    font-size: 0.93rem;
    border-radius: 999px;
    padding: 9px 18px !important;
}

.app-navbar .navbar-nav .nav-link:hover,
.app-navbar .navbar-nav .nav-link:focus {
    background: var(--button);
    color: var(--button-text) !important;
}

.nav-cta {
    border: 1px solid var(--line);
    border-radius: 999px;
    margin-left: 8px;
    padding-left: 14px !important;
    padding-right: 14px !important;
}

.auth-nav {
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    min-width: 88px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 999px;
    background: #2a2c2b;
    color: #f1f1ed;
    font-size: 0.9rem;
}

.theme-toggle:hover,
.theme-toggle:focus {
    background: #3a3c3b;
    color: #ffffff;
}

html[data-theme="light"] .theme-toggle {
    background: #d9dbd6;
    color: #242725;
}

html[data-theme="light"] .theme-toggle:hover,
html[data-theme="light"] .theme-toggle:focus {
    background: #c8cbc5;
    color: #111412;
}

.theme-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9b9f9b;
}

.user-menu-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    border: 0;
    border-radius: 999px;
    padding: 4px 10px 4px 5px;
    background: var(--panel);
    color: var(--text);
}

.user-menu-button:hover,
.user-menu-button:focus {
    background: var(--panel-strong);
    color: var(--text);
}

.user-avatar,
.profile-preview {
    position: relative;
    overflow: hidden;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #3a3d3b;
    color: #ffffff;
    font-weight: 700;
}

.user-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.88rem;
}

.user-avatar img,
.profile-preview img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-menu-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.92rem;
}

.user-dropdown {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    background: var(--panel);
    box-shadow: 0 24px 70px var(--shadow);
}

.user-dropdown .dropdown-item {
    border-radius: 6px;
    color: var(--text);
}

.user-dropdown .dropdown-item:hover,
.user-dropdown .dropdown-item:focus {
    background: var(--button);
    color: var(--button-text);
}

.body-content {
    margin-top: 0;
    padding-left: 15px;
    padding-right: 15px;
}

.container,
.hero-copy,
.section-heading,
.insight-section,
.dashboard-hero,
.planner-shell,
.chat-sidebar,
.settings-copy,
.settings-form {
    min-width: 0;
}

h1,
h2,
h3,
p,
a,
span,
strong,
label {
    overflow-wrap: anywhere;
}

.app-footer {
    border-top: 1px solid var(--line);
    margin-top: 78px;
    padding: 24px 0 8px;
    color: var(--muted);
}

input,
select,
textarea {
    max-width: none;
}

.home-page,
.dashboard-page,
.chat-page,
.settings-page {
    padding-top: 44px;
}

.hero-grid {
    min-height: 620px;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
    align-items: center;
    gap: 56px;
}

.hero-visual {
    position: relative;
    overflow: hidden;
    min-height: 520px;
    border-radius: 8px;
    background: #050505;
}

.hero-visual img {
    width: 100%;
    height: 100%;
    min-height: 520px;
    object-fit: cover;
    filter: grayscale(1) contrast(1.08);
    opacity: 0.92;
}

.hero-visual::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 30%, var(--bg) 100%);
}

.hero-copy h1,
.section-heading h2,
.insight-section h2 {
    margin: 0;
    font-size: clamp(2.6rem, 6vw, 5.9rem);
    font-weight: 300;
    letter-spacing: 0;
    line-height: 0.95;
}

.hero-copy p,
.insight-card p,
.dashboard-hero p,
.planner-shell p,
.feature-card p,
.metric-card p {
    color: var(--muted);
}

.eyebrow {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 22px 0;
}

.pill-row span {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 14px;
    color: var(--muted);
    font-size: 0.86rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.primary-action,
.ghost-action,
.auth-button {
    min-height: 44px;
    border-radius: 8px;
    padding: 10px 18px;
    font-weight: 700;
}

.primary-action,
.auth-button {
    border: 1px solid var(--button);
    background: var(--button);
    color: var(--button-text);
}

.primary-action:hover,
.primary-action:focus,
.auth-button:hover,
.auth-button:focus {
    background: var(--panel-strong);
    border-color: var(--panel-strong);
    color: var(--text);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
    transform: translateY(-1px);
}

html[data-theme="light"] .primary-action:hover,
html[data-theme="light"] .primary-action:focus,
html[data-theme="light"] .auth-button:hover,
html[data-theme="light"] .auth-button:focus {
    background: #d8dbd5;
    border-color: #d8dbd5;
    color: #111412;
}

.ghost-action:hover,
.ghost-action:focus {
    background: var(--button);
    color: var(--button-text);
    transform: translateY(-1px);
}

.ghost-action {
    border: 1px solid var(--line);
    color: var(--text);
}

.section-block {
    padding: 78px 0 36px;
}

.section-heading {
    margin-bottom: 36px;
}

.feature-grid,
.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.feature-card,
.metric-card,
.glass-panel,
.insight-card,
.planner-shell {
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 80px var(--shadow);
}

.feature-card {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 28px;
}

.feature-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--panel-strong);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 700;
}

.feature-card h3 {
    margin: 22px 0 8px;
    font-size: 1.1rem;
}

.insight-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.72fr);
    gap: 42px;
    align-items: end;
    padding: 92px 0 22px;
}

.insight-card {
    padding: 30px;
}

.insight-card a {
    display: inline-block;
    margin-top: 18px;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.auth-page {
    min-height: calc(100vh - 150px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 58px 0;
}

.auth-panel {
    width: min(100%, 450px);
    padding: 34px;
}

.auth-panel h1,
.dashboard-hero h1,
.planner-shell h2 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.6rem);
    font-weight: 300;
    letter-spacing: 0;
}

.auth-copy {
    margin: 14px 0 26px;
    color: var(--muted);
}

.form-stack {
    display: grid;
    gap: 10px;
}

.form-stack label {
    margin-top: 8px;
    color: var(--text);
    font-weight: 600;
}

.auth-input {
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg-soft);
    color: var(--text);
}

.auth-input:focus {
    border-color: var(--text);
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.08);
    background: var(--bg-soft);
    color: var(--text);
}

html[data-theme="light"] .auth-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(17, 20, 18, 0.08);
}

.auth-button {
    margin-top: 16px;
}

.auth-feedback {
    display: block;
    width: 100%;
    margin: 4px 0 0;
}

.auth-feedback ul {
    margin: 0;
    padding-left: 18px;
}

.auth-alert,
.auth-message {
    margin: 0 0 16px;
    border: 1px solid rgba(245, 112, 86, 0.32);
    border-radius: 8px;
    padding: 12px 14px;
    background: rgba(245, 112, 86, 0.1);
    color: #ffb3a3;
    font-size: 0.95rem;
}

html[data-theme="light"] .auth-alert,
html[data-theme="light"] .auth-message {
    color: #8a2d1f;
}

.auth-message-success {
    border-color: rgba(87, 184, 124, 0.38);
    background: rgba(87, 184, 124, 0.12);
    color: #9be2b4;
}

html[data-theme="light"] .auth-message-success {
    color: #22653d;
}

.auth-switch {
    margin: 22px 0 0;
    color: var(--muted);
}

.auth-switch a {
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.dashboard-page {
    display: grid;
    gap: 24px;
}

.dashboard-hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    padding: 34px;
}

.metric-card {
    padding: 26px;
}

.metric-card span,
.planner-preview span {
    display: block;
    color: var(--muted);
    font-size: 0.86rem;
}

.metric-card strong {
    display: block;
    margin: 10px 0;
    font-size: 2.2rem;
    font-weight: 300;
}

.planner-shell {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(280px, 1.05fr);
    gap: 28px;
    padding: 34px;
}

.planner-preview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.planner-preview div {
    min-height: 112px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: var(--panel-strong);
}

.planner-preview strong {
    color: var(--text);
    font-size: 1.2rem;
}

.chat-shell {
    min-height: 690px;
    display: grid;
    grid-template-columns: minmax(260px, 0.42fr) minmax(0, 0.58fr);
    overflow: hidden;
}

.chat-sidebar {
    padding: 34px;
    border-right: 1px solid var(--line);
}

.chat-sidebar h1,
.settings-copy h1 {
    margin: 0;
    font-size: clamp(2.3rem, 5vw, 5rem);
    font-weight: 300;
    line-height: 0.96;
}

.settings-copy h1 {
    font-size: clamp(2.2rem, 4vw, 4rem);
    line-height: 1.02;
}

.settings-message {
    display: block;
    margin-top: 18px;
}

.suggestion-list {
    display: grid;
    gap: 10px;
    margin-top: 30px;
}

.suggestion-list span {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 9px 14px;
    color: var(--muted);
}

.chat-workspace {
    min-height: 690px;
    display: grid;
    grid-template-rows: 1fr auto;
    padding: 24px;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    padding-right: 6px;
}

.chat-bubble {
    max-width: 78%;
    border-radius: 8px;
    padding: 14px 16px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.chat-bot {
    align-self: flex-start;
    background: var(--panel-strong);
    color: var(--text);
}

.chat-user {
    align-self: flex-end;
    background: var(--button);
    color: var(--button-text);
}

.chat-input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding-top: 18px;
}

.chat-input {
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg-soft);
    color: var(--text);
}

.chat-send {
    min-width: 96px;
}

.settings-shell {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(300px, 0.72fr);
    gap: 34px;
    padding: 34px;
}

.settings-form {
    border-left: 1px solid var(--line);
    padding-left: 34px;
}

.profile-preview {
    width: 94px;
    height: 94px;
    margin-bottom: 22px;
    font-size: 2rem;
}

.profile-photo-editor {
    position: relative;
    width: 94px;
    margin-bottom: 22px;
}

.profile-photo-editor .profile-preview {
    margin-bottom: 0;
}

.profile-edit-button {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 2px solid var(--panel);
    border-radius: 50%;
    background: var(--button);
    color: var(--button-text);
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
}

.profile-edit-button svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
}

.profile-edit-button:hover,
.profile-edit-button:focus {
    transform: translateY(-1px);
}

.profile-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.settings-divider {
    height: 1px;
    margin: 18px 0 8px;
    background: var(--line);
}

.settings-subtitle {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.field-note {
    margin: -4px 0 6px;
    color: var(--muted);
    font-size: 0.88rem;
}

.file-input {
    padding-top: 11px;
}

.chat-app-page {
    min-height: calc(100vh - 96px);
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 0;
    padding-top: 24px;
}

.chat-app-sidebar {
    position: sticky;
    top: 76px;
    height: calc(100vh - 100px);
    overflow-y: auto;
    border-right: 1px solid var(--line);
    padding: 18px 14px 18px 0;
}

.chat-app-brand {
    margin-bottom: 18px;
    color: var(--text);
    font-size: 1.2rem;
    font-weight: 800;
}

.side-action,
.side-search-button {
    display: block;
    width: 100%;
    border: 0;
    border-radius: 8px;
    padding: 11px 12px;
    background: transparent;
    color: var(--text);
    text-align: left;
    text-decoration: none;
}

.side-action:hover,
.side-action:focus,
.side-action.active,
.side-search-button:hover,
.side-search-button:focus {
    background: var(--panel-strong);
    color: var(--text);
}

.side-search {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin: 12px 0 18px;
}

.side-search-input {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--bg-soft);
    color: var(--text);
}

.side-search-button {
    width: auto;
    text-align: center;
}

.side-section-title {
    margin: 18px 0 10px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
}

.history-item {
    border-radius: 8px;
    padding: 10px 12px;
}

.history-item:hover {
    background: var(--panel-strong);
}

.history-item span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.history-item strong {
    display: block;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
}

.chat-app-main {
    min-height: calc(100vh - 100px);
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: 18px;
    padding: 78px 0 24px 42px;
}

.chat-welcome {
    text-align: center;
}

.chat-welcome h1 {
    margin: 0;
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    font-weight: 500;
}

.mode-card {
    width: min(100%, 820px);
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    background: var(--panel);
}

.mode-toggle {
    margin-bottom: 16px;
}

.mode-toggle label {
    margin-right: 16px;
    color: var(--text);
}

.guided-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.guided-wide {
    grid-column: 1 / -1;
}

.prompt-panel label,
.guided-grid label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.88rem;
}

.chat-app-messages {
    width: min(100%, 820px);
    margin: 0 auto;
    padding: 8px 0;
}

.chat-composer {
    width: min(100%, 820px);
    margin: 0 auto;
    display: flex;
    justify-content: flex-end;
}

.admin-page {
    display: grid;
    gap: 24px;
    padding-top: 44px;
}

.admin-table-wrap {
    overflow-x: auto;
    padding: 18px;
}

.admin-table {
    width: 100%;
    min-width: 980px;
    border-collapse: separate;
    border-spacing: 0 8px;
    color: var(--text);
}

.admin-table th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

.admin-table th,
.admin-table td {
    padding: 12px;
    vertical-align: middle;
}

.admin-table tr {
    background: var(--panel-strong);
}

.admin-table input[type="text"] {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    background: var(--bg-soft);
    color: var(--text);
}

.admin-table a {
    display: inline-block;
    margin-right: 8px;
    color: var(--text);
    font-weight: 700;
}

@media screen and (min-width: 768px) {
    .body-content {
        padding: 0;
    }
}

@media screen and (max-width: 991px) {
    .hero-grid,
    .insight-section,
    .planner-shell,
    .chat-shell,
    .settings-shell {
        grid-template-columns: 1fr;
    }

    .chat-sidebar,
    .settings-form {
        border-right: 0;
        border-left: 0;
        border-bottom: 1px solid var(--line);
        padding-left: 0;
    }

    .settings-form {
        border-bottom: 0;
        padding-left: 0;
    }

    .hero-visual,
    .hero-visual img {
        min-height: 360px;
    }

    .hero-visual::after {
        background: linear-gradient(180deg, transparent 40%, var(--bg) 100%);
    }

    .feature-grid,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .chat-app-page {
        grid-template-columns: 1fr;
    }

    .chat-app-sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding-right: 0;
        padding-bottom: 18px;
    }

    .chat-app-main {
        padding: 30px 0 24px;
    }

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

@media screen and (max-width: 575px) {
    .home-page,
    .dashboard-page,
    .chat-page,
    .settings-page {
        padding-top: 26px;
    }

    .hero-copy h1,
    .section-heading h2,
    .insight-section h2 {
        font-size: 2.35rem;
        line-height: 1.02;
    }

    .auth-panel,
    .dashboard-hero,
    .planner-shell,
    .settings-shell {
        padding: 24px;
    }

    .planner-preview {
        grid-template-columns: 1fr;
    }

    .chat-input-row {
        grid-template-columns: 1fr;
    }

    .chat-bubble {
        max-width: 100%;
    }

    .guided-grid {
        grid-template-columns: 1fr;
    }
}

/* Structured chat history and rule-based refinements. */
.chat-shell-mode [id$="ChatUpdatePanel"] {
    display: block;
    width: 100%;
    height: 100vh;
}

.history-created,
.history-message-count {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.35;
}

.history-message-count {
    margin-top: 2px;
}

.chat-rule-panel {
    width: 100%;
    margin-bottom: 10px;
}

.chat-rule-panel > span {
    display: block;
    margin: 0 0 8px 4px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.chat-rule-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    overflow: visible;
    padding: 0 2px 2px;
}

.chat-rule-button {
    flex: 0 0 auto;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 12px;
    background: var(--panel);
    color: var(--muted);
    font-size: 0.78rem;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.chat-rule-button:hover,
.chat-rule-button:focus {
    border-color: var(--muted);
    background: var(--panel-strong);
    color: var(--text);
    transform: translateY(-1px) scale(1.01);
}

.chat-shell-mode .chat-bot {
    max-width: min(92%, 780px);
    padding: 20px 22px;
    white-space: normal;
}

.chat-response {
    display: grid;
    gap: 10px;
    line-height: 1.62;
}

.chat-response p,
.chat-response h3,
.chat-response h4,
.chat-response ul {
    margin: 0;
}

.chat-response h3 {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--text);
    font-size: 0.98rem;
    font-weight: 750;
}

.chat-response h3:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.chat-response h4 {
    margin-top: 8px;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 700;
}

.chat-response h4.selected-result {
    border-left: 3px solid #8e918d;
    padding: 9px 11px;
    background: var(--panel-strong);
}

.chat-response-list {
    display: grid;
    gap: 7px;
    padding-left: 20px;
    color: var(--text);
}

.chat-response-list li::marker {
    color: var(--muted);
}

.is-chat-updating .chat-app-main {
    opacity: 0.72;
    transition: opacity 140ms ease;
}

@media screen and (max-width: 575px) {
    .chat-shell-mode .chat-bot {
        max-width: 100%;
        padding: 16px;
    }

    .chat-rule-panel > span {
        padding-right: 160px;
    }
}

body.chat-shell-mode {
    overflow: hidden;
}

.chat-shell-mode .app-navbar {
    min-height: 58px;
    box-shadow: none;
}

.chat-shell-mode .app-navbar .container {
    width: 100%;
    max-width: none;
    justify-content: flex-end;
    padding: 8px 20px;
}

.chat-shell-mode .navbar-toggler {
    display: none;
}

.chat-shell-mode .navbar-collapse {
    display: flex !important;
    flex-basis: auto;
    flex-grow: 0;
    justify-content: flex-end !important;
}

.chat-shell-mode .body-content {
    width: 100%;
    max-width: none;
    height: calc(100vh - 58px);
    margin: 0;
    padding: 0;
}

.chat-shell-mode .auth-nav {
    justify-content: flex-end;
}

.chat-shell-mode .user-menu-button {
    background: #343635;
}

html[data-theme="light"] .chat-shell-mode .user-menu-button {
    background: #e2e4df;
}

.chat-shell-mode .app-footer {
    display: none;
}

.chat-shell-mode .chat-app-page {
    position: relative;
    height: calc(100vh - 58px);
    min-height: 0;
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    padding: 0;
    overflow: hidden;
    background: var(--bg);
}

.chat-shell-mode .chat-app-sidebar {
    position: relative;
    top: auto;
    height: calc(100vh - 58px);
    overflow-y: auto;
    border-right: 1px solid var(--line);
    padding: 20px 14px 20px 22px;
    background: #181818;
}

html[data-theme="light"] .chat-shell-mode .chat-app-sidebar {
    background: #ededeb;
}

.chat-shell-mode .chat-app-page.sidebar-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
}

.chat-shell-mode .chat-app-page.sidebar-collapsed .chat-app-sidebar {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-24px);
    border-right: 0;
    padding-left: 0;
    padding-right: 0;
}

.sidebar-toggle {
    position: fixed;
    left: 18px;
    top: 70px;
    z-index: 1060;
    width: 38px;
    height: 38px;
    display: grid;
    place-content: center;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #303231;
    color: #fff;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
}

.sidebar-toggle span {
    width: 14px;
    height: 2px;
    border-radius: 99px;
    background: currentColor;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus {
    background: #414342;
    color: #fff;
}

html[data-theme="light"] .sidebar-toggle {
    background: #dadcd7;
    color: #171918;
}

html[data-theme="light"] .sidebar-toggle:hover,
html[data-theme="light"] .sidebar-toggle:focus {
    background: #c9ccc6;
    color: #111412;
}

.chat-shell-mode .chat-app-brand {
    padding-left: 44px;
}

.chat-shell-mode .side-action,
.chat-shell-mode .side-search-button,
.chat-shell-mode .history-item {
    min-height: 42px;
    border-radius: 12px;
}

.chat-shell-mode .history-item {
    display: block;
    margin-bottom: 6px;
    text-decoration: none;
}

.chat-shell-mode .history-item:hover,
.chat-shell-mode .history-item:focus {
    background: #2e302f;
    color: var(--text);
}

html[data-theme="light"] .chat-shell-mode .history-item:hover,
html[data-theme="light"] .chat-shell-mode .history-item:focus {
    background: #dfe1dc;
}

.chat-shell-mode .chat-app-main {
    height: calc(100vh - 58px);
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 18px;
    overflow: hidden;
    padding: 54px 28px 22px;
}

.chat-shell-mode .chat-welcome {
    width: min(100%, 840px);
    margin: 0 auto;
    grid-row: 1;
}

.chat-shell-mode .chat-app-messages {
    width: min(100%, 840px);
    min-height: 0;
    margin: 0 auto;
    overflow-y: auto;
    padding: 8px 4px 20px;
    grid-row: 2;
}

.chat-shell-mode .chat-bubble {
    max-width: min(78%, 720px);
    border-radius: 16px;
}

.chat-shell-mode .chat-composer {
    width: min(100%, 840px);
    margin: 0 auto;
    display: block;
    grid-row: 3;
}

.chat-shell-mode .mode-card {
    width: 100%;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px;
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    box-shadow: 0 20px 60px var(--shadow);
}

.composer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.chat-shell-mode .mode-toggle {
    margin: 0;
}

.chat-shell-mode .mode-toggle tbody,
.chat-shell-mode .mode-toggle tr {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-shell-mode .mode-toggle td {
    padding: 0;
}

.chat-shell-mode .mode-toggle input {
    position: absolute;
    opacity: 0;
}

.chat-shell-mode .mode-toggle label {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    border-radius: 999px;
    padding: 8px 13px;
    margin: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.chat-shell-mode .mode-toggle input:checked + label {
    background: #333534;
    color: #ffffff;
}

html[data-theme="light"] .chat-shell-mode .mode-toggle input:checked + label {
    background: #d7dad4;
    color: #111412;
}

.response-select-wrap {
    position: relative;
    flex: 0 0 auto;
}

.response-select-wrap::after {
    content: "";
    position: absolute;
    right: 14px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    color: #d9ddda;
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}

.response-select {
    min-height: 40px;
    min-width: 126px;
    appearance: none;
    border: 0;
    border-radius: 999px;
    padding: 0 36px 0 16px;
    background: #343635;
    color: #f8faf7;
    font-weight: 600;
    outline: 0;
}

.response-select:hover,
.response-select:focus {
    background: #414342;
    color: #fff;
}

.response-select option {
    background: #353535;
    color: #f8faf7;
}

html[data-theme="light"] .response-select {
    background: #d9dbd6;
    color: #171918;
}

html[data-theme="light"] .response-select:hover,
html[data-theme="light"] .response-select:focus {
    background: #c9ccc6;
    color: #111412;
}

html[data-theme="light"] .response-select-wrap::after {
    color: #171918;
}

.chat-shell-mode .guided-grid {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.chat-shell-mode .prompt-panel .chat-input {
    min-height: 52px;
}

.send-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.inline-validation {
    display: block;
    margin-top: 8px;
    color: #ffb3a3;
    font-size: 0.86rem;
    line-height: 1.45;
}

html[data-theme="light"] .inline-validation {
    color: #8a2d1f;
}

.chat-validation {
    text-align: right;
}

.chat-shell-mode .chat-send {
    min-width: 112px;
    border-radius: 999px;
}

@media screen and (max-width: 991px) {
    body.chat-shell-mode {
        overflow: auto;
    }

    .chat-shell-mode .body-content,
    .chat-shell-mode .chat-app-page,
    .chat-shell-mode .chat-app-main,
    .chat-shell-mode .chat-app-sidebar {
        height: auto;
        min-height: calc(100vh - 58px);
    }

    .chat-shell-mode .chat-app-page,
    .chat-shell-mode .chat-app-page.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .chat-shell-mode .chat-app-sidebar {
        position: fixed;
        inset: 58px auto 0 0;
        z-index: 1050;
        width: min(86vw, 320px);
        min-height: 0;
        height: calc(100vh - 58px);
        box-shadow: 20px 0 60px rgba(0, 0, 0, 0.28);
    }

    .chat-shell-mode .chat-app-page.sidebar-collapsed .chat-app-sidebar {
        transform: translateX(-100%);
    }

    .chat-shell-mode .chat-app-main {
        padding: 64px 16px 18px;
    }

    .chat-shell-mode .guided-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media screen and (max-width: 575px) {
    .chat-shell-mode .chat-app-main {
        padding-left: 12px;
        padding-right: 12px;
    }

    .composer-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .chat-shell-mode .guided-grid {
        grid-template-columns: 1fr;
    }

    .chat-shell-mode .chat-bubble {
        max-width: 100%;
    }
}

body.chat-shell-mode {
    --chat-nav-height: 72px;
    height: 100vh;
    overflow: hidden;
}

.chat-shell-mode .app-navbar {
    height: var(--chat-nav-height);
    min-height: var(--chat-nav-height);
    padding: 0;
}

.chat-shell-mode .app-navbar .container {
    height: var(--chat-nav-height);
    padding: 0 20px;
}

.chat-shell-mode .body-content,
.chat-shell-mode .chat-app-page,
.chat-shell-mode .chat-app-main,
.chat-shell-mode .chat-app-sidebar {
    height: calc(100vh - var(--chat-nav-height));
    min-height: 0;
}

.chat-shell-mode .body-content,
.chat-shell-mode .chat-app-page {
    overflow: hidden;
}

.chat-shell-mode .chat-app-page {
    grid-template-columns: 292px minmax(0, 1fr);
    transition: grid-template-columns 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.chat-shell-mode .chat-app-sidebar {
    top: auto;
    overflow: hidden auto;
    background: var(--bg);
    transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 220ms ease, padding 280ms ease, border-color 220ms ease;
}

html[data-theme="light"] .chat-shell-mode .chat-app-sidebar {
    background: var(--bg);
}

.chat-shell-mode .chat-app-page.sidebar-collapsed .chat-app-sidebar {
    transform: translateX(-100%);
}

.sidebar-toggle {
    top: calc(var(--chat-nav-height) + 12px);
    transition: background-color 220ms ease, color 220ms ease, transform 220ms ease, box-shadow 220ms ease;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus {
    transform: translateY(-1px);
}

.chat-shell-mode .chat-app-main {
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    padding: 36px 28px 18px;
}

.chat-shell-mode .chat-app-messages {
    overflow: hidden auto;
}

.chat-shell-mode .mode-card {
    max-height: 42vh;
    overflow: hidden auto;
}

.chat-shell-mode .composer-toolbar {
    justify-content: flex-start;
}

.chat-shell-mode .prompt-panel .chat-input {
    width: 100%;
}

body.chat-shell-mode,
.chat-shell-mode .chat-app-sidebar,
.chat-shell-mode .chat-app-messages,
.chat-shell-mode .mode-card {
    scrollbar-color: #747774 transparent;
    scrollbar-width: thin;
}

html[data-theme="light"] body.chat-shell-mode,
html[data-theme="light"] .chat-shell-mode .chat-app-sidebar,
html[data-theme="light"] .chat-shell-mode .chat-app-messages,
html[data-theme="light"] .chat-shell-mode .mode-card {
    scrollbar-color: #9ca09a transparent;
}

.chat-shell-mode .chat-app-sidebar::-webkit-scrollbar,
.chat-shell-mode .chat-app-messages::-webkit-scrollbar,
.chat-shell-mode .mode-card::-webkit-scrollbar {
    width: 9px;
}

.chat-shell-mode .chat-app-sidebar::-webkit-scrollbar-track,
.chat-shell-mode .chat-app-messages::-webkit-scrollbar-track,
.chat-shell-mode .mode-card::-webkit-scrollbar-track {
    background: transparent;
}

.chat-shell-mode .chat-app-sidebar::-webkit-scrollbar-thumb,
.chat-shell-mode .chat-app-messages::-webkit-scrollbar-thumb,
.chat-shell-mode .mode-card::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: #747774;
    background-clip: padding-box;
}

html[data-theme="light"] .chat-shell-mode .chat-app-sidebar::-webkit-scrollbar-thumb,
html[data-theme="light"] .chat-shell-mode .chat-app-messages::-webkit-scrollbar-thumb,
html[data-theme="light"] .chat-shell-mode .mode-card::-webkit-scrollbar-thumb {
    background: #9ca09a;
    background-clip: padding-box;
}

.chat-shell-mode .chat-app-sidebar::-webkit-scrollbar-button,
.chat-shell-mode .chat-app-messages::-webkit-scrollbar-button,
.chat-shell-mode .mode-card::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

@media screen and (max-width: 991px) {
    body.chat-shell-mode {
        overflow: hidden;
    }

    .chat-shell-mode .body-content,
    .chat-shell-mode .chat-app-page,
    .chat-shell-mode .chat-app-main {
        height: calc(100vh - var(--chat-nav-height));
        min-height: 0;
    }

    .chat-shell-mode .chat-app-sidebar {
        inset: var(--chat-nav-height) auto 0 0;
        height: calc(100vh - var(--chat-nav-height));
        min-height: 0;
    }

    .chat-shell-mode .chat-app-main {
        padding: 34px 16px 18px;
    }
}

/* Chat refinement pass */
body.chat-shell-mode {
    --chat-nav-height: 0px;
}

.chat-shell-mode .app-navbar {
    display: none;
}

.chat-shell-mode .body-content,
.chat-shell-mode .chat-app-page,
.chat-shell-mode .chat-app-main,
.chat-shell-mode .chat-app-sidebar {
    height: 100vh;
}

.chat-shell-mode .chat-app-page {
    padding-top: 0;
    grid-template-columns: 292px minmax(0, 1fr);
}

.chat-shell-mode .chat-app-sidebar {
    padding: 18px 10px 18px 18px;
    background: var(--bg);
}

.sidebar-toggle {
    top: 18px;
}

.chat-shell-mode .chat-app-brand {
    display: block;
    min-height: 38px;
    margin: 0 0 18px;
    padding-left: 48px;
    color: var(--text);
    text-decoration: none;
}

.chat-shell-mode .chat-app-brand:hover,
.chat-shell-mode .chat-app-brand:focus {
    color: var(--text);
    text-decoration: none;
}

.chat-shell-mode .chat-app-main {
    height: 100vh;
    padding: 24px 28px 18px;
}

.chat-shell-mode .chat-app-messages {
    padding-top: 0;
    gap: 10px;
    padding-bottom: 12px;
}

.chat-shell-mode .chat-bubble {
    text-align: left;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.chat-shell-mode .chat-user {
    max-width: min(86%, 760px);
    padding: 12px 16px;
    line-height: 1.45;
    white-space: normal;
}

.chat-shell-mode .chat-user-content {
    display: block;
}

.history-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px;
    border-radius: 10px;
}

.history-row:hover,
.history-row.menu-open,
.history-row.is-pinned {
    background: var(--panel-strong);
}

.history-row.is-pinned .history-pin {
    opacity: 1;
}

.chat-shell-mode .history-row .history-item {
    min-width: 0;
    margin-bottom: 0;
    background: transparent;
}

.history-item strong {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.history-actions {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding-right: 4px;
    opacity: 0;
    transition: opacity 180ms ease;
}

.history-row:hover .history-actions,
.history-row:focus-within .history-actions,
.history-row.menu-open .history-actions,
.history-row.is-pinned .history-actions {
    opacity: 1;
}

.history-pin,
.history-menu-toggle {
    min-width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 0.78rem;
    text-align: center;
    text-decoration: none;
}

.history-pin:hover,
.history-pin:focus,
.history-menu-toggle:hover,
.history-menu-toggle:focus {
    background: var(--bg-soft);
    color: var(--text);
}

.history-menu {
    position: absolute;
    right: 2px;
    top: 36px;
    z-index: 20;
    display: none;
    min-width: 168px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #353535;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

.history-row.menu-open .history-menu {
    display: grid;
}

.history-menu a {
    display: block;
    border-radius: 8px;
    padding: 9px 10px;
    color: #f4f4f4;
    text-decoration: none;
}

.history-menu a:hover,
.history-menu a:focus {
    background: rgba(255, 255, 255, 0.08);
}

.history-menu a.danger {
    color: #ff6969;
}

html[data-theme="light"] .history-menu {
    background: #ffffff;
}

html[data-theme="light"] .history-menu a {
    color: #151716;
}

html[data-theme="light"] .history-menu a.danger {
    color: #c82333;
}

.rename-chat-panel {
    display: grid;
    gap: 8px;
    margin: 12px 0 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
}

.rename-chat-panel label {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.rename-chat-input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 10px;
    background: var(--bg-soft);
    color: var(--text);
}

.rename-chat-actions {
    display: flex;
    gap: 8px;
}

.rename-validation {
    margin-top: 0;
}

.rename-save,
.rename-cancel {
    border: 0;
    border-radius: 999px;
    padding: 8px 12px;
}

.rename-save {
    background: var(--button);
    color: var(--button-text);
}

.rename-cancel {
    background: var(--panel-strong);
    color: var(--text);
}

.chat-shell-mode .guided-grid {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.chat-shell-mode .mode-card:has(.prompt-panel) {
    position: relative;
    overflow: visible;
    border: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.chat-shell-mode .prompt-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: end;
    min-height: 56px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 76px 8px 20px;
    background: #242424;
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.22);
}

.chat-shell-mode .prompt-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.chat-shell-mode .prompt-panel .chat-input,
.chat-shell-mode .prompt-input {
    min-height: 28px;
    max-height: 150px;
    height: 28px;
    border: 0;
    border-radius: 0;
    padding: 3px 0;
    resize: none;
    overflow-y: auto;
    background: transparent;
    color: #f5f5f5;
    line-height: 1.45;
}

.chat-shell-mode .prompt-panel .chat-input:focus,
.chat-shell-mode .prompt-input:focus {
    outline: 0;
    box-shadow: none;
}

.chat-shell-mode .prompt-panel + .send-row {
    position: absolute;
    right: 7px;
    bottom: 7px;
    margin: 0;
}

.chat-shell-mode .prompt-panel + .send-row .chat-send {
    width: 48px;
    min-width: 48px;
    height: 42px;
    border-radius: 999px;
    padding: 0;
    font-size: 0.78rem;
}

html[data-theme="light"] .chat-shell-mode .prompt-panel {
    background: #ededeb;
}

html[data-theme="light"] .chat-shell-mode .prompt-panel .chat-input,
html[data-theme="light"] .chat-shell-mode .prompt-input {
    color: #151716;
}

@media screen and (max-width: 575px) {
    .chat-rule-panel > span {
        padding-right: 0;
    }

    .chat-rule-actions {
        gap: 6px;
    }

    .chat-rule-button {
        min-height: 32px;
        padding: 6px 10px;
    }
}

/* Keep account controls available in the full-screen chat shell. */
.chat-shell-mode .app-navbar {
    position: fixed;
    top: 14px;
    right: 18px;
    left: auto;
    z-index: 1080;
    display: flex;
    width: auto;
    height: auto;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

.chat-shell-mode .app-navbar .container {
    width: auto;
    max-width: none;
    height: auto;
    margin: 0;
    padding: 0;
}

.chat-shell-mode .navbar-collapse,
.chat-shell-mode .auth-nav,
.chat-shell-mode .auth-nav > [id$="UserNav"] {
    display: flex !important;
    flex: 0 0 auto;
    align-items: center;
}

.chat-shell-mode .auth-nav {
    gap: 8px;
    margin: 0;
    padding: 0;
}

.chat-shell-mode .auth-nav .nav-item {
    display: flex;
    align-items: center;
}

.chat-shell-mode .theme-toggle,
.chat-shell-mode .user-menu-button {
    min-height: 42px;
    border: 1px solid var(--line);
    background: rgba(39, 39, 39, 0.94);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(14px);
}

.chat-shell-mode .theme-toggle:hover,
.chat-shell-mode .theme-toggle:focus,
.chat-shell-mode .user-menu-button:hover,
.chat-shell-mode .user-menu-button:focus {
    border-color: var(--muted);
    background: #343635;
    color: var(--text);
}

html[data-theme="light"] .chat-shell-mode .theme-toggle,
html[data-theme="light"] .chat-shell-mode .user-menu-button {
    background: rgba(244, 244, 241, 0.94);
}

html[data-theme="light"] .chat-shell-mode .theme-toggle:hover,
html[data-theme="light"] .chat-shell-mode .theme-toggle:focus,
html[data-theme="light"] .chat-shell-mode .user-menu-button:hover,
html[data-theme="light"] .chat-shell-mode .user-menu-button:focus {
    background: #e2e4df;
    color: #111412;
}

.chat-shell-mode .user-dropdown {
    z-index: 1090;
}

.chat-shell-mode .chat-app-main {
    padding-top: 72px;
}

@media screen and (max-width: 575px) {
    .chat-shell-mode .app-navbar {
        top: 10px;
        right: 10px;
    }

    .chat-shell-mode .theme-toggle,
    .chat-shell-mode .user-menu-button {
        min-height: 40px;
    }

    .chat-shell-mode .user-menu-name {
        display: none;
    }

    .chat-shell-mode .chat-app-main {
        padding-top: 64px;
    }
}

/* Final admin table overrides must follow the legacy admin styles. */
.admin-shell-mode .admin-table-wrap {
    margin-top: 24px;
    overflow-x: auto;
    padding: 20px;
}

.admin-shell-mode .admin-table {
    min-width: 940px;
    border-collapse: collapse;
    border-spacing: 0;
}

.admin-shell-mode .admin-table th {
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.admin-shell-mode .admin-table td {
    border-bottom: 1px solid var(--line);
}

.admin-shell-mode .admin-table tr {
    background: transparent;
}

.admin-shell-mode .admin-table tr:hover td {
    background: var(--panel-strong);
}

.admin-shell-mode .admin-table a {
    display: inline-block;
    margin-right: 6px;
    border-radius: 5px;
    padding: 6px 8px;
    background: var(--panel-strong);
    color: var(--text);
    text-decoration: none;
}

.admin-shell-mode .admin-table a:hover,
.admin-shell-mode .admin-table a:focus {
    background: var(--button);
    color: var(--button-text);
}

.admin-shell-mode .admin-table {
    min-width: 1120px;
}

.admin-shell-mode .admin-table th:nth-child(2),
.admin-shell-mode .admin-table td:nth-child(2) {
    min-width: 160px;
}

.admin-shell-mode .admin-table th:nth-child(3),
.admin-shell-mode .admin-table td:nth-child(3) {
    min-width: 290px;
}

.admin-shell-mode .admin-table th:nth-child(5),
.admin-shell-mode .admin-table td:nth-child(5),
.admin-shell-mode .admin-table th:nth-child(6),
.admin-shell-mode .admin-table td:nth-child(6) {
    min-width: 125px;
}

.admin-shell-mode .admin-table th:last-child,
.admin-shell-mode .admin-table td:last-child {
    min-width: 140px;
    white-space: nowrap;
}

.admin-shell-mode .admin-table td:last-child a {
    white-space: nowrap;
}

.admin-create-account {
    margin-top: 24px;
}

.admin-section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.admin-section-heading span {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
}

.admin-section-heading h2 {
    margin: 4px 0 0;
    font-size: 1rem;
}

.admin-section-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.admin-account-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
    align-items: end;
    gap: 12px;
    margin-top: 18px;
}

.admin-account-form label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 650;
}

.admin-form-input {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg-soft);
    color: var(--text);
}

.admin-create-button {
    min-height: 42px;
    white-space: nowrap;
}

.admin-form-feedback {
    grid-column: 1 / -1;
}

.admin-form-feedback:empty {
    display: none;
}

.admin-create-account .auth-alert {
    margin: 4px 0 0;
}

.admin-analytics-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(330px, 0.85fr);
}

.admin-topic-list {
    display: grid;
    gap: 15px;
    margin-top: 24px;
}

.admin-topic-row {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) minmax(90px, 1.2fr) 38px;
    align-items: center;
    gap: 12px;
}

.admin-topic-row > span:first-child {
    min-width: 0;
    display: grid;
}

.admin-topic-row strong {
    overflow: hidden;
    color: var(--text);
    font-size: 0.78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-topic-row small,
.admin-topic-row b {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
}

.admin-topic-row b {
    text-align: right;
}

.admin-topic-track {
    height: 7px;
    overflow: hidden;
    border-radius: 4px;
    background: var(--panel-strong);
}

.admin-topic-track > span {
    display: block;
    height: 100%;
    min-width: 3px;
    border-radius: inherit;
    background: #6daee8;
}

.admin-ranking-panel,
.admin-prompt-feed {
    margin-top: 14px;
}

.admin-ranking-list,
.admin-prompt-list {
    display: grid;
    margin-top: 14px;
}

.admin-ranking-row {
    display: grid;
    grid-template-columns: 34px minmax(170px, 1fr) 90px 160px;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.admin-ranking-row > span:nth-child(3) {
    display: grid;
    text-align: right;
}

.admin-ranking-row > span:nth-child(3) strong {
    font-size: 1rem;
}

.admin-ranking-row > span:nth-child(3) small,
.admin-ranking-row time {
    color: var(--muted);
    font-size: 0.7rem;
}

.admin-ranking-row time {
    text-align: right;
}

.admin-prompt-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 12px;
    padding: 15px 0;
    border-top: 1px solid var(--line);
}

.admin-prompt-copy {
    min-width: 0;
}

.admin-prompt-copy > header {
    display: flex;
    align-items: center;
    gap: 9px;
}

.admin-prompt-copy > header strong {
    font-size: 0.82rem;
}

.admin-prompt-copy time {
    margin-left: auto;
    color: var(--muted);
    font-size: 0.68rem;
}

.admin-mode-badge {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 7px;
    color: var(--muted);
    font-size: 0.62rem;
}

.admin-prompt-copy p {
    margin: 7px 0 4px;
    color: var(--text);
    font-size: 0.8rem;
    line-height: 1.55;
}

.admin-prompt-copy > small {
    display: block;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.68rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media screen and (max-width: 1180px) {
    .admin-account-form {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .admin-create-button {
        width: max-content;
    }

    .admin-analytics-grid {
        grid-template-columns: 1fr;
    }
}

@media screen and (max-width: 760px) {
    .admin-nav {
        grid-template-columns: repeat(5, max-content);
    }

    .admin-account-form {
        grid-template-columns: 1fr;
    }

    .admin-section-heading {
        flex-direction: column;
    }

    .admin-ranking-row {
        grid-template-columns: 34px minmax(0, 1fr) 70px;
    }

    .admin-ranking-row time {
        display: none;
    }

    .admin-prompt-copy > header {
        flex-wrap: wrap;
    }

    .admin-prompt-copy time {
        width: 100%;
        margin-left: 0;
    }
}

/* Final chat sizing overrides */
.chat-shell-mode .chat-app-main {
    gap: 12px;
}

.chat-shell-mode .chat-app-messages {
    align-content: flex-start;
    align-items: flex-start;
}

.chat-shell-mode .chat-bubble {
    flex: 0 0 auto;
    min-height: 0;
    height: auto;
}

.chat-shell-mode .chat-bot {
    padding: 14px 18px;
}

.history-pin {
    display: inline-grid;
    place-items: center;
    padding: 0;
    line-height: 0;
}

.history-pin-icon {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.history-row.is-pinned .history-pin {
    color: var(--text);
}

/* Saved trip planning workspace. */
.trip-page { width: min(1180px, calc(100% - 32px)); min-height: calc(100vh - 180px); margin: 0 auto; padding: 56px 0 72px; }
.trip-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.trip-page-header h1 { max-width: 760px; margin: 5px 0 8px; color: var(--text); font-size: clamp(2.2rem, 5vw, 4.8rem); line-height: .98; letter-spacing: 0; }
.trip-page-header p:not(.eyebrow), .trip-empty p, .feedback-section p, .actual-preview p { margin: 0; color: var(--muted); }
.trip-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; gap: 10px; margin-bottom: 12px; }
.trip-search, .trip-section .form-control { min-height: 46px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-strong); color: var(--text); }
.trip-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 26px; }
.trip-plan-card { position: relative; min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: 0 16px 38px rgba(0,0,0,.12); transition: transform 180ms ease, border-color 180ms ease, background 180ms ease; }
.trip-plan-card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.2); background: var(--panel-strong); }
html[data-theme="light"] .trip-plan-card:hover { border-color: rgba(0,0,0,.2); }
.trip-card-select { position: absolute; top: 20px; right: 20px; }
.trip-card-select input, .compare-check-list input { width: 18px; height: 18px; accent-color: #63b88a; }
.trip-card-top { display: flex; align-items: center; gap: 12px; padding-right: 38px; }
.trip-card-top time { color: var(--muted); font-size: .78rem; }
.trip-plan-card h2 { margin: 22px 0 5px; color: var(--text); font-size: 1.35rem; overflow-wrap: anywhere; }
.trip-route { margin: 0; color: var(--muted); }
.trip-status { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.trip-status.within { background: rgba(62,175,113,.16); color: #7bd7a5; }
.trip-status.over { background: rgba(226,95,82,.16); color: #ff9d93; }
html[data-theme="light"] .trip-status.within { color: #17643b; }
html[data-theme="light"] .trip-status.over { color: #9f2f27; }
.trip-card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 24px 0; }
.trip-card-stats div { min-width: 0; }
.trip-card-stats dt, .detail-list dt { color: var(--muted); font-size: .75rem; font-weight: 600; }
.trip-card-stats dd, .detail-list dd { margin: 4px 0 0; color: var(--text); font-weight: 650; overflow-wrap: anywhere; }
.trip-card-actions, .detail-header-actions, .feedback-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.trip-page .btn, .icon-action { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: 9px 16px; line-height: 1.2; }
.icon-action { min-width: 84px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); text-decoration: none; }
.icon-action:hover, .icon-action:focus { background: var(--button); color: var(--button-text); }
.icon-action.danger:hover, .icon-action.danger:focus { border-color: #d85b52; background: #d85b52; color: #fff; }
.trip-notice, .trip-empty { margin: 0 0 22px; padding: 17px 20px; border: 1px solid rgba(80,185,129,.36); border-radius: 7px; background: rgba(80,185,129,.1); color: var(--text); }
.trip-empty { padding: 46px 24px; text-align: center; border-color: var(--line); background: var(--panel); }
.trip-empty h2 { margin-top: 0; color: var(--text); }
.back-link { display: inline-block; margin-bottom: 26px; color: var(--muted); }
.back-link:hover { color: var(--text); }
.trip-summary-band, .accuracy-summary { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 1px; overflow: hidden; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--line); }
.trip-summary-band div, .accuracy-summary div { min-width: 0; padding: 20px; background: var(--panel); }
.trip-summary-band span, .accuracy-summary span { display: block; margin-bottom: 6px; color: var(--muted); font-size: .75rem; }
.trip-summary-band strong, .accuracy-summary strong { color: var(--text); overflow-wrap: anywhere; }
.trip-detail-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 18px; }
.trip-section { margin-bottom: 18px; padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.trip-section h2 { margin: 3px 0 20px; color: var(--text); font-size: 1.35rem; }
.section-heading, .actual-preview, .feedback-section { display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.cost-row { display: flex; justify-content: space-between; gap: 20px; padding: 11px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.cost-row strong { color: var(--text); white-space: nowrap; }
.cost-row.total { margin-top: 5px; border-bottom: 0; color: var(--text); font-size: 1.08rem; }
.detail-list { display: grid; gap: 16px; margin: 0; }
.detail-list div { padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.edit-plan-section summary { cursor: pointer; color: var(--text); font-size: 1.2rem; font-weight: 700; }
.edit-plan-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin: 24px 0 18px; }
.edit-plan-grid label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .82rem; font-weight: 650; }
.edit-plan-grid .guided-wide { grid-column: 1/-1; }
.feedback-button { border: 1px solid var(--line); background: var(--panel-strong); color: var(--text); }
.feedback-button:hover, .feedback-button:focus { background: var(--button); color: var(--button-text); }
.source-report { overflow: hidden; }
.saved-report-text { display: grid; gap: 6px; max-height: 520px; overflow: auto; padding-right: 10px; }
.saved-report-text h3 { margin: 18px 0 4px; color: var(--text); font-size: 1rem; }
.saved-report-text .report-item { margin: 0; padding: 5px 0 5px 18px; color: var(--muted); position: relative; }
.saved-report-text .report-item::before { content: ""; position: absolute; left: 3px; top: 13px; width: 5px; height: 5px; border-radius: 50%; background: #63b88a; }
.compare-selector { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.compare-check-list { flex: 1 1 620px; list-style: none; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin: 0; padding: 0; }
.compare-check-list li { display: flex; gap: 9px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); }
.comparison-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.comparison-table { width: 100%; min-width: 760px; border-collapse: collapse; background: var(--panel); color: var(--text); }
.comparison-table th, .comparison-table td { padding: 15px 17px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.comparison-table th { background: var(--panel-strong); }
.comparison-table .metric-cell { color: var(--muted); font-weight: 700; }
.comparison-table .compare-within { color: #69d39a; font-weight: 700; }
.comparison-table .compare-over { color: #ff8f85; font-weight: 700; }
.accuracy-summary { grid-template-columns: repeat(4,minmax(0,1fr)); }
.expense-page { max-width: 960px; }
.secondary-action {
    border: 1px solid var(--line);
    background: var(--panel-strong);
    color: var(--text);
}
.secondary-action:hover,
.secondary-action:focus {
    border-color: var(--button);
    background: var(--button);
    color: var(--button-text);
}
.side-trips-link { text-decoration: none; }
.chat-save-plan { margin-right: auto; border-radius: 999px; background: #3a3a3a; color: #f2f4f0; }
html[data-theme="light"] .chat-save-plan { background: #d9dcd6; color: #151715; }
.admin-feedback-panel { margin-bottom: 22px; }
@media (max-width:850px) { .trip-card-grid,.trip-detail-grid { grid-template-columns:1fr; } .trip-summary-band { grid-template-columns:repeat(2,minmax(0,1fr)); } .trip-summary-band div:last-child { grid-column:1/-1; } .accuracy-summary { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media (max-width:600px) { .trip-page { width:min(100% - 22px,1180px);padding-top:34px; } .trip-page-header,.section-heading,.actual-preview,.feedback-section { align-items:stretch;flex-direction:column; } .trip-page-header .btn,.detail-header-actions .btn { width:100%; } .trip-toolbar { grid-template-columns:1fr 1fr; } .trip-toolbar .trip-search { grid-column:1/-1; } .trip-card-stats,.edit-plan-grid,.compare-check-list { grid-template-columns:1fr; } .trip-summary-band,.accuracy-summary { grid-template-columns:1fr; } .trip-summary-band div:last-child { grid-column:auto; } .trip-section { padding:19px; } }

/* Structured rule editors for follow-up trip changes. */
.chat-shell-mode .chat-rule-panel {
    margin-bottom: 12px;
    min-height: 0;
}

.chat-shell-mode .chat-rule-label {
    flex: 0 0 auto;
    margin: 0 0 10px;
    padding: 0;
    line-height: 1.35;
}

.chat-shell-mode .chat-rule-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
}

.chat-shell-mode .chat-rule-button {
    min-width: 84px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    padding: 8px 14px;
    line-height: 1.2;
    text-align: center;
}

.chat-shell-mode .chat-rule-button.is-active {
    border-color: var(--button);
    background: var(--button);
    color: var(--button-text);
    transform: none;
}

.chat-rule-editors {
    width: 100%;
    min-height: 0;
}

.chat-rule-editor[hidden] {
    display: none;
}

.chat-rule-editor {
    display: grid;
    gap: 14px;
    margin-top: 14px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.2);
    animation: ruleEditorEnter 180ms ease both;
}

.chat-shell-mode .mode-card.rule-editor-open {
    display: flex;
    flex-direction: column;
    max-height: min(620px, calc(100dvh - 150px));
    overflow: hidden;
}

.chat-shell-mode .mode-card.rule-editor-open .chat-rule-panel {
    display: flex;
    min-height: 0;
    flex-direction: column;
}

.chat-shell-mode .mode-card.rule-editor-open .chat-rule-editors {
    overflow-y: auto;
    overscroll-behavior: contain;
    max-height: min(430px, calc(100dvh - 310px));
    margin-top: 12px;
    padding: 0 8px 2px 0;
    scrollbar-color: #747774 transparent;
    scrollbar-width: thin;
}

.chat-shell-mode .mode-card.rule-editor-open .chat-rule-editor {
    margin-top: 0;
    margin-bottom: 12px;
    box-shadow: none;
}

.chat-shell-mode .mode-card.rule-editor-open .chat-rule-editor:last-child {
    margin-bottom: 0;
}

.chat-rule-editor-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.chat-rule-editor-heading span,
.chat-rule-editor-heading strong {
    display: block;
    margin: 0;
    text-align: left;
}

.chat-rule-editor-heading span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.chat-rule-editor-heading strong {
    margin-top: 3px;
    color: var(--text);
    font-size: 1rem;
    line-height: 1.35;
}

.chat-rule-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: 14px;
}

.chat-rule-form.one-column {
    grid-template-columns: minmax(0, 1fr);
}

.chat-rule-form label {
    min-width: 0;
    display: grid;
    gap: 7px;
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 650;
    line-height: 1.35;
    text-align: left;
}

.chat-rule-input {
    width: 100%;
    min-height: 44px;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    background: var(--panel-strong);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.3;
}

.chat-rule-input:focus {
    outline: 2px solid color-mix(in srgb, var(--text) 38%, transparent);
    outline-offset: 1px;
    border-color: var(--muted);
}

.chat-rule-editor-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.chat-rule-batch-actions {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 14px;
    padding: 12px 0 2px;
    background: var(--panel);
}

.chat-rule-batch-actions[hidden] {
    display: none;
}

.chat-rule-cancel,
.chat-rule-apply {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    padding: 9px 15px;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
}

.chat-rule-cancel {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text);
}

.chat-rule-apply {
    border: 1px solid var(--button);
    background: var(--button);
    color: var(--button-text);
}

.chat-rule-cancel:hover,
.chat-rule-cancel:focus {
    border-color: var(--muted);
    background: var(--panel-strong);
}

.chat-rule-apply:hover,
.chat-rule-apply:focus {
    filter: brightness(0.88);
}

.chat-rule-error {
    min-height: 1.2em;
    margin: 0;
    color: #ffb3a3;
    font-size: 0.8rem;
    line-height: 1.4;
    text-align: left;
}

html[data-theme="light"] .chat-rule-error {
    color: #8a2d1f;
}

.chat-shell-mode .mode-card.rule-editor-open .prompt-panel,
.chat-shell-mode .mode-card.rule-editor-open .send-row,
.chat-shell-mode .mode-card.rule-editor-open > .chat-validation {
    display: none !important;
}

.chat-shell-mode .mode-card:has(.chat-rule-panel) .prompt-panel {
    display: none !important;
}

.chat-shell-mode .mode-card:has(.chat-rule-panel) > .send-row {
    position: static;
    right: auto;
    bottom: auto;
    justify-content: flex-end;
    margin-top: 12px;
}

.chat-shell-mode .mode-card:has(.chat-rule-panel) > .send-row .chat-send {
    display: none;
}

.chat-shell-mode .chat-bot,
.chat-shell-mode .chat-bot .chat-response {
    min-height: 0;
    height: auto;
    padding-bottom: 0;
}

.chat-shell-mode .chat-bot {
    padding-bottom: 14px;
    white-space: normal;
}

.chat-shell-mode .chat-response {
    align-content: start;
    margin-bottom: 0;
}

.chat-shell-mode .chat-response > :last-child,
.chat-shell-mode .chat-response-list:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
}

@keyframes ruleEditorEnter {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@media screen and (max-width: 720px) {
    .chat-shell-mode .chat-rule-actions {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
    }

    .chat-shell-mode .chat-rule-button {
        width: 100%;
        min-width: 0;
        padding-inline: 8px;
    }
}

@media screen and (max-width: 520px) {
    .chat-shell-mode .chat-rule-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chat-rule-editor {
        padding: 15px;
    }

    .chat-rule-form {
        grid-template-columns: 1fr;
    }

    .chat-rule-editor-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .chat-rule-batch-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .chat-rule-cancel,
    .chat-rule-apply {
        width: 100%;
    }
}
