* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #232529;
  --ink-soft: #4c5058;
  --page: #0e0e0f;        /* latar halaman gelap */
  --page-soft: #b4b4b0;   /* teks di atas gelap */
  --card: #ffffff;
  --tile: #f2f3f4;        /* isian tile & input (neutral) */
  --tile-2: #e8e9eb;
  --muted: #9a9ea7;
  --hair: #ebecef;
  --lime: #dcf24a;        /* aksen lime/chartreuse */
  --lime-deep: #c6dd2e;
  --lime-ink: #24270e;    /* teks gelap di atas lime */
  --accent: #232529;      /* ring seleksi (ink, kontras di kartu putih) */
  --orange: #f2734d;      /* titik logo */
  --shadow: 0 2px 6px rgba(0,0,0,.16), 0 16px 40px rgba(0,0,0,.26);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.10);
  /* warna folder kategori */
  --c-all: #34383f;
  --c-sewing: #c2e85a;
  --c-flora: #f4a6c8;
  --c-stones: #b3ade6;
  --c-sea: #8ec6f0;
  --c-mine: #f5c451;
  --r-card: 22px;
  --r-tile: 13px;
  --r-btn: 11px;
  --font-sans: "Plus Jakarta Sans", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
}

html { background: var(--page); }
body {
  font-family: var(--font-sans);
  background: var(--page);
  min-height: 100vh;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  padding: 24px 30px 0;
}

.grow { flex: 1; }
.hidden { display: none !important; }
.soft { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }

