:root {
    --color-ink: #322e2b;
    --color-primary: #322e2b;
    --color-accent: #f8a931;
    --color-blue: #235de6;
    --color-surface: #ffffff;
    --color-muted: #5f5b58;
    --color-border: rgba(50, 46, 43, 0.16);
    --shadow-soft: 0 10px 24px rgba(50, 46, 43, 0.08);
    --font-heading: "Space Grotesk", sans-serif;
    --font-body: "Sora", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--color-ink);
    background: var(--color-surface);
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    margin: 0 0 0.6rem;
}

p {
    margin: 0 0 1rem;
    line-height: 1.6;
    color: var(--color-muted);
}

.lede {
    font-size: 1.05rem;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    color: var(--color-blue);
}

.app-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0 24px;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand-mark {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.brand-sub {
    font-size: 0.8rem;
    color: var(--color-muted);
}

.nav-links {
    display: flex;
    gap: 16px;
    font-weight: 500;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.role-switch select {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: rgba(255, 255, 255, 0.8);
    font-family: var(--font-body);
}

.btn {
    padding: 10px 18px;
    border-radius: 14px;
    border: 1px solid transparent;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(50, 46, 43, 0.18);
}

.btn-primary {
    background: var(--color-blue);
    color: var(--color-surface);
    box-shadow: 0 10px 22px rgba(35, 93, 230, 0.25);
}

.btn-outline {
    background: var(--color-surface);
    color: var(--color-blue);
    border-color: var(--color-blue);
    box-shadow: 0 6px 16px rgba(35, 93, 230, 0.12);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 6px 16px rgba(50, 46, 43, 0.12);
}

.btn:focus-visible {
    outline: 2px solid rgba(35, 93, 230, 0.5);
    outline-offset: 2px;
}

.app-content {
    flex: 1;
    animation: fadeInUp 0.6s ease;
}

.graphic-line {
    position: relative;
    width: 130px;
    height: 4px;
    border-radius: 999px;
    background: var(--color-blue);
    margin: 12px 0 18px;
    overflow: hidden;
}

.graphic-line::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    width: 30%;
    height: 100%;
    background: var(--color-accent);
}

.hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 32px;
    align-items: center;
    padding: 32px 0 16px;
}

.hero-content h1 {
    font-size: clamp(2.2rem, 4vw, 3.6rem);
    color: var(--color-primary);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.3em;
    font-size: 0.75rem;
    color: var(--color-blue);
    font-weight: 600;
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.hero-metrics {
    display: grid;
    gap: 12px;
}

.metric {
    display: block;
    font-weight: 700;
    color: var(--color-primary);
}

.metric-label {
    font-size: 0.9rem;
}

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

.panel-card {
    padding: 20px;
    border-radius: 24px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-soft);
}

.panel-card.accent {
    border-color: rgba(248, 169, 49, 0.6);
}

.panel-list {
    padding-left: 18px;
    color: var(--color-muted);
}

.tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tags span {
    background: rgba(35, 93, 230, 0.08);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
}

