:root {
  --bg: #f5f4f1;
  --panel: #ffffff;
  --ink: #1d2422;
  --muted: #6b7470;
  --line: #e2e0da;
  --green: #163A32;
  --green-soft: #e3ece8;
  --rust: #A83F32;
  --warn: #9a6400;
  --radius: 10px;
  font-family: Inter, system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px;
  cursor: pointer; white-space: nowrap;
}
button:hover { border-color: #c9c6be; }
button.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
button.primary:hover { background: #0f2a24; }
button.danger { color: var(--rust); }
button:disabled { opacity: .5; cursor: default; }
button.link { border: 0; background: none; padding: 0; color: var(--green); text-decoration: underline; }
input[type=text], input[type=number], input[type=date], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fff; width: 100%;
}
textarea { resize: vertical; min-height: 64px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
h2 { font-size: 18px; margin: 0 0 4px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }

header {
  position: sticky; top: 0; z-index: 10; background: var(--green); color: #fff;
  display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 54px;
}
header .brand { font-weight: 800; letter-spacing: -.01em; font-size: 16px; }
header nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
header nav button {
  background: none; border: 0; color: #cfe0da; padding: 16px 12px; border-radius: 0;
  border-bottom: 3px solid transparent;
}
header nav button.on { color: #fff; border-bottom-color: #fff; font-weight: 600; }
header .usage { font-size: 12px; color: #cfe0da; white-space: nowrap; }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar > div { min-width: 180px; }
.toolbar label { margin-top: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--green-soft); font-weight: 600; }

/* Make cards */
.make { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.copylist { display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow: auto; }
.copy {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px; cursor: pointer; position: relative;
}
.copy.on { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-soft); }
.copy .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.copy .h { font-weight: 800; font-size: 15px; }
.copy .s { font-size: 12px; color: var(--muted); }
.copy .x, .tile .x {
  position: absolute; top: 6px; right: 6px; border: 0; background: rgba(255,255,255,.85); border-radius: 6px;
  padding: 2px 7px; font-size: 13px; color: var(--muted);
}
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.tile canvas { display: block; width: 100%; height: auto; }
.tile .cap { font-size: 11px; color: var(--muted); padding: 5px 8px; border-top: 1px solid var(--line); }
.tile.pending { display: grid; place-items: center; color: var(--muted); font-size: 12px; background: #fbfaf8; }
.spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Editor dialog */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(1280px, 96vw); max-height: 94vh; }
dialog::backdrop { background: rgba(10, 20, 18, .55); }
.editor { display: grid; grid-template-columns: 1fr 300px; height: 94vh; }
.editor .stage { background: #e9e7e2; padding: 18px; display: grid; place-items: center; overflow: auto; min-height: 0; }
.editor .stage canvas { max-width: 100%; max-height: calc(94vh - 36px); box-shadow: 0 4px 20px rgba(0,0,0,.15); }
.editor .side { padding: 16px; overflow: auto; min-height: 0; border-left: 1px solid var(--line); }
.editor .side h3 { margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; background: #fff; }
.chip.on { background: var(--green-soft); border-color: var(--green); }
input[type=range] { width: 100%; }

/* Approved strip + table */
.cards-table { width: 100%; border-collapse: collapse; }
.cards-table td, .cards-table th { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.cards-table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.cards-table img { width: 96px; border-radius: 6px; display: block; border: 1px solid var(--line); }
.cards-table input[type=date] { width: 150px; }

/* Calendar mock */
.mock { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12px; max-width: 980px; }
.mock .right { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-content: start; }
.mock .banner { grid-column: 1 / -1; }
.slotbox {
  position: relative; border: 2px dashed #c9c6be; border-radius: 8px; overflow: hidden; background: #fbfaf8;
  display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center;
}
.slotbox img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slotbox .tag {
  position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px;
  padding: 2px 8px; border-radius: 999px;
}
.slotbox .rot { position: absolute; right: 8px; bottom: 8px; }

/* Themes */
.themes { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.themelist button { display: block; width: 100%; text-align: left; margin-bottom: 6px; }
.themelist button.on { border-color: var(--green); background: var(--green-soft); font-weight: 600; }
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.formgrid .full { grid-column: 1 / -1; }
.pickgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.pick { display: flex; gap: 6px; align-items: center; font-size: 12px; border: 1px solid transparent; border-radius: 6px; padding: 4px; cursor: pointer; }
.pick.on { border-color: var(--green); background: var(--green-soft); }
.pick img { width: 34px; height: 34px; object-fit: contain; }
.windows .row { margin-bottom: 6px; }
.windows input { width: 90px; }

/* Catalog */
.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.prod { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12px; }
.prod img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fafaf8; border-radius: 6px; }
.prod .n { font-weight: 700; font-size: 13px; margin-top: 6px; }
.badge { display: inline-block; font-size: 11px; border-radius: 999px; padding: 1px 8px; background: #f3e3e0; color: var(--rust); font-weight: 600; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 8px; z-index: 100; max-width: 90vw; font-size: 13px;
}
.toast.err { background: var(--rust); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  main { padding: 16px; }
  .make, .themes, .editor { grid-template-columns: 1fr; }
  .editor { height: auto; max-height: none; }
  dialog { max-height: none; }
  .editor .side { border-left: 0; border-top: 1px solid var(--line); }
  .mock { grid-template-columns: 1fr; }
  .formgrid { grid-template-columns: 1fr; }
  header .usage { display: none; }
}
