@import url("https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,400..700,0..1,-50..200&family=Poppins:wght@400;500&display=swap");

:root {
    --bg: #ffffff;
    --ink: #090909;
    --text: #141414;
    --muted: #6b6b66;
    --line: #171717;
    --line-soft: rgba(9, 9, 9, 0.12);
    --surface: #ffffff;
    --surface-soft: #f6f6f3;
    --surface-dark: #090909;
    --danger: #090909;
    --radius: 6px;
    --sidebar: 276px;
    font-family: "Poppins", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Poppins", ui-sans-serif, system-ui, sans-serif;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
}

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

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.material-symbols-rounded {
    display: inline-block;
    direction: ltr;
    font-family: "Material Symbols Rounded";
    font-feature-settings: "liga";
    font-size: 20px;
    font-style: normal;
    font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 24;
    font-weight: normal;
    letter-spacing: 0;
    line-height: 1;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    -webkit-font-feature-settings: "liga";
    -webkit-font-smoothing: antialiased;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100vh;
    padding: 22px 16px;
    background: var(--ink);
    color: var(--surface);
    border-right: 1px solid var(--ink);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
}

.brand-mark {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid currentColor;
    border-radius: 50%;
    background: var(--ink);
    color: var(--surface);
    font-family: "Instrument Serif", Georgia, serif;
    font-size: 25px;
    font-style: italic;
    line-height: 1;
}

.sidebar .brand-mark {
    background: var(--surface);
    color: var(--ink);
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 14px;
    font-weight: 500;
}

.brand small,
.muted,
small {
    color: var(--muted);
}

.sidebar .brand small,
.sidebar small {
    color: rgba(255, 254, 250, 0.58);
}

.nav-list {
    display: grid;
    gap: 5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 0 11px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: rgba(255, 254, 250, 0.72);
    font-size: 13px;
    font-weight: 400;
    transition: background 180ms ease, color 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.nav-item:hover,
.nav-item.is-active {
    background: var(--surface);
    color: var(--ink);
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    font-size: 18px;
}

.nav-badge {
    display: grid;
    min-width: 20px;
    height: 20px;
    margin-left: auto;
    place-items: center;
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font-size: 11px;
    font-weight: 500;
}

.sidebar-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 8px;
    align-items: center;
    margin-top: auto;
}

.sidebar-profile {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 11px;
    border: 1px solid rgba(255, 254, 250, 0.18);
    border-radius: var(--radius);
    background: rgba(255, 254, 250, 0.06);
    transition: background 160ms ease, border-color 160ms ease;
}

.sidebar-profile:hover {
    background: rgba(255, 254, 250, 0.12);
    border-color: rgba(255, 254, 250, 0.32);
}

.sidebar-profile strong,
.sidebar-profile small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-arrow {
    color: rgba(255, 254, 250, 0.52);
    font-size: 18px;
}

.sidebar-logout {
    display: grid;
    width: 44px;
    height: 100%;
    min-height: 62px;
    place-items: center;
    border: 1px solid rgba(255, 254, 250, 0.18);
    border-radius: var(--radius);
    background: rgba(255, 254, 250, 0.06);
    color: var(--paper);
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease;
}

.sidebar-logout:hover {
    background: rgba(255, 254, 250, 0.12);
    border-color: rgba(255, 254, 250, 0.32);
}

.sidebar-logout .material-symbols-rounded {
    font-size: 20px;
}

