* { box-sizing: border-box; }
body { margin: 0; }
textarea, input, button { font-family: 'M PLUS Rounded 1c', sans-serif; }

#ssgen-root {
  min-height: 100vh;
  background: #f8f1e4;
  font-family: 'M PLUS Rounded 1c', sans-serif;
  color: #4e3b2e;
  padding: 0 0 80px;
}

/* ---- header ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(248, 241, 228, .92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1.5px solid #ead9c2;
  padding: 18px 28px;
}
.topbar-row { display: flex; align-items: center; gap: 14px; max-width: 1200px; margin: 0 auto; flex-wrap: wrap; }
.app-icon {
  width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none;
  background: #fff; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(120, 90, 60, .2);
}
.title-wrap { flex: 1; min-width: 200px; }
.title { font-size: 21px; font-weight: 800; letter-spacing: .3px; }
.subtitle { font-size: 12.5px; color: #8f7764; font-weight: 700; margin-top: 1px; }

.help {
  max-width: 1200px; margin: 14px auto 0; padding: 18px 22px;
  background: #fffaf2; border: 1.5px solid #eadfcc; border-radius: 14px;
  color: #4e3b2e; font-size: 13.5px; line-height: 1.75;
  max-height: 60vh; overflow: auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px 28px;
}
.help[hidden] { display: none; }
.help-h { font-weight: 800; font-size: 14.5px; color: #8a5f48; margin-bottom: 4px; }

/* ---- shared buttons ---- */
.pill-btn {
  flex: none; padding: 8px 16px; border-radius: 999px; font-weight: 800; font-size: 13px; cursor: pointer;
  border: 1.5px solid #dcc8ac; background: #fff; color: #8a5f48;
}
.pill-btn.active { background: #c08a6c; color: #fff; border-color: #c08a6c; }

.tab {
  padding: 9px 17px; border-radius: 999px; font-weight: 800; font-size: 14px; cursor: pointer;
  border: 1.5px solid #dcc8ac; transition: .12s; background: #fff; color: #8a5f48;
}
.tab.active { background: #c08a6c; color: #fff; border-color: #c08a6c; box-shadow: 0 2px 6px rgba(192, 138, 108, .35); }

.size-btn {
  padding: 6px 13px; border-radius: 8px; font-weight: 800; font-size: 12.5px; cursor: pointer;
  border: 1.5px solid #e2d3bd; transition: .12s; background: #fff; color: #8f7764;
}
.size-btn.active { background: #c08a6c; color: #fff; border-color: #c08a6c; }

.font-btn {
  padding: 6px 13px; border-radius: 8px; font-weight: 700; font-size: 13px; cursor: pointer;
  border: 1.5px solid #e2d3bd; transition: .12s; background: #fff; color: #6a5442;
}
.font-btn.active { background: #c08a6c; color: #fff; border-color: #c08a6c; }

.seg { display: flex; border: 1.5px solid #e2d3bd; border-radius: 8px; overflow: hidden; }
.seg > button {
  border: 0; padding: 7px 13px; font-size: 12.5px; font-weight: 800; cursor: pointer; white-space: nowrap;
  background: #fff; color: #9a8270;
}
.seg > button.active { background: #c08a6c; color: #fff; }

.danger-btn {
  border: 1.5px solid #e6b8b0; background: #fdecea; color: #c0503f;
  font-weight: 800; font-size: 12.5px; border-radius: 8px; padding: 7px 12px; cursor: pointer;
}
.upload-btn {
  display: flex; align-items: center; gap: 5px; border: 1.5px solid #e2d3bd; border-radius: 8px;
  background: #fff; color: #8a5f48; font-weight: 800; font-size: 12.5px; cursor: pointer; padding: 7px 12px;
}
.upload-btn input, .card-upload input { display: none; }

input[type=color] {
  width: 34px; height: 28px; border: 1.5px solid #e2d3bd; border-radius: 7px; padding: 1px; cursor: pointer; background: #fff;
}
input[type=range] { accent-color: #c08a6c; cursor: pointer; }

/* ---- controls ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 22px 28px 0; }
.panel {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 12px;
  padding: 11px 16px; background: #fff; border: 1.5px solid #eadfcc; border-radius: 12px;
}
.panel.tight { gap: 8px; }
.panel.first { margin-top: 0; padding: 11px 14px; }
.panel.small { padding: 10px 14px; gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.lbl { font-size: 12.5px; font-weight: 800; color: #7a6352; margin-right: 2px; }
.row > .lbl { font-size: 13px; margin-right: 4px; }
.sublbl { font-size: 12px; font-weight: 800; color: #b8a491; margin-left: 4px; }
.colorlbl { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: #9a8270; }
.divider { width: 1px; height: 22px; background: #eadfcc; margin: 0 4px; }
.spacer { flex: 1; }
.saved { font-size: 12px; font-weight: 800; color: #3fae7a; }

.text-input {
  border: 1.5px solid #e2d3bd; border-radius: 8px; padding: 7px 10px; font-size: 13.5px; font-weight: 700;
  color: #4e3b2e; outline: none;
}
.title-input { flex: 1; min-width: 200px; }
.word-input { width: 130px; font-size: 13px; font-weight: 800; }
.scale-range { flex: 1; min-width: 160px; max-width: 360px; }
.pct { font-size: 13px; font-weight: 800; color: #8a5f48; min-width: 48px; text-align: right; }

/* app chips */
.chip { display: flex; align-items: center; border-radius: 999px; overflow: hidden; border: 1.5px solid #e2d3bd; background: #fff; }
.chip.active { border-color: #c08a6c; background: #c08a6c; }
.chip.pending { border-color: #e6604f; background: #fdecea; }
.chip-name {
  border: 0; background: transparent; padding: 8px 6px 8px 15px; font-weight: 800; font-size: 13px; cursor: pointer;
  max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #8a5f48;
}
.chip.active .chip-name { color: #fff; }
.chip-del {
  border: 0; background: transparent; padding: 8px 12px 8px 6px; font-weight: 800; cursor: pointer; line-height: 1;
  white-space: nowrap; font-size: 14px; color: #bfae9c;
}
.chip.active .chip-del { color: rgba(255, 255, 255, .85); }
.chip.pending .chip-del { font-size: 11.5px; color: #e6604f; }
.new-app {
  padding: 8px 14px; border-radius: 999px; border: 1.5px dashed #d7bfa3; background: #fbf5ea; color: #8a5f48;
  font-weight: 800; font-size: 13px; cursor: pointer;
}

/* ---- sections & cards ---- */
.section { max-width: 1200px; margin: 0 auto; padding: 30px 28px 0; }
.section-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.section-label { font-size: 16px; font-weight: 800; color: #8a5f48; }
.section-size { font-size: 12.5px; font-weight: 700; color: #a8927f; background: #f1e6d4; padding: 3px 10px; border-radius: 999px; }
.zip-btn {
  padding: 8px 16px; border-radius: 999px; border: 0; background: #c08a6c; color: #fff; font-weight: 800; font-size: 13px;
  cursor: pointer; box-shadow: 0 2px 6px rgba(192, 138, 108, .35);
}
.cards { display: flex; flex-wrap: wrap; gap: 20px; }
.card { flex: none; width: 236px; display: flex; flex-direction: column; gap: 9px; }
.card-num { font-size: 12px; color: #8a7360; font-weight: 800; }
.preview { position: relative; border-radius: 12px; overflow: hidden; box-shadow: 0 3px 12px rgba(110, 80, 50, .16); }
.preview canvas { display: block; width: 100%; height: auto; background: #efe4d2; touch-action: none; }
.dl-btn {
  position: absolute; top: 10px; right: 10px; opacity: 0; transition: opacity .15s;
  border: 0; border-radius: 999px; padding: 8px 14px; background: rgba(18, 48, 80, .85); color: #fff;
  font-weight: 800; font-size: 12.5px; cursor: pointer; white-space: nowrap; box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.preview:hover .dl-btn, .dl-btn:focus-visible { opacity: 1; }
@media (hover: none) { .dl-btn { opacity: 1; } }

.card textarea {
  width: 100%; resize: vertical; border: 1.5px solid #e2d3bd; border-radius: 9px; line-height: 1.45; outline: none;
}
.card .ta-main { padding: 7px 9px; font-size: 13px; color: #4e3b2e; font-weight: 700; }
.card .ta-sub { padding: 6px 9px; font-size: 12px; color: #6a5442; font-weight: 500; }
.card-row { display: flex; align-items: center; gap: 7px; }
.card-row.stretch { gap: 8px; align-items: stretch; }
.card .seg { border-radius: 9px; flex: none; }
.card .seg.grow { flex: 1; }
.card .seg.grow > button { flex: 1; padding: 6px 0; font-size: 11.5px; }
.card-upload {
  display: flex; align-items: center; justify-content: center; border: 1.5px solid #e2d3bd; border-radius: 9px;
  background: #fff; color: #8a5f48; font-weight: 800; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.card-upload.wide { flex: 1; min-width: 0; padding: 7px 0; }
.card-upload.compact { flex: none; padding: 6px 10px; }
.card-lbl { font-size: 11.5px; font-weight: 800; color: #a8927f; flex: none; }
.card-range { flex: 1; min-width: 0; }
.card-x {
  border: 1.5px solid #e6b8b0; background: #fdecea; color: #c0503f; font-weight: 800; font-size: 12px;
  border-radius: 9px; padding: 6px 9px; cursor: pointer; flex: none;
}
.card-hint { flex: 1; font-size: 11px; font-weight: 700; color: #b8a491; }
.reset-btn {
  border: 1.5px solid #e2d3bd; background: #fff; color: #9a8270; font-weight: 800; font-size: 11px;
  border-radius: 8px; padding: 5px 9px; cursor: pointer; white-space: nowrap;
}
