:root {
    --bg: #f7f8fa;
    --panel: #ffffff;
    --line: #dfe1e6;
    --muted: #5e6c84;
    --text: #172b4d;
    --blue: #0052cc;
    --blue-soft: #deebff;
    --green: #36b37e;
    --yellow: #ffab00;
    --purple: #6554c0;
    --cyan: #00b8d9;
    --red: #de350b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 0;
}

a {
    color: var(--blue);
    text-decoration: none;
}

button,
.button {
    min-height: 38px;
    border: 0;
    border-radius: 6px;
    background: var(--blue);
    color: #fff;
    padding: 0 14px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

button.secondary,
.button.secondary {
    background: #ebecf0;
    color: var(--text);
}

button.danger {
    background: var(--red);
    color: #fff;
}

button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

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

input,
select {
    height: 38px;
    padding: 0 10px;
}

textarea {
    min-height: 170px;
    resize: vertical;
    padding: 14px;
    line-height: 1.5;
}

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
}

.sidebar {
    border-right: 1px solid var(--line);
    background: #fafbfc;
    padding: 26px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
}

.project-lockup {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.sidebar #newSessionBtn,
.sidebar #sessionManagementBtn {
    width: 100%;
}

.sidebar #newSessionBtn {
    margin-bottom: 10px;
}

.sidebar #sessionManagementBtn {
    margin-bottom: 24px;
    justify-content: flex-start;
    border: 1px solid var(--line);
    background: #ebecf0;
    color: var(--text);
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--cyan), var(--blue));
    color: #fff;
    font-weight: 800;
}

.project-lockup span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-top: 3px;
}

.session-list h2 {
    font-size: 13px;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 10px;
}

.session-item {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-weight: 600;
    margin-bottom: 10px;
}

.session-item.active {
    border-color: var(--blue);
    background: #fff;
    box-shadow: 0 0 0 2px var(--blue-soft);
}

.main {
    min-width: 0;
    padding: 32px 48px 80px;
}

.topbar {
    min-height: 88px;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
}

.breadcrumb {
    color: var(--muted);
    font-size: 14px;
}

h1 {
    font-size: 30px;
    margin: 8px 0 0;
}

h2 {
    margin: 0;
}

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

.credit-pill {
    height: 38px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 999px;
    padding: 0 14px;
    white-space: nowrap;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    min-width: 38px;
    padding: 0;
    border-radius: 6px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    font-size: 15px;
}

.menu {
    position: relative;
}

.menu summary {
    list-style: none;
}

.menu-panel {
    position: absolute;
    right: 0;
    top: 46px;
    min-width: 220px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(9, 30, 66, .16);
    z-index: 10;
    display: grid;
    gap: 8px;
}

.menu-panel a {
    background: transparent;
    color: var(--text);
    justify-content: flex-start;
    font-size: 15px;
    font-weight: 600;
    padding: 8px 10px;
}

.progress-row {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 10px;
    background: rgba(247, 248, 250, .94);
    backdrop-filter: blur(8px);
    padding: 12px 0 18px;
}

.step {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--text);
    justify-content: flex-start;
    min-height: 50px;
}

.step span {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #ebecf0;
}

.step.active {
    border-color: var(--blue);
    color: var(--blue);
}

.step.active span,
.step.complete span {
    background: var(--blue);
    color: #fff;
}

.workspace-section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 22px;
    padding: 24px;
}

.workspace-section.compact {
    max-width: 760px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.section-heading span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 4px;
}

.section-heading select {
    max-width: 220px;
}

.llm-controls {
    display: grid;
    grid-template-columns: minmax(150px, 180px) minmax(190px, 260px);
    gap: 10px;
}

.llm-controls select {
    max-width: none;
}

#hfProviderNotice {
    margin: -6px 0 16px;
}

.form-row,
.action-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
}

.file-button {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.file-button input {
    display: none;
}

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

.concept-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    display: grid;
    grid-template-rows: auto 1fr;
}

.concept-card.selected {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px var(--blue-soft);
}

.concept-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: block;
    object-fit: cover;
    background: #f4f5f7;
}

.image-pending {
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
    gap: 8px;
    color: var(--muted);
    background: #f4f5f7;
}

.concept-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.concept-body h3 {
    margin: 0 0 8px;
}

.concept-body p {
    color: var(--muted);
    line-height: 1.45;
}

.concept-body button[data-select] {
    margin-top: auto;
    align-self: flex-start;
}

.refinement-workspace {
    display: grid;
    grid-template-columns: minmax(320px, 420px) minmax(420px, 1fr);
    gap: 22px;
    align-items: start;
}

.selected-concept-panel.empty-state {
    min-height: 320px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #fafbfc;
}

.refinement-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: #fafbfc;
    display: grid;
    gap: 14px;
}

.refinement-panel label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.refinement-panel textarea {
    min-height: 150px;
    font: inherit;
    line-height: 1.5;
}

.refinement-actions {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.version-selector {
    width: 130px;
}

.refinement-status {
    min-width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    display: inline-grid;
    place-items: center;
    font-weight: 800;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0;
}

.tag-list span {
    border-radius: 999px;
    background: #ebecf0;
    padding: 4px 8px;
    font-size: 12px;
}

.empty-state {
    color: var(--muted);
    display: block;
}

.notice {
    border-radius: 6px;
    padding: 12px 14px;
}

.notice.error {
    color: #5f1f12;
    background: #ffebe6;
}

.notice.warning {
    color: #4f3a00;
    background: #fffae6;
    border: 1px solid #ffe380;
}

.notice.success {
    color: #064;
    background: #e3fcef;
}

.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(9, 30, 66, .42);
}

.modal-panel {
    width: min(440px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 22px;
    box-shadow: 0 18px 48px rgba(9, 30, 66, .24);
}

.modal-panel h2 {
    margin-bottom: 15px;
}

.modal-panel p {
    color: var(--muted);
    margin: 0 0 20px;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 30px;
}

.login-card {
    width: min(440px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 30px;
}

.login-card form,
.admin-form {
    display: grid;
    gap: 14px;
}

.login-card button {
    justify-content: center;
}

.login-card label,
.admin-form label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.admin-page {
    background: #fff;
}

.admin-shell {
    width: min(1180px, calc(100% - 48px));
    margin: 32px auto;
}

.admin-shell section:not(:first-child) {
    margin-top: 32px;
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.section-actions {
    margin-top: 18px;
    margin-bottom: 16px;
}

.section-actions .button {
    display: inline-flex;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
}

.inline-form {
    display: flex;
    gap: 8px;
}

.inline-form input {
    max-width: 120px;
}

@media (max-width: 1100px) {
    .app {
        grid-template-columns: 240px minmax(0, 1fr);
    }

    .main {
        padding: 26px;
    }

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

    .refinement-workspace {
        grid-template-columns: 1fr;
    }

    .llm-controls {
        grid-template-columns: 1fr;
        width: 100%;
    }
}