.grid-section {
    padding: 48px 0 24px;
}

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid article {
    padding: 18px;
    border-radius: 20px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.cta {
    margin-top: 48px;
    padding: 28px;
    border-radius: 28px;
    background: var(--color-surface);
    border: 1px solid rgba(35, 93, 230, 0.3);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.cta-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.cta p {
    color: var(--color-muted);
}

.cta .btn-outline {
    border-color: var(--color-blue);
    color: var(--color-blue);
}

.auth {
    display: flex;
    justify-content: center;
    padding: 40px 0;
}

.auth-card {
    background: var(--color-surface);
    padding: 28px;
    border-radius: 24px;
    width: min(420px, 100%);
    box-shadow: var(--shadow-soft);
}

.form {
    display: grid;
    gap: 14px;
}

.form label {
    display: grid;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--color-primary);
}

.form input,
.form textarea,
.form select {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    font-family: var(--font-body);
    background: var(--color-surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form input[type="file"] {
    padding: 8px 10px;
    width: 100%;
}

.form input:focus,
.form textarea:focus,
.form select:focus {
    border-color: rgba(35, 93, 230, 0.6);
    box-shadow: 0 0 0 3px rgba(35, 93, 230, 0.12);
    outline: none;
}

.checkbox {
    display: flex;
    gap: 10px;
    align-items: center;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

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

.toggle-track {
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: rgba(50, 46, 43, 0.15);
    position: relative;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.toggle-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 4px 10px rgba(50, 46, 43, 0.2);
    transition: transform 0.2s ease;
}

.toggle input:checked + .toggle-track {
    background: rgba(35, 93, 230, 0.9);
}

.toggle input:checked + .toggle-track::after {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--color-primary);
}

.auth-footer {
    margin-top: 16px;
    display: flex;
    gap: 8px;
    font-size: 0.9rem;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}

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

.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.section-title {
    display: grid;
    gap: 6px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.panel-title {
    margin: 0;
    font-size: 1.05rem;
}

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

.panel-sub {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(50, 46, 43, 0.12);
    background: rgba(50, 46, 43, 0.02);
}

.plan-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}

.plan-list li {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(50, 46, 43, 0.12);
    background: #fff;
}

.plan-list li strong {
    color: var(--color-primary);
}

.plan-actions {
    margin-top: 8px;
}

.truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.form-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-grid .full {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.stats {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    margin-bottom: 24px;
}

.stat-card {
    padding: 16px;
    border-radius: 18px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-muted);
}

.stat-value {
    font-size: 1.8rem;
    font-family: var(--font-heading);
    color: var(--color-primary);
}

.grid.two {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid.three {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.panel {
    padding: 20px;
    border-radius: 22px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-soft);
}

.pricing-card {
    display: grid;
    gap: 12px;
    align-content: start;
}

.pricing-card.highlight {
    border: 1px solid rgba(35, 93, 230, 0.35);
    box-shadow: 0 18px 45px rgba(35, 93, 230, 0.2);
}

.pricing-price {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    color: var(--color-primary);
    margin: 0 0 8px;
}

.chat-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 280px;
    gap: 20px;
    align-items: start;
}

.chat-test {
    display: grid;
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    margin-top: 16px;
    max-width: 100%;
}

.chat-test-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.chat-test-badge {
    background: rgba(35, 93, 230, 0.08);
    border: 1px solid rgba(35, 93, 230, 0.3);
    color: var(--color-primary);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.chat-test-panel {
    display: grid;
    gap: 18px;
    min-width: 0;
    align-self: start;
    max-width: 100%;
    overflow: hidden;
}

.chat-test-panel .panel-header {
    flex-wrap: wrap;
}

.chat-test-panel h3 {
    margin: 0;
}

.chat-test-panel .graphic-line {
    margin-bottom: 6px;
}

.chat-test-section {
    display: grid;
    gap: 12px;
    padding-top: 12px;
}

.chat-test-section + .chat-test-section {
    border-top: 1px solid rgba(50, 46, 43, 0.08);
    padding-top: 18px;
}

.chat-test-section p,
.chat-test-section span,
.chat-test-section li,
.chat-test-section strong {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.chat-test-section select {
    width: 100%;
}

.chat-test-section p,
.chat-test-section span {
    max-width: 100%;
}

.chat-test-section .form {
    gap: 10px;
}

.chat-test-status {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    background: rgba(50, 46, 43, 0.04);
    border: 1px solid rgba(50, 46, 43, 0.08);
    border-radius: 16px;
    padding: 12px;
    min-width: 0;
}

.chat-test-conversation {
    min-height: 620px;
    min-width: 0;
    align-self: start;
}

.chat-test-conversation .chat-messages {
    background: rgba(50, 46, 43, 0.02);
    border: 1px solid rgba(50, 46, 43, 0.06);
    border-radius: 16px;
    padding: 12px;
}

.chat-test-messages {
    max-height: 520px;
}

.chat-test-form,
.chat-test-upload {
    display: grid;
    gap: 10px;
}

.chat-test-window {
    gap: 16px;
}

.chat-test-actions {
    align-items: center;
}

.chat-test-actions .btn {
    min-width: 120px;
}

#voiceStatus {
    font-size: 0.85rem;
    color: var(--color-muted);
}

#voiceStart {
    background: rgba(35, 93, 230, 0.08);
    border-color: rgba(35, 93, 230, 0.3);
}

#speakLast {
    border-color: rgba(50, 46, 43, 0.2);
    color: var(--color-ink);
}

#voiceStart.is-recording {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-ink);
}

.chat-test-prompt {
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 12px;
    background: rgba(50, 46, 43, 0.03);
}

.chat-test-prompt summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 8px;
}

