/* ── Playground Space — soft pastel theme ───────────────────────── */
:root {
  color-scheme: light;

  /* light green carries the room; the other pastels are accents */
  --bg: #f3faf5;
  --bg-2: #e7f4ec;
  --card: #ffffff;
  --line: #dcefe4;
  --line-2: #bfe2ce;
  --ink: #2f443c;
  --ink-2: #5d7269;
  --ink-3: #8ba096;
  --green: #6dbf96;
  --green-hi: #5bb188;
  --green-deep: #2e7b5b;
  --green-soft: #e4f4ea;
  --peach: #ffe3d5;
  --butter: #fff1d6;
  --sky: #dceefb;
  --lilac: #ebe3fa;
  --rose: #ffe4ec;
  --danger: #c4564a;
  --danger-soft: #ffecea;
  --danger-line: #f4c2bc;

  --r-lg: 20px;
  --r-md: 14px;
  --pill: 999px;
  --sh-1: 0 1px 2px rgba(47, 90, 70, .05), 0 4px 12px rgba(47, 90, 70, .06);
  --sh-2: 0 2px 6px rgba(47, 90, 70, .08), 0 14px 28px rgba(47, 90, 70, .10);
  --font: 'Quicksand', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  font-family: var(--font);
  font-weight: 500;
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 50% -14%, #ffffff 0%, rgba(255, 255, 255, 0) 62%),
    radial-gradient(760px 460px at 105% 8%, var(--sky) 0%, rgba(255, 255, 255, 0) 60%),
    radial-gradient(680px 420px at -8% 22%, var(--butter) 0%, rgba(255, 255, 255, 0) 58%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
}

.pix { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }

/* ── top bar ───────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 4;
  display: flex; align-items: center; gap: 10px; flex-wrap: nowrap;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: rgba(255, 255, 255, .78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.brand-icon { width: 48px; height: 48px; flex: none; }
.brand-text { min-width: 0; }
.brand h1 {
  margin: 0; font-size: 19px; font-weight: 700; letter-spacing: .2px;
  color: var(--green-deep);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand p { margin: 3px 0 0; font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.topbar-actions { display: flex; gap: 8px; flex: none; }

/* ── buttons ───────────────────────────────────────────────────── */
.btn {
  font-family: var(--font); font-size: 13.5px; font-weight: 700;
  color: var(--ink); background: #fff;
  border: 1px solid var(--line-2); border-radius: var(--pill);
  padding: 9px 16px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(47, 90, 70, .05);
  transition: background .16s, border-color .16s, transform .1s, box-shadow .16s, color .16s;
}
.btn:hover { background: var(--green-soft); border-color: var(--green); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--green-soft); border-color: var(--line-2); color: var(--ink); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-hi); border-color: var(--green-hi); }
.btn-danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.btn-danger:hover { background: #ffe1de; border-color: var(--danger); }
.btn[aria-pressed="true"] {
  background: var(--green-soft); border-color: var(--green); color: var(--green-deep);
}

/* ── search ────────────────────────────────────────────────────── */
.searchwrap { padding: 18px 18px 0; max-width: 1120px; margin: 0 auto; }
#search {
  width: 100%; font-family: var(--font); font-size: 15px; font-weight: 500; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--pill);
  padding: 12px 18px; box-shadow: var(--sh-1);
}
#search::placeholder { color: var(--ink-3); font-weight: 500; }
#search:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }

/* ── grid ──────────────────────────────────────────────────────── */
main { padding: 18px; max-width: 1120px; margin: 0 auto; }
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
@media (max-width: 430px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 13px; }
  .topbar { padding-left: 14px; padding-right: 14px; gap: 8px; }
  .brand { gap: 10px; }
  .brand-icon { width: 40px; height: 40px; }
  .brand h1 { font-size: 16px; }
  .brand p { display: none; }
  .btn { padding: 8px 12px; font-size: 12.5px; }
  .searchwrap, main { padding-left: 14px; padding-right: 14px; }
}

.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 11px;
  padding: 20px 12px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  color: inherit; text-decoration: none; text-align: center;
  cursor: pointer; font: inherit;
  transition: transform .16s cubic-bezier(.22, .9, .3, 1), box-shadow .16s, border-color .16s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--sh-2); border-color: var(--line-2); }
.tile:active { transform: translateY(0); box-shadow: var(--sh-1); }
.tile:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
.tile img { width: 72px; height: 72px; }
.tile .name { font-size: 13.5px; font-weight: 700; line-height: 1.35; word-break: break-word; }
.tile .sub { font-size: 11.5px; font-weight: 500; color: var(--ink-3); line-height: 1.4; }

