:root {
  --bg: #e9ecf1; --surface: #ffffff; --sunk: #f3f5f8; --ink: #1e2433; --muted: #566074; --line: #d2d8e2; --focus: #1e2433;
  --danger: #b42318; --ok: #0f7a4f; --warn: #9a5b00;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12161f; --surface: #1a2030; --sunk: #151a26; --ink: #e8ebf2; --muted: #9ca5b8; --line: #2b3345; --focus: #e8ebf2;
    --danger: #ff8a7a; --ok: #5fd39b; --warn: #f0b75a; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 0.9375rem/1.45 "Archivo", system-ui, sans-serif; }
a { color: inherit; }
code { font-size: 0.9em; background: var(--sunk); padding: 1px 5px; border-radius: 5px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr, .field input.sr { position: absolute; left: 0; top: 0; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { margin: 0; font-size: 1.05rem; }
.brand b { font: 400 1.15rem/1 "Archivo Black", "Archivo", system-ui, sans-serif; letter-spacing: -0.02em; margin-right: 4px; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.status { color: var(--muted); font-size: 0.875rem; max-width: 46ch; }
.status[data-kind="dirty"] { color: var(--warn); font-weight: 700; }
.status[data-kind="ok"] { color: var(--ok); font-weight: 700; }
.status[data-kind="error"] { color: var(--danger); font-weight: 700; }
.status[data-kind="warn"] { color: var(--warn); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px;
  font: 700 0.875rem/1 "Archivo", system-ui, sans-serif; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 9px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.small { min-height: 28px; padding: 4px 10px; font-size: 0.8125rem; }
.danger-btn { color: var(--danger); }
.danger-btn:hover:not(:disabled) { border-color: var(--danger); }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; padding: 6px; z-index: 20;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgb(0 0 0 / 0.18);
  display: flex; flex-direction: column;
}
.menu-pop a, .menu-pop button {
  text-align: left; padding: 9px 10px; border-radius: 8px; font: inherit; color: var(--ink);
  background: none; border: 0; cursor: pointer; text-decoration: none;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--sunk); }

/* sign in */
.signin { max-width: 560px; margin: 0 auto; padding: 48px 16px; }
.signin h1 { font: 400 2rem/1.1 "Archivo Black", "Archivo", system-ui, sans-serif; letter-spacing: -0.02em; margin: 0 0 12px; }
.signin > p { margin: 0 0 24px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.error { margin: 0; color: var(--danger); font-weight: 700; }
.help { margin-top: 20px; }
.help summary { cursor: pointer; font-weight: 700; }
.help li { margin: 6px 0; }

.field { position: relative; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-weight: 700; font-size: 0.875rem; }
.field input:not([type="checkbox"]):not([type="color"]), .field select, .field textarea, #iconQ {
  width: 100%; min-height: 38px; padding: 7px 10px; font: inherit; color: var(--ink);
  background: var(--sunk); border: 1.5px solid var(--line); border-radius: 9px;
}
.field textarea { resize: vertical; }
.hint { color: var(--muted); font-size: 0.8125rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.field-check { align-self: end; min-height: 38px; }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
input[type="color"] { width: 42px; height: 38px; padding: 2px; border: 1.5px solid var(--line); border-radius: 9px; background: var(--sunk); cursor: pointer; }
.hex { max-width: 110px; font-family: inherit; }
.icon-prev { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: var(--sunk); border: 1.5px solid var(--line); }
.icon-prev svg { width: 22px; height: 22px; }
.danger { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }

/* editor */
.editor { display: grid; grid-template-columns: 250px minmax(0, 1fr) minmax(0, 1fr); gap: 16px; padding: 16px; align-items: start; }
.side { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 18px; max-height: calc(100vh - 88px); overflow: auto; padding-bottom: 8px; }
.side-group { display: flex; flex-direction: column; gap: 6px; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px; }
.side-head h2 { margin: 0; font-size: 0.8125rem; color: var(--muted); font-weight: 700; }
.side-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.side-list li { display: flex; align-items: center; gap: 4px; }
.side-item {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px 10px; text-align: left;
  font: inherit; color: var(--ink); background: transparent; border: 1.5px solid transparent; border-radius: 9px; cursor: pointer;
}
.side-item:hover { background: var(--surface); }
.side-item[aria-current="true"] { background: var(--surface); border-color: var(--ink); }
.side-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.side-sub { color: var(--muted); font-size: 0.8125rem; }
.side-sub.st-hidden, .side-sub.st-soon { padding: 1px 7px; border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); }
.dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.mv { display: flex; gap: 2px; }
.icon-btn { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 0.85rem; }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.suggest { justify-content: space-between; padding: 4px 4px 4px 10px; background: var(--surface); border: 1.5px dashed var(--line); border-radius: 9px; }

.form .card h1 { font: 400 1.4rem/1.15 "Archivo Black", "Archivo", system-ui, sans-serif; margin: 0; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.app-head { display: flex; flex-direction: column; gap: 12px; }
.tile-solo { max-width: 340px; }

.preview { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; }
.preview-head { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.preview-head h2 { margin: 0; font-size: 0.9375rem; }
.preview-head p { margin: 0; color: var(--muted); font-size: 0.8125rem; }
.preview-body { padding: 16px; }
.preview-body .tiles { grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 14px; }
.preview-body .cat { margin-bottom: 28px; }
.pv-tagline { margin: 0 0 12px; font-size: 1.05rem; }
.pv-notice { margin: 0 0 16px; padding: 8px 12px; border-left: 4px solid var(--ink); background: var(--surface); }

/* icon dialog */
.dialog { width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); }
.dialog::backdrop { background: rgb(10 14 22 / 0.5); }
.dialog-in { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 1.1rem; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; max-height: 52vh; overflow: auto; }
.icon-cell { aspect-ratio: 1; display: grid; place-items: center; border: 1.5px solid var(--line); border-radius: 10px; background: var(--sunk); color: var(--ink); cursor: pointer; }
.icon-cell:hover { border-color: var(--ink); }
.icon-cell svg { width: 24px; height: 24px; }

@media (max-width: 1100px) {
  .editor { grid-template-columns: 230px minmax(0, 1fr); }
  .preview { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 720px) {
  .editor { grid-template-columns: 1fr; padding: 12px; }
  .side { position: static; max-height: none; }
  .row2 { grid-template-columns: 1fr; }
  .top-actions { margin-left: 0; width: 100%; }
  .status { flex-basis: 100%; }
}