.prompt-block {
    display: grid;
    gap: 8px;
}

.prompt-block pre {
    white-space: pre-wrap;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 10px;
    font-size: 0.85rem;
    color: var(--color-ink);
}

.hidden {
    display: none;
}

.chat-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 16px;
    box-shadow: var(--shadow-soft);
}

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

.chat-status {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--color-muted);
}

.chat-window {
    display: grid;
    gap: 12px;
}

.chat-messages {
    display: grid;
    gap: 12px;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 6px;
}

.chat-panel .chat-messages {
    background: rgba(50, 46, 43, 0.02);
    border: 1px solid rgba(50, 46, 43, 0.08);
    border-radius: 16px;
    padding: 14px;
}

.chat-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    background: rgba(35, 93, 230, 0.06);
    border: 1px solid rgba(35, 93, 230, 0.12);
    color: var(--color-primary);
    max-width: 80%;
    box-shadow: 0 6px 14px rgba(35, 93, 230, 0.08);
    word-break: break-word;
}

.chat-bubble.user {
    margin-left: auto;
    background: rgba(35, 93, 230, 0.12);
    border-color: rgba(35, 93, 230, 0.2);
}

.chat-bubble.system {
    background: rgba(248, 169, 49, 0.12);
    border-color: rgba(248, 169, 49, 0.3);
}

.chat-input {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.chat-input textarea {
    width: 100%;
}

.chat-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.chat-sidebar,
.chat-sheet {
    display: grid;
    gap: 12px;
}

.path-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

.path-list a {
    display: block;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.path-list a:hover {
    border-color: rgba(35, 93, 230, 0.4);
    box-shadow: 0 10px 20px rgba(35, 93, 230, 0.12);
    transform: translateY(-1px);
}

.path-list a.active {
    border-color: rgba(35, 93, 230, 0.5);
    background: rgba(35, 93, 230, 0.06);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    font-size: 0.75rem;
    color: var(--color-muted);
}

.status.paused {
    color: var(--color-accent);
}

.leader-actions {
    display: grid;
    gap: 10px;
}

.inline-actions {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

@media (max-width: 1100px) {
    .chat-layout {
        grid-template-columns: 1fr;
    }

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

    .chat-test-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .chat-test-actions .btn {
        width: 100%;
    }
}

.list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

.list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(50, 46, 43, 0.1);
}

.list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.pill {
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(50, 46, 43, 0.06);
    font-size: 0.8rem;
}

.tag {
    background: var(--color-surface);
    border-radius: 16px;
    padding: 10px 16px;
    border: 1px solid var(--color-border);
}

.flash {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.flash.success {
    background: rgba(35, 93, 230, 0.1);
    color: var(--color-primary);
}

.flash.error {
    background: rgba(248, 169, 49, 0.18);
    color: var(--color-primary);
}

.path {
    display: grid;
    gap: 16px;
}

.path-card {
    padding: 20px;
    border-radius: 20px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.path-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.status {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    color: var(--color-muted);
}

.status.completed {
    color: var(--color-blue);
}

.status.blocked {
    color: var(--color-accent);
}

.alert {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(248, 169, 49, 0.18);
    color: var(--color-primary);
}

.alert.success {
    background: rgba(35, 93, 230, 0.12);
}

.meta {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.muted {
    color: var(--color-muted);
    font-size: 0.85rem;
}

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

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

@media (max-width: 900px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-actions {
        width: 100%;
        justify-content: space-between;
    }

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

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

@media (max-width: 600px) {
    .nav-links {
        flex-wrap: wrap;
    }

    .hero-actions,
    .nav-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        width: 100%;
    }
}