/* ---------- header (di atas latar gelap) ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-bottom: 22px; padding: 6px 6px; }
.logo { font-family: var(--font-serif); font-size: 28px; font-weight: 600; letter-spacing: -0.01em; color: #fff; }
.logo .dot { color: var(--orange); }
.top-right { display: flex; flex-direction: row; align-items: center; gap: 12px; }
/* tool toggle: Font Studio | PNG to Font */
.tool-toggle { display: inline-flex; gap: 5px; padding: 5px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.14); }
.tt { padding: 9px 20px; border-radius: 10px; font-family: var(--font-sans); font-weight: 600; font-size: 13.5px; text-decoration: none; color: var(--ink); background: #fff; transition: background 0.12s, color 0.12s; }
.tt.active { background: var(--lime); color: var(--lime-ink); }
.tt:not(.active):hover { background: #ececeb; }
/* Download — outlined (secondary output action) */
.dl-outline { display: inline-flex; align-items: center; gap: 8px; background: transparent; border: 1.5px solid rgba(255,255,255,0.32); color: #fff; padding: 10px 18px; border-radius: 999px; font-family: var(--font-sans); font-weight: 600; font-size: 13.5px; cursor: pointer; transition: border-color 0.12s, background 0.12s; }
.dl-outline:hover { border-color: #fff; background: rgba(255,255,255,0.06); }

/* ---------- buttons (di dalam kartu putih) ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; background: var(--tile); color: var(--ink);
  padding: 8px 15px; font-size: 12.5px; font-weight: 500;
  cursor: pointer; text-decoration: none; font-family: inherit;
  border-radius: var(--r-btn); transition: background 0.12s, color 0.12s;
}
.btn:hover { background: var(--tile-2); }
.btn.dark { background: var(--lime); color: var(--lime-ink); font-weight: 700; }
.btn.dark:hover { background: #e6fa62; }
.btn.active { background: var(--lime); color: var(--lime-ink); font-weight: 600; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--tile); color: var(--ink); }
.btn.danger { background: transparent; color: #d97a6a; }
.btn.danger:hover { background: #fdeeeb; }
.btn.wide { width: 100%; justify-content: center; padding: 12px 16px; font-size: 13.5px; font-weight: 700; margin-top: 14px; border-radius: var(--r-tile); }
.btn:disabled { background: transparent; color: #c2c5cc; cursor: default; }
.btn.danger:disabled { color: #e4c3bc; }

/* segmented toggles (A–Z tabs, Manual/Brush) — black outline + black active (Figma node 78) */
.seg { display: inline-flex; background: transparent; border: 1px solid var(--ink); border-radius: 12px; padding: 3px; gap: 2px; }
.seg .btn { background: transparent; color: var(--ink); border-radius: 8px; font-weight: 600; }
.seg .btn:hover { background: rgba(0,0,0,0.05); }
.seg .btn.active { background: var(--ink); color: #fff; box-shadow: none; }

/* ---------- section headers ---------- */
.head, .head-inline { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.head-inline { margin-bottom: 12px; flex-wrap: wrap; }
.step-num { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--tile); border-radius: 7px; padding: 3px 7px; }
.step-name { font-family: var(--font-serif); font-size: 18px; font-weight: 600; letter-spacing: 0; }
.head-inline .char-tabs { margin-left: auto; }

/* ---------- tester ---------- */
.tester { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 16px 22px 14px; margin-bottom: 16px; }
.tester-row { display: flex; align-items: center; gap: 16px; }
.tester-row input { flex: 1; border: none; border-bottom: 1.5px solid var(--hair); font-size: 15px; padding: 5px 2px; outline: none; font-family: inherit; color: var(--ink); background: transparent; }
.tester-row input:focus { border-bottom-color: var(--ink); }
.type-canvas { min-height: 72px; display: flex; align-items: flex-end; flex-wrap: wrap; padding-top: 10px; }
.type-canvas svg { height: 60px; display: block; }
.type-canvas .miss { font-weight: 700; font-size: 46px; color: #dcdee2; line-height: 60px; letter-spacing: -0.02em; }
.type-canvas .sp { width: 20px; }

/* ---------- studio layout ---------- */
.studio { display: grid; grid-template-columns: 1fr 1.9fr; gap: 16px; align-items: start; }
.studio > * { min-width: 0; }
.side-col, .main-col { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 18px 20px; }
.canvas-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.canvas-bar.sel-row { margin-top: 14px; }
.chip { background: var(--lime); color: var(--lime-ink); padding: 3px 11px; font-weight: 700; font-size: 14px; border-radius: 8px; }
.range input { width: 90px; accent-color: var(--lime-deep); }

/* ---------- char picker ---------- */
.char-block { margin-bottom: 14px; }
.char-strip { display: flex; gap: 7px; overflow-x: auto; width: 100%; padding-bottom: 4px; scrollbar-width: thin; }
.char-tile { position: relative; flex: 0 0 47px; width: 47px; height: 47px; border: 1.5px solid transparent; border-radius: var(--r-tile); cursor: pointer; background: var(--tile); display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; color: var(--ink); transition: background 0.12s, border-color 0.12s; }
.char-tile::before { content: attr(data-char); position: absolute; top: 2px; left: 5px; font-size: 8px; font-weight: 600; color: var(--muted); display: none; }
.char-tile.made::before { display: block; }
.char-tile .tile-glyph { width: 90%; height: 90%; }
.char-tile:hover { background: var(--tile-2); }
.char-tile.active { background: var(--card); border-color: var(--ink); }
.char-tile .corner { display: none; }

/* ---------- canvas ---------- */
.stage-wrap { border-radius: var(--r-tile); overflow: hidden; background: #ffffff; aspect-ratio: 1 / 1; max-height: 54vh; margin: 0 auto; }
#stage { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; }
#stage.brush { cursor: crosshair; }
#stage .tpl { fill: #e6e7ec; }              /* huruf template abu muda di atas kanvas putih (Figma node 78) */

/* Polish action buttons: outlined pills (Reroll + selected-object row) */
.canvas-bar .btn { background: #fff; border: 1.5px solid #d7d8db; color: var(--ink); font-weight: 500; }
/* tombol di dalam segmented toggle (Manual/Brush) TIDAK ikut outline abu */
.canvas-bar .seg .btn { border: none; background: transparent; }
.canvas-bar .seg .btn.active { background: var(--ink); color: #fff; }
.canvas-bar .btn:hover { border-color: var(--ink); background: #fff; }
.canvas-bar .btn:disabled { border-color: #e7e8ea; color: #c2c5cc; background: #fff; }
.canvas-bar .btn.danger { border-color: #ecc7bf; color: #e0824a; }
.canvas-bar .btn.danger:hover { border-color: #e0824a; background: #fdefe8; }
.canvas-bar .btn.danger:disabled { border-color: #f2ddd5; color: #e6b9a6; }
.canvas-bar .btn.ghost { border: none; background: transparent; color: var(--muted); }
.canvas-bar .btn.ghost:hover { background: transparent; color: var(--ink); }
#btn-reset { color: #e0824a; }
#btn-reset:hover { color: #cf6f38; }

/* ---------- things: vertical folder tabs + object panel ---------- */
.things-body { display: flex; gap: 8px; align-items: stretch; height: 330px; }
.cat-bar { flex: 0 0 42px; width: 42px; height: 100%; border-radius: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: filter 0.12s; }
.cat-bar:hover { filter: brightness(0.97); }
.cat-bar span { transform: rotate(-90deg); white-space: nowrap; font-family: var(--font-sans); font-weight: 700; font-size: 13.5px; color: #1b1a18; }
.pal-panel { flex: 1; min-width: 0; height: 100%; background: #fff; border: 1px solid var(--hair); border-radius: 16px; padding: 12px; overflow-y: auto; scrollbar-width: thin; }
.pal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pal-item { position: relative; aspect-ratio: 1; border-radius: 16px; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.12s; }
.pal-item:hover { background: #f4f4f2; }
.pal-item.selected { background: #FFF1FE; }
.pal-item svg, .pal-item img.thumb { width: 64%; height: 64%; object-fit: contain; }
.pal-item .del { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border: none; border-radius: 6px; background: rgba(255,255,255,0.95); color: var(--ink); font-size: 10px; line-height: 1; cursor: pointer; display: none; box-shadow: var(--shadow-sm); }
.pal-item:hover .del { display: block; }
.pal-item .del:hover { background: #d97a6a; color: #fff; }
.pal-upbox { border: 1.5px dashed #c9ccd2; border-radius: 14px; padding: 16px 10px; text-align: center; margin-bottom: 8px; cursor: pointer; transition: border-color 0.12s, background 0.12s; }
.pal-upbox span { font-size: 12px; font-weight: 600; color: var(--muted); }
.pal-upbox:hover { border-color: var(--ink); background: #fafafa; }
.pal-empty { grid-column: 1 / -1; font-size: 12px; color: var(--muted); padding: 24px 8px; text-align: center; }
.el-note { font-size: 11px; color: var(--ink-soft); margin-top: 10px; line-height: 1.4; }

/* ---------- recipe ---------- */
.help { font-size: 12px; color: var(--muted); line-height: 1.5; margin-bottom: 12px; }
.dropzone { border: 1.5px dashed #cfcfcf; border-radius: 14px; padding: 20px; text-align: center; margin-bottom: 12px; transition: border-color 0.12s, background 0.12s; }
.dropzone span { font-size: 13px; color: var(--muted); }
.dropzone.drag { border-color: var(--lime-deep); background: #fbffe9; }
.mix { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.mix-item { width: 44px; height: 44px; border-radius: 14px; background: #fff; border: 1px solid var(--hair); cursor: pointer; display: flex; align-items: center; justify-content: center; position: relative; transition: border-color 0.12s, box-shadow 0.12s; }
.mix-item svg, .mix-item img { width: 30px; height: 30px; object-fit: contain; }
.mix-item:hover { border-color: var(--ink); }
.mix-item.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.mix-item.on::after { content: "✓"; position: absolute; top: -5px; right: -5px; background: var(--lime); color: var(--lime-ink); font-size: 9px; font-weight: 700; width: 15px; height: 15px; border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.ctl { display: flex; align-items: center; gap: 12px; background: transparent; padding: 5px 2px; margin-bottom: 4px; }
.ctl span { font-size: 12.5px; font-weight: 600; width: 56px; color: var(--ink); }
.ctl input { flex: 1; accent-color: var(--lime-deep); }
.ctl b { font-size: 12.5px; font-weight: 600; width: 36px; text-align: right; }
.scope { display: flex; gap: 14px; flex-wrap: wrap; margin: 12px 2px 2px; font-size: 12.5px; }
.scope label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.scope input { accent-color: var(--lime-deep); }
.scope.overwrite { display: flex; color: var(--muted); }

/* ---------- footer (di atas latar gelap) ---------- */
.mega { padding: 30px 6px 16px; overflow: hidden; }
.mega-word { display: flex; align-items: flex-end; justify-content: center; }
.mega-word svg { height: clamp(58px, 8.5vw, 104px); display: block; }
.mega-word .miss { font-family: var(--font-serif); font-weight: 600; font-size: clamp(58px, 8.5vw, 104px); line-height: 1; letter-spacing: -0.02em; color: #fff; }
.mega-word .dotchar { color: var(--orange); }
.mega-word .sp { width: 20px; }
.copyright { text-align: center; font-size: 12px; color: #6f6f68; margin-top: 20px; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-backdrop.hidden { display: none; }
.modal { background: #fff; border-radius: var(--r-card); padding: 26px; width: 440px; max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.modal h2 { font-family: var(--font-serif); font-size: 20px; font-weight: 600; letter-spacing: 0; margin-bottom: 18px; }
.field { display: block; margin-bottom: 14px; font-size: 13px; }
.field > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.field input[type="text"] { width: 100%; border: none; background: var(--tile); border-radius: var(--r-btn); padding: 10px 13px; font-size: 14px; outline: none; font-family: inherit; }
.field input[type="text"]:focus { box-shadow: 0 0 0 2px var(--accent); }
.radio { display: flex; gap: 10px; align-items: flex-start; padding: 12px; background: var(--tile); border-radius: var(--r-tile); margin-bottom: 8px; cursor: pointer; transition: box-shadow 0.12s; }
.radio:has(input:checked) { background: var(--card); box-shadow: 0 0 0 2px var(--accent); }
.radio small { display: block; color: var(--muted); margin-top: 2px; line-height: 1.4; font-size: 11.5px; }
.modal-status { font-size: 12.5px; color: var(--ink-soft); min-height: 18px; margin-bottom: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 940px) {
  body { padding: 18px 16px 0; }
  .studio { grid-template-columns: 1fr; }
  .top { flex-direction: column; }
  .top-right { align-items: flex-start; }
}