.avatar {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    font-family: "Instrument Serif", Georgia, serif;
    font-size: 21px;
    font-weight: 400;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-large {
    width: 64px;
    height: 64px;
    font-size: 31px;
}

.main-panel {
    min-width: 0;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.topbar h1,
.hero-copy h1,
.auth-card h1,
.panel h2,
.empty-state h2,
.empty-state h3,
.template-card h3,
.project-card h3 {
    margin: 0;
    color: var(--ink);
    font-family: "Instrument Serif", Georgia, serif;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 0.94;
}

.topbar h1 {
    font-size: clamp(32px, 4vw, 54px);
}

.panel h2 {
    font-size: clamp(26px, 3vw, 38px);
}

.template-card h3,
.project-card h3,
.empty-state h3 {
    font-size: 26px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: uppercase;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    gap: 7px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 500;
    transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.button .material-symbols-rounded {
    font-size: 17px;
}

.button:hover {
    background: var(--ink);
    color: var(--surface);
}

.button-primary,
.button-danger {
    background: var(--ink);
    color: var(--surface);
}

.button-primary:hover,
.button-danger:hover {
    background: #2a2a2a;
    color: var(--surface);
}

.button-secondary {
    background: var(--surface);
    color: var(--ink);
}

.button-full {
    width: 100%;
}

.ghost-link {
    color: var(--ink);
    font-size: 12px;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 5px;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

.stat-card,
.panel,
.project-card,
.template-card,
.auth-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.stat-card {
    position: relative;
    min-height: 132px;
    padding: 17px 18px 15px;
    overflow: hidden;
}

.stat-icon {
    position: absolute;
    top: 17px;
    right: 18px;
    color: var(--ink);
    font-size: 34px;
    font-variation-settings: "FILL" 0, "wght" 300, "GRAD" 0, "opsz" 48;
    line-height: 1;
    opacity: 0.92;
}

.stat-card span,
.stat-card strong {
    display: block;
}

.stat-card > span:not(.stat-icon) {
    max-width: 210px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

.stat-card strong {
    margin-top: 22px;
    font-family: "Instrument Serif", Georgia, serif;
    font-size: 56px;
    font-weight: 400;
    line-height: 0.82;
}

.accent-green,
.accent-orange,
.accent-rose {
    border-top-color: var(--line);
}

.panel-row {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.8fr);
    gap: 14px;
}

.panel {
    padding: 18px;
}

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

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

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

tr:last-child td {
    border-bottom: 0;
}

th {
    background: var(--ink);
    color: var(--surface);
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

td strong,
td small {
    display: block;
}

.table-link {
    display: block;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover {
    background: var(--surface-soft);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font-size: 10px;
    font-weight: 500;
}

.status-ready,
.status-online,
.status-success {
    background: var(--ink);
    color: var(--surface);
}

.status-in_progress,
.status-warning,
.status-error,
.status-archived {
    background: var(--surface-soft);
    color: var(--ink);
}

.notification-list {
    display: grid;
    gap: 10px;
}

.notification-list-full {
    gap: 11px;
}

.notification-item {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.notification-item.is-unread {
    background: var(--ink);
    color: var(--surface);
}

.notification-item.is-unread p,
.notification-item.is-unread small {
    color: rgba(255, 254, 250, 0.68);
}

.notification-item strong,
.notification-item small {
    display: block;
}

.notification-item p {
    margin: 7px 0;
    color: var(--muted);
    line-height: 1.55;
}

.project-list {
    display: grid;
    gap: 12px;
}

.project-card {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(320px, 0.85fr) auto;
    gap: 15px;
    padding: 16px;
}

.project-card h3 {
    margin: 9px 0 6px;
}

.project-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.project-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.project-detail {
    display: grid;
    gap: 14px;
}

.project-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.project-hero p:not(.eyebrow) {
    margin: 8px 0 0;
    color: var(--muted);
}

.project-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.project-layout {
    display: grid;
    grid-template-columns: minmax(280px, 0.75fr) minmax(0, 1.4fr);
    gap: 14px;
}

.project-meta dl {
    grid-template-columns: 1fr;
}

.brief-box,
.brief-form {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line-soft);
}

.brief-box p:last-child {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.ai-panel,
.prompt-panel {
    display: grid;
    gap: 14px;
}

.prompt-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.prompt-toolbar p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.prompt-code {
    min-height: 520px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre;
}

.project-history {
    display: grid;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
}

.chat-thread {
    display: grid;
    gap: 10px;
    max-height: 420px;
    overflow: auto;
    padding-right: 4px;
}

.chat-message {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.chat-message strong,
.chat-message small {
    display: block;
}

.chat-message p {
    margin: 7px 0;
    color: var(--muted);
    line-height: 1.55;
}

.chat-user {
    background: var(--surface-soft);
}

.chat-assistant {
    border-color: var(--ink);
}

.chat-system {
    color: var(--muted);
}

.chat-form {
    display: grid;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
}

dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

dt {
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

dd {
    margin: 5px 0 0;
    overflow-wrap: anywhere;
    font-weight: 500;
}

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

.template-card {
    display: flex;
    flex-direction: column;
    gap: 11px;
    min-height: 340px;
    padding: 14px;
}

.template-card p {
    margin: 0;
}

.template-card p:not(.eyebrow) {
    color: var(--muted);
    line-height: 1.52;
}

.template-preview {
    display: grid;
    gap: 7px;
    min-height: 130px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        repeating-linear-gradient(135deg, rgba(9, 9, 9, 0.08) 0 1px, transparent 1px 12px),
        var(--surface-soft);
}

.template-preview span {
    display: block;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
}

.template-preview span:first-child {
    width: 48%;
}

.template-preview span:nth-child(2) {
    width: 82%;
}

.template-preview span:nth-child(3) {
    width: 62%;
}

.card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
}

.card-actions span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 400;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(330px, 0.75fr);
    gap: 14px;
}

.profile-upload {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
}

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

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

label {
    display: grid;
    gap: 6px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 500;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 10px 11px;
    outline: none;
    transition: border-color 160ms ease, background 160ms ease;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--ink);
    background: #fbfbfb;
}

.empty-state,
.notice {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.empty-state p,
.notice p {
    margin-bottom: 0;
}

.notice-warning {
    border-color: var(--line);
    background: var(--ink);
    color: var(--surface);
}

.toast-stack {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 100;
    display: grid;
    gap: 10px;
    width: min(340px, calc(100vw - 28px));
}

.toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    animation: slideIn 220ms ease both;
}

.toast-success,
.toast-error {
    border-color: var(--line);
}

.icon-button,
.modal-close,
.mobile-menu {
    display: grid;
    place-items: center;
    border: 0;
    background: transparent;
    color: var(--muted);
}

.icon-button {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.icon-button:hover,
.modal-close:hover,
.mobile-menu:hover {
    background: var(--ink);
    color: var(--surface);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(9, 9, 9, 0.58);
    animation: fadeIn 160ms ease both;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    position: relative;
    width: min(710px, 100%);
    max-height: min(780px, calc(100vh - 40px));
    overflow: auto;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    animation: riseIn 180ms ease both;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
}

.modal-header {
    margin-bottom: 14px;
    padding-right: 38px;
}

.modal-header h2 {
    margin: 0;
    font-family: "Instrument Serif", Georgia, serif;
    font-size: 36px;
    font-weight: 400;
    line-height: 0.95;
}

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

.landing-page,
.auth-page {
    min-height: 100vh;
}

.landing {
    width: min(1120px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 20px 0 42px;
}

.landing-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.landing-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 0.72fr);
    align-items: center;
    gap: 38px;
    min-height: calc(100vh - 110px);
    padding: 28px 0;
}

.hero-copy h1 {
    max-width: 820px;
    font-size: clamp(42px, 6vw, 76px);
    letter-spacing: 0;
}

.hero-copy p:not(.eyebrow) {
    max-width: 690px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.55;
}

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

.hero-preview {
    min-height: 410px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    transform: none;
}

.preview-window {
    display: flex;
    gap: 6px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.preview-window span {
    width: 10px;
    height: 10px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
}

.preview-window span:first-child {
    background: var(--ink);
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding-top: 12px;
}

.preview-grid div {
    min-height: 150px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        repeating-linear-gradient(135deg, rgba(9, 9, 9, 0.12) 0 1px, transparent 1px 10px),
        var(--surface-soft);
}

.preview-grid div:nth-child(2),
.preview-grid div:nth-child(3) {
    background: var(--ink);
}

.auth-page {
    display: grid;
    place-items: center;
    padding: 20px;
}

.auth-card {
    display: grid;
    gap: 18px;
    width: min(430px, 100%);
    padding: 22px;
}

.auth-card h1 {
    font-size: 40px;
}

.mobile-menu {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOut {
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@media (max-width: 1120px) {
    .content-grid,
    .template-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .panel-row,
    .settings-grid,
    .landing-hero {
        grid-template-columns: 1fr;
    }

    .hero-preview {
        min-height: 380px;
        transform: none;
    }
}

@media (max-width: 820px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        width: min(var(--sidebar), 84vw);
        transform: translateX(-100%);
        transition: transform 200ms ease;
    }

    .sidebar-open .sidebar {
        transform: translateX(0);
    }

    .main-panel {
        padding: 18px;
    }

    .mobile-menu {
        display: inline-grid;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar form {
        display: none;
    }

    .content-grid,
    .template-grid,
    .form-grid,
    .project-card,
    .project-layout,
    dl {
        grid-template-columns: 1fr;
    }

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

    .panel-header,
    .modal-actions,
    .card-actions,
    .prompt-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .landing {
        width: min(100vw - 24px, 1220px);
    }

    .landing-nav {
        align-items: flex-start;
    }

    .hero-copy h1 {
        font-size: 52px;
    }

    .hero-preview {
        display: none;
    }
}
