:root {
    --bg: #f6f5f2;
    --card: #ffffff;
    --ink: #1f2420;
    --muted: #7c837c;
    --line: #e7e5e0;
    --accent: #2f6b4f;
    --accent-ink: #ffffff;
    --danger: #b3402f;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); }
.brand span { color: var(--accent); }
.nav a { margin-left: 18px; color: var(--ink); font-size: .95rem; }
.nav a.muted { color: var(--muted); }

.container { max-width: 1040px; margin: 0 auto; padding: 28px 24px 64px; }

h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mt { margin-top: 28px; }
.hidden { display: none !important; }

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

.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.card.narrow { max-width: 460px; margin: 40px auto; }

label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 14px; }
input, select, textarea {
    display: block; width: 100%; margin-top: 6px; padding: 11px 13px;
    border: 1px solid var(--line); border-radius: 10px; font: inherit; font-weight: 400;
    background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; }

.stack > * { margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.btn {
    display: inline-block; cursor: pointer; border: 1px solid transparent;
    padding: 11px 18px; border-radius: 10px; font: inherit; font-weight: 600;
    background: #eef0ee; color: var(--ink); text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: #fff; border-color: var(--line); }
.btn-danger { background: #fff; color: var(--danger); border-color: #e6cfc9; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .95rem; }
.flash-info { background: #eef3f7; color: #2c4a5e; }
.flash-success { background: #e8f3ec; color: #245c3e; }
.flash-error { background: #fbeae7; color: #8f3322; }

.tag {
    display: inline-block; background: #e8efe9; color: var(--accent);
    padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
}
.tag-soft { background: #f0eee9; color: #6b6258; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

.empty { text-align: center; color: var(--muted); padding: 48px 0; }

/* Project grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.project-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow); color: var(--ink);
}
.project-card:hover { text-decoration: none; transform: translateY(-2px); transition: transform .15s; }
.thumb { aspect-ratio: 4/3; background: #eceae5; display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-empty { font-size: 2.4rem; }
.project-card-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; }

/* Generate */
.dropzone {
    display: flex; align-items: center; justify-content: center; flex-direction: column;
    min-height: 180px; border: 2px dashed var(--line); border-radius: var(--radius);
    background: #fafaf8; cursor: pointer; text-align: center; padding: 16px; font-weight: 500; color: var(--muted);
}
.dropzone.dragover { border-color: var(--accent); background: #f1f6f2; }
.dz-preview { max-height: 260px; max-width: 100%; border-radius: 10px; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.gen-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.ba { display: grid; grid-template-columns: 1fr 1fr; }
.ba figure { margin: 0; position: relative; }
.ba img { width: 100%; height: 100%; object-fit: cover; display: block; aspect-ratio: 1/1; }
.ba figcaption {
    position: absolute; bottom: 6px; left: 6px; background: rgba(0,0,0,.6); color: #fff;
    font-size: .72rem; padding: 2px 8px; border-radius: 999px;
}
.gen-failed { display: flex; align-items: center; justify-content: center; background: #fbeae7; color: #8f3322; font-weight: 600; aspect-ratio: 1/1; }
.gen-pending { display: flex; align-items: center; justify-content: center; text-align: center; background: #eef1f6; color: #4a5568; font-weight: 600; aspect-ratio: 1/1; padding: 12px; }
.gen-pending .dots { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.gen-meta { padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px; }

@media (max-width: 560px) {
    .container { padding: 20px 16px 48px; }
    .nav a { margin-left: 12px; }
}