.tile-add {
  background: rgba(255, 255, 255, .55);
  border: 1.5px dashed var(--line-2);
  box-shadow: none;
}
.tile-add:hover { background: #fff; border-color: var(--green); }
.tile-add .plus {
  display: grid; place-items: center;
  width: 72px; height: 72px; border-radius: var(--r-md);
  background: var(--green-soft); color: var(--green-deep);
  font-size: 32px; font-weight: 700; line-height: 1;
}

/* edit-mode controls */
.tile .edit-bar { display: none; gap: 6px; }
body.editing .tile .edit-bar { display: flex; }
body.editing .tile { border-color: var(--line-2); border-style: dashed; }
.mini {
  font-family: var(--font); font-size: 12px; font-weight: 700; line-height: 1;
  color: var(--ink-2); background: var(--green-soft);
  border: 1px solid transparent; border-radius: var(--pill);
  padding: 7px 10px; cursor: pointer; transition: background .14s, border-color .14s;
}
.mini:hover { background: #fff; border-color: var(--green); color: var(--green-deep); }

.empty, .hint {
  margin: 22px 4px 0; font-size: 12.5px; font-weight: 500;
  color: var(--ink-3); line-height: 1.75;
}
.hint b { color: var(--green-deep); font-weight: 700; }

.foot {
  padding: 30px 18px calc(30px + env(safe-area-inset-bottom));
  text-align: center; font-size: 11.5px; color: var(--ink-3);
}

/* ── dialogs ───────────────────────────────────────────────────── */
.sheet {
  width: min(560px, calc(100vw - 24px));
  max-height: 88vh; padding: 0; color: var(--ink);
  background: var(--card); border: none; border-radius: var(--r-lg);
  box-shadow: 0 18px 60px rgba(35, 70, 55, .24);
}
.sheet::backdrop { background: rgba(42, 74, 60, .3); backdrop-filter: blur(3px); }
.sheet form { display: contents; }
.sheet-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; background: #fff; border-bottom: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.sheet-head h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--green-deep); }
.sheet-body { padding: 18px; overflow-y: auto; max-height: calc(88vh - 140px); }
.sheet-foot {
  position: sticky; bottom: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 13px 18px calc(13px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.spacer { flex: 1; }

.preview {
  display: flex; align-items: center; gap: 15px;
  padding: 14px; margin-bottom: 18px;
  background: var(--green-soft); border-radius: var(--r-md);
}
.preview-icon { width: 72px; height: 72px; flex: none; }
.preview strong { display: block; font-size: 15px; font-weight: 700; line-height: 1.3; }
.preview span { display: block; margin-top: 4px; font-size: 12.5px; color: var(--ink-2); }

.field { display: block; margin-bottom: 18px; }
.field > span { display: block; margin-bottom: 8px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.field > span i { font-style: normal; font-weight: 500; color: var(--ink-3); }
.field input[type=text], .field textarea {
  width: 100%; font-family: var(--font); font-size: 15px; font-weight: 500; color: var(--ink);
  background: #fff; border: 1px solid var(--line-2); border-radius: var(--r-md);
  padding: 11px 13px;
}
.field textarea { resize: vertical; font-size: 12.5px; }
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 4px var(--green-soft);
}
.help { display: block; margin-top: 7px; font-size: 11.5px; color: var(--ink-3); line-height: 1.55; }

.checkrow { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: 13.5px; }
.checkrow input { width: 18px; height: 18px; accent-color: var(--green); }

.swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch {
  width: 36px; height: 36px; padding: 0; cursor: pointer;
  border: 2px solid var(--line); border-radius: 11px;
  transition: transform .14s, border-color .14s;
}
.swatch:hover { transform: scale(1.06); }
.swatch[aria-pressed="true"] {
  border-color: var(--green-deep);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.iconpicker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px; max-height: 250px; overflow-y: auto;
  padding: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md);
}
.iconpicker .grouphead {
  grid-column: 1 / -1; font-size: 11px; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; color: var(--ink-3); padding-top: 6px;
}
.iconbtn {
  display: grid; place-items: center; padding: 4px; cursor: pointer;
  background: transparent; border: 2px solid transparent; border-radius: 12px;
  transition: background .14s, border-color .14s, transform .14s;
}
.iconbtn img { width: 48px; height: 48px; }
.iconbtn:hover { background: #fff; transform: scale(1.05); }
.iconbtn[aria-pressed="true"] { border-color: var(--green); background: #fff; }

.stamp { margin: 6px 0 0; font-size: 11.5px; color: var(--ink-3); }

.block { margin-bottom: 28px; }
.block h3 { margin: 0 0 10px; font-size: 14px; font-weight: 700; color: var(--green-deep); }
.note { margin: 0 0 13px; font-size: 13px; line-height: 1.75; color: var(--ink-2); }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 13px; }

.explain {
  margin-top: 12px; border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--bg); overflow: hidden;
}
.explain summary {
  padding: 12px 14px; cursor: pointer; font-size: 13px; font-weight: 700; color: var(--ink);
}
.explain p { margin: 0 14px 12px; font-size: 12.5px; line-height: 1.8; color: var(--ink-2); }
.explain b { color: var(--ink); }

/* ── toast ─────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 9;
  padding: 12px 20px; font-size: 13.5px; font-weight: 700;
  background: #fff; color: var(--green-deep);
  border: 1px solid var(--green); border-radius: var(--pill);
  box-shadow: var(--sh-2);
  max-width: calc(100vw - 32px);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
