:root {
    --bg: #f4f3f1;
    --card: #ffffff;
    --text: #222;
    --muted: #777;
    --border: #dcd9d4;
    --accent: #2f2f2f;
    --danger: #c0392b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

header { text-align: center; padding: 24px 16px 8px; }
header h1 { margin: 0 0 4px; font-weight: 600; letter-spacing: .02em; }
header p { margin: 0; color: var(--muted); }

.notice {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    max-width: 880px;
    margin: 16px auto 0;
    padding: 7px 9px;
    color: #5a2a00;
    background: linear-gradient(135deg, #ffe2c2 0%, #ffc58f 100%);
    border: 1px solid #f6a55a;
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(240, 130, 30, .18);
}
.notice strong { display: block; margin-bottom: 2px; }
.notice p { margin: 0; font-size: 12px; line-height: 1.45; }
.notice-icon {
    flex: none;
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: #f07c1e;
    color: #fff;
    font-weight: 700;
}
@media (max-width: 900px) { .notice { margin: 16px 16px 0; } }

.layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 32px;
    align-items: start;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.slots { display: flex; flex-direction: column; gap: 14px; }
#slots-left { align-items: flex-end; }
#slots-right { align-items: flex-start; }

.slot {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 260px;
    padding: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: border-color .15s, box-shadow .15s;
}
.pick { display: flex; align-items: center; gap: 12px; cursor: pointer; }

#desc {
    width: 100%;
    resize: none;
    min-height: 90px;
    padding: 8px 10px;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
}
#desc:focus { outline: none; border-color: var(--accent); }
#desc.invalid { border-color: var(--danger); }
.param-wide { grid-column: 1 / -1; }
.desc-meta { display: flex; justify-content: space-between; gap: 8px; }
.desc-error { font-size: 12px; color: var(--danger); }
.counter { margin-left: auto; font-size: 11px; color: var(--muted); }
.slot:hover, .slot.drag { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,.06); }

.thumb {
    width: 64px; height: 64px;
    flex: none;
    border-radius: 8px;
    background: var(--bg);
    border: 1px dashed var(--border);
    display: grid; place-items: center;
    overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: none; }
.slot.filled .thumb { border-style: solid; }
.slot.filled .thumb img { display: block; }
.slot.filled .plus { display: none; }
.plus { font-size: 28px; color: var(--muted); }

.name { font-size: 15px; }

.remove {
    align-self: flex-end;
    margin-top: -4px;
    padding: 0;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 13px;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}
.remove:hover { color: var(--danger); }
.remove[hidden] { display: none; }
.remove:disabled { color: var(--border); cursor: not-allowed; text-decoration: none; }

/* While an image is being generated the form is locked. */
body.busy .slot { opacity: .6; }
body.busy .slot, body.busy .pick { cursor: not-allowed; }
body.busy .slot:hover { border-color: var(--border); box-shadow: none; }
#desc:disabled, .params select:disabled { opacity: .6; cursor: not-allowed; }

.stage { display: flex; flex-direction: column; align-items: center; gap: 16px; }

.frame {
    position: relative;
    width: min(420px, 90vw);
    aspect-ratio: 2 / 3;
    border-radius: 16px;
    overflow: hidden;
    background: #e9e8e6;
    box-shadow: 0 6px 30px rgba(0,0,0,.08);
}
.frame img { width: 100%; height: 100%; object-fit: contain; display: block; }

.loader {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    background: rgba(255,255,255,.75);
    text-align: center; padding: 16px; color: var(--text);
}
.loader[hidden] { display: none; }
.spinner {
    width: 44px; height: 44px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.params {
    width: min(420px, 90vw);
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 6px 12px;
}
.param { display: flex; flex-direction: column; gap: 4px; }
.param-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.params select {
    font: inherit;
    font-size: 14px;
    padding: 8px 10px;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
}
.params select:focus { outline: none; border-color: var(--accent); }
.hint { grid-column: 1 / -1; font-size: 13px; color: var(--muted); min-height: 1.2em; }

.credits { margin: 0; font-size: 14px; color: var(--muted); }
.credits b { color: var(--text); }
.credits a { color: var(--text); }
.error { color: var(--danger); margin: 0; max-width: 420px; text-align: center; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
button, .button {
    font: inherit;
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
}
.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .stage { order: -1; }
    #slots-left, #slots-right { align-items: stretch; }
    .slot { width: 100%; }
}

/* Top navigation (rendered by the server on every page). */
.topnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 16px;
}
.brand { font-size: 20px; font-weight: 600; letter-spacing: .02em; color: var(--text); text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav-links > a:not(.button) { color: var(--text); text-decoration: none; }
.nav-links > a:not(.button):hover { text-decoration: underline; text-underline-offset: 3px; }
.nav-links form { margin: 0; }
.nav-credits { padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); font-size: 14px; }
.nav-links > a.nav-credits:hover { text-decoration: none; border-color: var(--accent); }
.nav-user { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.nav-logout { padding: 6px 14px; font-size: 14px; }

.page { max-width: 1000px; margin: 0 auto; padding: 16px 16px 48px; }
.page > header { padding-top: 8px; margin-bottom: 24px; }
.muted { color: var(--muted); font-size: 13px; }
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 6px 30px rgba(0,0,0,.06);
}

/* Landing */
.hero { display: grid; grid-template-columns: 1fr 280px; gap: 40px; align-items: center; padding: 24px 0 40px; }
.hero h1 { margin: 0 0 16px; font-size: 40px; line-height: 1.15; font-weight: 600; }
.hero p { margin: 0 0 24px; font-size: 17px; line-height: 1.55; color: #444; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-image { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 16px; background: #e9e8e6; box-shadow: 0 6px 30px rgba(0,0,0,.08); }
.steps h2 { font-weight: 600; }
.steps ol { margin: 0; padding-left: 22px; display: grid; gap: 10px; line-height: 1.5; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 40px; }
.features article { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.features h3 { margin: 0 0 6px; font-size: 16px; }
.features p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 14px; }

/* Login */
.auth-card, .checkout-card { max-width: 420px; margin: 40px auto 0; text-align: center; }
.auth-card h1, .checkout-card h1 { margin: 0 0 8px; font-weight: 600; }
.auth-card .error { margin: 0 auto 16px; }
.google-button { width: 100%; margin: 12px 0; font-weight: 500; }
.google-button:hover { border-color: var(--accent); }

/* Pricing */
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: stretch; }
.plan {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
}
.plan.featured { border: 2px solid var(--accent); box-shadow: 0 6px 30px rgba(0,0,0,.08); }
.plan h2 { margin: 0; font-size: 20px; font-weight: 600; }
.plan ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; flex: 1; color: #444; }
.plan .button { margin-top: 8px; }
.plan-price { margin: 0; font-size: 28px; font-weight: 600; }
.plan-price span { font-size: 14px; font-weight: 400; color: var(--muted); }

/* Checkout */
.checkout-summary { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 20px 0; text-align: left; }
.checkout-summary dt { color: var(--muted); }
.checkout-summary dd { margin: 0; word-break: break-all; }
.checkout-summary .plan-price { font-size: 18px; }

@media (max-width: 800px) {
    .hero { grid-template-columns: 1fr; }
    .hero-image { max-width: 280px; margin: 0 auto; }
    .hero h1 { font-size: 30px; }
    .features, .plans { grid-template-columns: 1fr; }
}
