:root {
  --bg: #f4f2ee;
  --card: #ffffff;
  --ink: #1d2320;
  --muted: #5f6964;
  --line: #dedad2;
  --accent: #0f5c4d;
  --accent-ink: #ffffff;
  --soft: #e7f0ed;
  --stage: #e9e6df;
  --ok: #1e7a4f;
  --warn: #a35a00;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121615;
    --card: #1b2120;
    --ink: #e9eeec;
    --muted: #9aa6a1;
    --line: #2d3533;
    --accent: #3fb59a;
    --accent-ink: #08201a;
    --soft: #1f302b;
    --stage: #0d1110;
    --ok: #4cc78b;
    --warn: #f0a648;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121615; --card: #1b2120; --ink: #e9eeec; --muted: #9aa6a1; --line: #2d3533;
  --accent: #3fb59a; --accent-ink: #08201a; --soft: #1f302b; --stage: #0d1110;
  --ok: #4cc78b; --warn: #f0a648; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; display: flex; align-items: center; gap: .55rem; margin-bottom: .9rem; }
.n {
  display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: .85rem; font-weight: 700;
}

.top, main, .foot { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: 18px; padding-bottom: 6px; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--ink); }
.brand svg { width: 34px; height: 34px; flex: none; }
.privacy {
  display: flex; align-items: center; gap: .5rem; margin: .6rem 0 0; font-size: .9rem; color: var(--muted);
}
.privacy .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.privacy.offline .dot { background: var(--accent); }

main { display: grid; gap: 14px; padding-top: 12px; padding-bottom: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; min-width: 0;
}
.hint { font-size: .85rem; color: var(--muted); margin: .7rem 0 0; }
.hint.strong { color: var(--ink); margin-top: 0; }
.status { min-height: 1.3em; font-size: .9rem; margin: .6rem 0 0; color: var(--ok); }
.status.err { color: var(--warn); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer;
  user-select: none; -webkit-user-select: none; white-space: nowrap;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .88rem; }
.btn.icon { width: 42px; padding: 0; font-size: 1.15rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.slot { display: grid; gap: 8px; min-width: 0; }
.thumb {
  aspect-ratio: 1.586; border: 1.5px dashed var(--line); border-radius: 10px; background: var(--stage);
  display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: .9rem;
}
.thumb.has { border-style: solid; }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.slot-actions { display: grid; grid-template-columns: minmax(0, 1fr) 40px 40px; gap: 6px; }
.slot-actions .btn { min-width: 0; padding: 0 8px; }
.slot-actions .btn:first-child { grid-column: 1 / -1; }
.slot-actions .btn.icon { width: 40px; }
.slot.drag .thumb { border-color: var(--accent); background: var(--soft); }

.editor { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .editor { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .slots { grid-template-columns: 1fr 1fr; max-width: 720px; }
}
.tabs, .modes, .seg { display: flex; gap: 4px; background: var(--stage); border-radius: 10px; padding: 4px; }
.tabs { margin-bottom: 8px; }
.tabs button, .modes button, .seg button {
  flex: 1; min-height: 36px; border: 0; border-radius: 7px; background: transparent; color: var(--muted);
  font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer;
}
.tabs button[aria-selected="true"], .modes button[aria-pressed="true"], .seg button[aria-pressed="true"] {
  background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12);
}
.modes { margin-top: 8px; }
.stage {
  position: relative; background: var(--stage); border-radius: 10px; min-height: 220px;
  display: grid; place-items: center; overflow: hidden;
  background-image: linear-gradient(45deg, color-mix(in srgb, var(--line) 50%, transparent) 25%, transparent 25%, transparent 75%, color-mix(in srgb, var(--line) 50%, transparent) 75%),
                    linear-gradient(45deg, color-mix(in srgb, var(--line) 50%, transparent) 25%, transparent 25%, transparent 75%, color-mix(in srgb, var(--line) 50%, transparent) 75%);
  background-size: 20px 20px; background-position: 0 0, 10px 10px;
}
#preview { display: block; max-width: 100%; max-height: 70vh; touch-action: none; cursor: grab; }
#preview.mask { cursor: crosshair; }
#preview[hidden] { display: none; }
.empty { color: var(--muted); padding: 2rem 1rem; text-align: center; font-size: .95rem; }

.panel { display: grid; gap: 12px; min-width: 0; }
.group { display: grid; gap: 12px; min-width: 0; grid-template-columns: minmax(0, 1fr); }
.group > *, .field, .range { min-width: 0; }
input, select, textarea { max-width: 100%; min-width: 0; }
.group[hidden] { display: none; }
.field { display: grid; gap: 4px; font-size: .88rem; color: var(--muted); min-width: 0; }
textarea, select, input[type="date"] {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; min-height: 40px;
}
textarea { resize: vertical; font-weight: 600; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row > select { flex: 1 1 140px; width: auto; }
.row > input[type="date"] { flex: 1 1 140px; width: auto; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.colors { display: flex; align-items: center; gap: 6px; }
input[type="color"] { width: 40px; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--bg); }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: var(--c); cursor: pointer; padding: 0; flex: none; }
.range { display: grid; gap: 2px; font-size: .88rem; color: var(--muted); }
.range span { display: flex; justify-content: space-between; }
.range output { color: var(--ink); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }
.tips { font-size: .88rem; border-top: 1px solid var(--line); padding-top: 10px; }
.tips summary { cursor: pointer; font-weight: 600; }
.tips ul { margin: .5rem 0 0; padding-left: 1.1rem; color: var(--muted); }
.tips li { margin-bottom: .35rem; }

.out { display: flex; flex-wrap: wrap; gap: 8px; }
.out .btn { flex: 1 1 200px; }
.foot { color: var(--muted); font-size: .82rem; padding-bottom: 28px; }
