:root {
    --bg: #0b0a10;
    --surface: #16141f;
    --surface-2: #1e1b2a;
    --line: #2c2740;
    --text: #e8e6f0;
    --muted: #9b95b4;
    --accent: #a855f7;
    --accent-dim: #7c3aed;
    --ok: #4ade80;
    --bad: #f87171;
}

* { box-sizing: border-box; }

/* The browser hides [hidden] with a rule weak enough for any id or class selector to beat, and
   several below do exactly that - so the login screen stayed on top of the app after signing in. */
[hidden] { display: none !important; }

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

.mark {
    font-weight: 700;
    letter-spacing: .04em;
    background: linear-gradient(90deg, #8b3fd6, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.screen { min-height: 100vh; }

/* ---------------------------------------------------------------- login */

#login {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login { width: min(380px, 100%); }
.login h1 { margin: 0 0 4px; font-size: 20px; }
.hint { color: var(--muted); margin: 0 0 20px; }
code {
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* ---------------------------------------------------------------- chrome */

header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

header .spacer { flex: 1; }
header #who { color: var(--muted); }

nav { display: flex; gap: 4px; }

nav button {
    background: transparent;
    border: 0;
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
}

nav button:hover { color: var(--text); background: var(--surface-2); }
nav button.active { color: var(--text); background: var(--surface-2); }

.tab { padding: 20px; }

.columns {
    display: grid;
    gap: 16px;
    grid-template-columns: 280px 1fr 320px;
    align-items: start;
}

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

.panel, .card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
}

.panel h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.panel h3 { margin: 20px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }

.panelHead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panelHead h2 { margin: 0; }

/* ---------------------------------------------------------------- lists */

.list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }

.list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.list li:hover { background: var(--surface-2); }
.list li.selected { background: var(--surface-2); outline: 1px solid var(--accent-dim); }
.list li .grow { flex: 1; min-width: 0; }
.list li small { color: var(--muted); display: block; }
.list li .swatch {
    width: 22px; height: 34px;
    border-radius: 3px;
    background: var(--surface-2) center/cover no-repeat;
    image-rendering: pixelated;
    flex: none;
}
.list li.inactive .grow { opacity: .5; }

/* ---------------------------------------------------------------- forms */

.form { display: flex; flex-direction: column; gap: 12px; }
.form.row { flex-direction: row; align-items: center; flex-wrap: wrap; }

label { display: block; font-size: 13px; color: var(--muted); }
label small { display: block; font-size: 11px; margin-top: 2px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }

input, select {
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
}

input:focus, select:focus { outline: none; border-color: var(--accent-dim); }
label.check input { width: auto; margin: 0; }

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

button {
    padding: 8px 14px;
    background: var(--accent-dim);
    color: #fff;
    border: 0;
    border-radius: 6px;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

button:hover { background: var(--accent); }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
button.ghost:hover { color: var(--text); background: var(--surface-2); }
button.danger { background: transparent; border: 1px solid #7f1d1d; color: var(--bad); }
button.danger:hover { background: #7f1d1d; color: #fff; }

/* ---------------------------------------------------------------- preview */

.preview { display: flex; flex-direction: column; align-items: center; gap: 12px; }

#viewer {
    background: radial-gradient(circle at 50% 35%, #241f36, var(--bg));
    border-radius: 8px;
    cursor: grab;
}

#viewer:active { cursor: grabbing; }

.previewControls { display: flex; gap: 4px; }
.previewControls button { background: var(--surface-2); color: var(--muted); }
.previewControls button.active { background: var(--accent-dim); color: #fff; }

.upload {
    width: 100%;
    text-align: center;
    padding: 12px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    cursor: pointer;
    color: var(--muted);
}

.upload:hover { border-color: var(--accent-dim); color: var(--text); }

/* ---------------------------------------------------------------- messages */

.message, .error { margin: 4px 0 0; font-size: 13px; }
.message.ok { color: var(--ok); }
.message.bad, .error { color: var(--bad); }

/* ---------------------------------------------------------------- editor */

button.wide { width: 100%; }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(5, 4, 10, .75);
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 10;
}

.modalCard {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
    width: min(1080px, 100%);
    max-height: 92vh;
    overflow-y: auto;
}

.modalHead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modalHead h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modalHead #editorSku { color: var(--accent); }

.editorBody { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.editorLeft { flex: 1 1 560px; }
.editorRight { flex: 0 0 240px; display: flex; flex-direction: column; align-items: center; gap: 8px; }

#sheet {
    width: 100%;
    /* The sheet is pixel art at eight times its size; smoothing it would be a lie about the file. */
    image-rendering: pixelated;
    background:
        repeating-conic-gradient(#211d2e 0% 25%, #191627 0% 50%) 50% / 16px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: grab;
    touch-action: none;
}

#sheet:active { cursor: grabbing; }

#editorViewer {
    background: radial-gradient(circle at 50% 35%, #241f36, var(--bg));
    border-radius: 8px;
    cursor: grab;
}

.editorTools {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.editorTools .spacer { flex: 1; }
.editorTools label { margin: 0; }
.editorTools select { width: auto; }
.editorTools .upload { width: auto; padding: 8px 14px; }

input[type="color"] {
    width: 42px;
    height: 34px;
    padding: 2px;
    margin: 0;
    cursor: pointer;
}

.gifBox { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.gifBox summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.gifBox .hint { margin: 10px 0; }
.gifBox .upload { width: auto; display: inline-block; padding: 8px 14px; }
