:root {
    --bg: #f4efe5;
    --surface: #fffdf8;
    --surface-alt: #f7f1e7;
    --text: #14213d;
    --muted: #59667d;
    --accent: #ff6b35;
    --accent-dark: #cf4d1d;
    --success: #1f9363;
    --error: #b52f2f;
    --warning: #b9851b;
    --border: #e3d9ca;
    --shadow: 0 18px 40px rgba(20, 33, 61, 0.09);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 107, 53, 0.12), transparent 28%),
        linear-gradient(180deg, #f7f0e6 0%, #f3ecdf 100%);
}

a {
    color: inherit;
}

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    padding: 0.9rem 1.1rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

button:hover,
.button-link:hover {
    background: var(--accent-dark);
}

.secondary-link {
    background: #223d66;
}

.secondary-link:hover {
    background: #162b4c;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    background: #fff;
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
}

label span {
    display: block;
    margin-bottom: 0.45rem;
    font-weight: 700;
}

.shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1rem 0 3rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0 1.5rem;
}

.brand {
    font-size: 1.2rem;
    font-weight: 900;
    text-decoration: none;
    letter-spacing: 0.02em;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-user {
    color: var(--muted);
    font-weight: 700;
}

.inline-form {
    margin: 0;
}

.ghost-button {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.content {
    display: grid;
    gap: 1.25rem;
}

.hidden {
    display: none !important;
}

.hero-panel,
.card,
.auth-card {
    background: rgba(255, 253, 248, 0.95);
    border: 1px solid rgba(227, 217, 202, 0.8);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.hero-panel {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 1rem;
    padding: 1.5rem;
}

.hero-panel h1,
.auth-card h1 {
    margin-top: 0;
    margin-bottom: 0.75rem;
}

.hero-copy,
.muted,
.auth-card p,
.empty-state {
    color: var(--muted);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.78rem;
    color: var(--accent);
    font-weight: 800;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.85rem;
}

.stat-card {
    background: var(--surface-alt);
    border-radius: 18px;
    padding: 1rem;
    display: grid;
    gap: 0.3rem;
}

.stat-card strong {
    font-size: 2rem;
}

.panel-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.95fr;
    gap: 1.25rem;
}

.card,
.auth-card {
    padding: 1.5rem;
}

.stack {
    display: grid;
    gap: 1rem;
}

.brief-chat {
    display: grid;
    gap: 1rem;
}

.brief-analysis {
    background: #fff7e9;
    border: 1px solid #f0d9a7;
    border-radius: 16px;
    padding: 0.9rem 1rem;
    color: #6c5723;
    line-height: 1.5;
}

.brief-messages {
    display: grid;
    gap: 0.75rem;
    max-height: 430px;
    overflow-y: auto;
    padding-right: 0.35rem;
}

.brief-bubble {
    max-width: 90%;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    white-space: pre-wrap;
    line-height: 1.5;
}

.brief-bubble-assistant {
    background: #fff4ec;
    border: 1px solid #f2cbb8;
    justify-self: start;
}

.brief-bubble-user {
    background: #223d66;
    color: #fff;
    justify-self: end;
}

.brief-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.brief-option {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    padding: 0.7rem 0.95rem;
    border-radius: 999px;
}

.brief-option:hover {
    background: var(--surface-alt);
}

.brief-input {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.8rem;
}

.brief-summary {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1rem;
}

.brief-summary pre {
    margin: 0 0 1rem;
    white-space: pre-wrap;
    font-family: inherit;
    color: var(--muted);
}

.brief-thinking {
    position: sticky;
    top: 0;
    z-index: 5;
}

.brief-thinking-card {
    display: grid;
    gap: 0.65rem;
    background: rgba(20, 33, 61, 0.96);
    color: #fff;
    border-radius: 18px;
    padding: 1rem;
    box-shadow: 0 18px 36px rgba(20, 33, 61, 0.25);
}

.brief-thinking-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.brief-thinking-note {
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.92rem;
}

.brief-thinking-stream {
    min-height: 48px;
    max-height: 140px;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.5;
    color: #fff0d8;
    padding: 0.75rem 0.85rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.flow-list {
    margin: 0;
    padding-left: 1.2rem;
    display: grid;
    gap: 0.8rem;
}

.section-head,
.project-head,
.project-meta,
.project-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.project-list {
    display: grid;
    gap: 1rem;
}

.project-card {
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-alt);
    display: grid;
    gap: 1rem;
}

.project-card h3 {
    margin: 0 0 0.35rem;
}

.project-meta {
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.92rem;
}

.job-progress {
    display: grid;
    gap: 0.55rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0.9rem 1rem;
}

.job-progress-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.job-progress-bar {
    height: 10px;
    border-radius: 999px;
    background: #e7dece;
    overflow: hidden;
}

.job-progress-bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #ff6b35, #f3a64e);
    transition: width 1s linear;
}

.job-progress-detail {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.job-events {
    display: grid;
    gap: 0.7rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0.95rem 1rem;
}

.job-events-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.job-events-list {
    display: grid;
    gap: 0.65rem;
    max-height: 240px;
    overflow-y: auto;
}

.job-event {
    border-left: 4px solid var(--border);
    background: var(--surface-alt);
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
}

.job-event-info {
    border-left-color: #4b77b6;
}

.job-event-success {
    border-left-color: var(--success);
}

.job-event-warning {
    border-left-color: var(--warning);
}

.job-event-error {
    border-left-color: var(--error);
}

.job-event-title {
    font-weight: 800;
    margin-bottom: 0.2rem;
}

.job-event-detail,
.job-event-meta {
    color: var(--muted);
    font-size: 0.92rem;
}

.tweak-chat {
    display: grid;
    gap: 0.85rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1rem;
}

.tweak-chat h4 {
    margin: 0 0 0.25rem;
}

.tweak-apply {
    display: grid;
    gap: 0.65rem;
    background: #fff7e9;
    border: 1px solid #f0d9a7;
    border-radius: 16px;
    padding: 0.9rem 1rem;
}

.tweak-apply p {
    margin: 0;
    color: #6c5723;
    line-height: 1.5;
}

.badge {
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.badge-ready,
.badge-published {
    background: rgba(31, 147, 99, 0.12);
    color: var(--success);
}

.badge-queued,
.badge-generating,
.badge-publishing {
    background: rgba(185, 133, 27, 0.16);
    color: var(--warning);
}

.badge-error {
    background: rgba(181, 47, 47, 0.12);
    color: var(--error);
}

.secondary {
    background: #223d66;
}

.flash {
    margin-bottom: 1rem;
    padding: 1rem 1.2rem;
    border-radius: 16px;
    font-weight: 700;
}

.flash-success {
    background: rgba(31, 147, 99, 0.12);
    color: var(--success);
}

.flash-error {
    background: rgba(181, 47, 47, 0.12);
    color: var(--error);
}

.auth-card {
    width: min(520px, 100%);
    margin: 4rem auto 0;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
}

.error-text {
    color: var(--error);
    margin: 0;
}

@media (max-width: 920px) {
    .hero-panel,
    .panel-grid {
        grid-template-columns: 1fr;
    }

    .topbar,
    .section-head,
    .project-head,
    .project-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .topnav {
        flex-wrap: wrap;
    }

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