:root {
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #f7f8fb;
    --panel: #ffffff;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #f97316;
    --danger: #dc2626;
    --ok: #0f9f6e;
    --shadow: 0 18px 50px rgba(31, 41, 55, .10);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4vw, 4.3rem); line-height: 1; letter-spacing: 0; }
h2 { font-size: 1.3rem; }
label { display: grid; gap: .45rem; font-weight: 700; font-size: .92rem; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .78rem .85rem;
    font: inherit;
    background: #fff;
}
textarea { resize: vertical; min-height: 96px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem clamp(1rem, 4vw, 3rem);
    background: rgba(255,255,255,.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}
.brand, .nav { display: flex; align-items: center; gap: .85rem; }
.brand { color: var(--ink); font-weight: 900; font-size: 1.1rem; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--accent));
}
.nav { flex-wrap: wrap; justify-content: flex-end; }
.nav a { color: var(--ink); font-weight: 700; }
.nav-user { color: var(--muted); font-size: .9rem; }
.page { padding: clamp(1rem, 4vw, 3rem); }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    padding: .75rem 1.1rem;
    color: #fff;
    background: var(--primary);
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(37, 99, 235, .18);
}
.button:hover { background: var(--primary-dark); color: #fff; }
.button.ghost {
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: none;
}
.button.small { min-height: 34px; padding: .45rem .7rem; font-size: .86rem; }
.button.large { min-height: 52px; padding-inline: 1.35rem; }
.button.danger { background: var(--danger); }
.button.danger:hover { background: #b91c1c; }

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(300px, .75fr);
    gap: clamp(2rem, 6vw, 5rem);
    align-items: center;
    min-height: calc(100vh - 150px);
}
.hero-copy p { max-width: 680px; color: var(--muted); font-size: 1.1rem; line-height: 1.7; }
.eyebrow { color: var(--accent); font-weight: 900; text-transform: uppercase; font-size: .78rem; letter-spacing: .08em; }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.actions.vertical { display: grid; }
.hero-preview {
    display: grid;
    place-items: center;
    min-height: 540px;
}
.invite-sample {
    width: min(360px, 100%);
    aspect-ratio: 4 / 5;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 2rem;
    border-radius: 8px;
    color: #5a351d;
    background:
        radial-gradient(circle at 18% 20%, #fff 0 7%, transparent 8%),
        radial-gradient(circle at 84% 76%, #ffd166 0 9%, transparent 10%),
        linear-gradient(145deg, #ffe7b6, #9ccf86);
    box-shadow: var(--shadow);
}
.invite-sample strong { font: 900 4.8rem Georgia, serif; }
.invite-sample em { color: white; background: #8b4513; border-radius: 8px; padding: .5rem 1.2rem; font-style: normal; font-weight: 900; }
.feature-grid, .stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}
.feature-grid article, .stats article {
    display: grid;
    gap: .35rem;
    padding: 1.2rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.feature-grid span, .stats span, .muted { color: var(--muted); }
.stats strong { font-size: 2rem; }

.auth-card, .panel {
    width: min(100%, 520px);
    margin: 0 auto;
    padding: 1.35rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}
.panel { width: 100%; margin: 0; box-shadow: none; }
.stack { display: grid; gap: 1rem; }
.alert { padding: .85rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: #eff6ff; border: 1px solid #bfdbfe; }
.alert.error { background: #fef2f2; border-color: #fecaca; }
.alert.success { background: #ecfdf5; border-color: #a7f3d0; }
.dashboard-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.2rem;
}
.dashboard-head h1 { font-size: clamp(2rem, 3vw, 3rem); margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: minmax(340px, .9fr) minmax(340px, 1.1fr); align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.project-list { display: grid; gap: .75rem; }
.project-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: .75rem;
    padding: .9rem;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.project-card strong, .project-card span { display: block; }
.project-card span { margin-top: .25rem; color: var(--muted); font-size: .9rem; }
.row-actions, .row-actions form { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.ai-box {
    padding: .9rem;
    border-radius: 8px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
}

.editor-shell {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 1rem;
    min-height: calc(100vh - 130px);
}
.editor-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.editor-panel h1 { font-size: 1.35rem; line-height: 1.2; margin-bottom: 0; }
.tool-block {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .55rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}
.tool-block label { grid-column: 1 / -1; }
.canvas-wrap {
    display: grid;
    place-items: center;
    overflow: auto;
    min-height: 70vh;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #e5e7eb;
}
#artCanvas {
    max-width: 100%;
    max-height: calc(100vh - 170px);
    background: white;
    box-shadow: 0 18px 45px rgba(0,0,0,.18);
}
.animated-art canvas { animation: floatArt 2.8s ease-in-out infinite; }
.animated-preview { display: grid; gap: .35rem; font-size: .9rem; }
@keyframes floatArt {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.table-wrap { overflow: auto; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chips span {
    display: inline-flex;
    padding: .45rem .7rem;
    border-radius: 999px;
    background: #f3f4f6;
    border: 1px solid var(--line);
    font-size: .88rem;
}

@media (max-width: 980px) {
    .hero, .grid.two, .editor-shell { grid-template-columns: 1fr; }
    .feature-grid, .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .editor-panel { order: 2; }
}
@media (max-width: 640px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .form-grid, .feature-grid, .stats { grid-template-columns: 1fr; }
    .project-card { grid-template-columns: 1fr; }
    .row-actions, .row-actions form { justify-content: flex-start; }
    .hero-preview { min-height: 380px; }
    .invite-sample strong { font-size: 3.4rem; }
}
