:root {
  --ink: #0a1630;
  --muted: #6f7b91;
  --line: #dfe6f0;
  --card: #ffffff;
  --page: #edf3fb;
  --blue: #082f85;
  --blue-2: #0f52d2;
  --orange: #ff7a00;
  --shadow: 0 20px 55px rgba(14, 39, 86, .13);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(30, 104, 232, .10), transparent 27rem),
    var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 74px;
  padding: 13px clamp(16px, 4vw, 52px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid rgba(12,42,101,.10);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: -.5px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--blue-2), var(--blue));
  border: 3px solid white;
  outline: 2px solid var(--blue);
  box-shadow: 0 7px 20px rgba(8,47,133,.24);
}
.brand h1 { margin: 0; font-size: 18px; line-height: 1.1; letter-spacing: -.3px; }
.brand p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.privacy-pill,
.autosave {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #d9e5dc;
  border-radius: 999px;
  color: #356348;
  background: #f4fbf6;
  font-size: 12px;
  font-weight: 700;
}
.privacy-pill span,
.autosave span {
  width: 7px; height: 7px; border-radius: 50%; background: #22a35a; box-shadow: 0 0 0 4px rgba(34,163,90,.12);
}

.app-shell {
  width: min(1460px, 100%);
  margin: 0 auto;
  padding: 28px clamp(14px, 3vw, 42px) 60px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(390px, .92fr);
  gap: clamp(22px, 3vw, 44px);
  align-items: start;
}
.editor-panel { min-width: 0; }
.panel-heading,
.preview-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 2px 0 17px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--blue-2);
  font-size: 10px;
  letter-spacing: 1.8px;
  font-weight: 900;
}
.panel-heading h2,
.preview-topline h2 { margin: 0; font-size: clamp(21px, 2vw, 29px); letter-spacing: -.7px; }
.icon-button {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: white; color: var(--blue); font-size: 21px;
}
.icon-button:hover { border-color: var(--blue-2); transform: translateY(-1px); }

.section-card {
  margin-bottom: 15px;
  padding: 19px;
  background: var(--card);
  border: 1px solid rgba(15,56,122,.09);
  border-radius: 18px;
  box-shadow: 0 8px 28px rgba(20,52,98,.055);
}
.section-title-row {
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.section-title-row h3 { margin: 0; font-size: 15px; }
.section-title-row > span { color: var(--muted); font-size: 11px; }
.text-button {
  border: 0;
  background: transparent;
  color: var(--blue-2);
  font-size: 11px;
  font-weight: 800;
}

.preset-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.preset {
  min-height: 70px;
  padding: 9px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: #3b475b;
  background: #f9fbfe;
}
.preset b { font-size: 17px; line-height: 1; }
.preset span { font-size: 10px; font-weight: 800; }
.preset:hover,
.preset.active { border-color: var(--blue-2); color: var(--blue); background: #f0f6ff; box-shadow: inset 0 0 0 1px var(--blue-2); }

.template-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.template {
  padding: 7px 7px 9px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  color: #5d687a;
}
.template b { display: block; margin-top: 7px; font-size: 11px; }
.template:hover,
.template.active { border-color: var(--blue-2); color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue-2), 0 8px 20px rgba(20,76,174,.10); }
.template-thumb { position: relative; display: block; height: 70px; overflow: hidden; border-radius: 8px; background: #eef4fc; }
.template-thumb::before,
.template-thumb::after,
.template-thumb span,
.template-thumb em { content: ""; position: absolute; display: block; border-radius: 3px; }
.classic-thumb::before { inset: 7px 8px 42px; background: #0b3d9a; }
.classic-thumb::after { inset: 33px 24px 25px 8px; background: #ff8a00; }
.classic-thumb span { left: 8px; bottom: 8px; width: 45%; height: 12px; background: white; }
.classic-thumb em { right: 7px; bottom: -3px; width: 28px; height: 33px; border-radius: 18px 18px 0 0; background: #184ea5; }
.bold-thumb { background: linear-gradient(145deg,#071a47,#0e4ac0); }
.bold-thumb::before { left: 8px; top: 10px; width: 65%; height: 9px; background: #fff; }
.bold-thumb::after { left: 8px; top: 27px; width: 80%; height: 17px; background: #ff7900; }
.bold-thumb span { left: 8px; bottom: 8px; width: 52%; height: 12px; background: rgba(255,255,255,.9); }
.bold-thumb em { right: 8px; bottom: 0; width: 26px; height: 37px; border-radius: 18px 18px 0 0; background: #f4f7ff; }
.split-thumb::before { inset: 0 48% 0 0; background: #08388f; border-radius: 0; }
.split-thumb::after { left: 8px; top: 10px; width: 34%; height: 10px; background: white; }
.split-thumb span { left: 8px; top: 29px; width: 34%; height: 19px; background: #ff7a00; }
.split-thumb em { right: 13px; bottom: 0; width: 31px; height: 48px; border-radius: 18px 18px 0 0; background: #2f62b7; }
.minimal-thumb { background: white; border: 1px solid #eef1f6; }
.minimal-thumb::before { left: 50%; transform: translateX(-50%); top: 9px; width: 18px; height: 18px; border-radius: 50%; background: #0d439f; }
.minimal-thumb::after { left: 24%; right: 24%; top: 34px; height: 8px; background: #0d439f; }
.minimal-thumb span { left: 32%; right: 32%; top: 48px; height: 5px; background: #ff7a00; }
.minimal-thumb em { display: none; }

.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.upload-box {
  min-height: 98px;
  padding: 14px 12px;
  display: grid;
  grid-template-columns: 38px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  border: 1px dashed #bdcae0;
  border-radius: 14px;
  background: #fafcff;
  cursor: pointer;
  transition: .18s ease;
}
.upload-box:hover { border-color: var(--blue-2); background: #f4f8ff; }
.upload-box input { display: none; }
.upload-icon {
  grid-row: 1 / 3;
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: white; background: linear-gradient(145deg,var(--blue-2),var(--blue)); font-size: 19px; font-weight: 900;
}
.upload-box b { font-size: 12px; }
.upload-box small { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; }
.range-row { margin-top: 15px; }
.range-row label { margin-bottom: 6px; display: flex; justify-content: space-between; color: #4c586b; font-size: 11px; font-weight: 700; }
.range-row output { color: var(--blue-2); }
.range-row input { width: 100%; accent-color: var(--blue-2); }
.dual-ranges { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.range-row.compact { margin-top: 10px; }
.subtle-button,
.save-button {
  width: 100%; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; color: #556176; background: #f9fbfe; font-size: 11px; font-weight: 800;
}
.subtle-button:hover,
.save-button:hover { border-color: #9db3d6; color: var(--blue); }

.form-card { padding-bottom: 8px; }
.field { margin-bottom: 13px; }
.field label { display: block; margin-bottom: 6px; color: #445066; font-size: 11px; font-weight: 800; }
.field label small { color: var(--muted); font-weight: 500; }
.field input,
.field textarea {
  width: 100%;
  border: 1px solid #d8e0ec;
  border-radius: 10px;
  outline: 0;
  background: #fbfcfe;
  color: var(--ink);
  font-size: 13px;
  transition: .16s ease;
}
.field input { height: 41px; padding: 0 12px; }
.field textarea { padding: 10px 12px; line-height: 1.45; resize: vertical; }
.field input:focus,
.field textarea:focus { border-color: var(--blue-2); background: white; box-shadow: 0 0 0 3px rgba(15,82,210,.09); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.featured-field input { border-color: rgba(255,122,0,.48); background: #fffaf5; font-weight: 800; }

.color-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.color-grid label { min-height: 54px; padding: 7px 9px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 11px; font-size: 11px; font-weight: 800; }
.color-grid input { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 7px; background: none; cursor: pointer; }

.preview-panel { position: sticky; top: 98px; min-width: 0; }
.canvas-stage {
  width: min(100%, 470px);
  margin: 0 auto;
  padding: 10px;
  border-radius: 26px;
  background: #0c1d42;
  box-shadow: 0 28px 70px rgba(7,27,65,.22);
}
#posterCanvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 18px;
  background: white;
}
.action-grid { width: min(100%, 470px); margin: 16px auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.primary-action,
.share-action {
  min-height: 64px;
  padding: 9px 12px;
  display: grid;
  grid-template-columns: 30px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  text-align: left;
  border-radius: 14px;
}
.primary-action span,
.share-action span { grid-row: 1 / 3; font-size: 24px; }
.primary-action b,
.share-action b { font-size: 12px; }
.primary-action small,
.share-action small { opacity: .75; font-size: 9px; }
.primary-action { border: 0; color: white; background: linear-gradient(135deg,var(--blue-2),var(--blue)); box-shadow: 0 12px 28px rgba(8,47,133,.23); }
.share-action { border: 1px solid #cfd9e7; color: var(--blue); background: white; }
.primary-action:hover,
.share-action:hover { transform: translateY(-1px); }
.preview-panel .save-button { width: min(100%,470px); display: block; margin: 10px auto 0; }
.helper-note { width: min(100%,470px); margin: 10px auto 0; color: var(--muted); font-size: 10px; line-height: 1.5; text-align: center; }

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  padding: 11px 16px;
  border-radius: 999px;
  background: #0b1834;
  color: white;
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: .22s ease;
  box-shadow: 0 15px 40px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .preview-panel { position: static; grid-row: 1; }
  .preview-panel .preview-topline { width: min(100%,470px); margin-left: auto; margin-right: auto; }
}

@media (max-width: 620px) {
  .topbar { padding: 10px 14px; }
  .brand h1 { font-size: 16px; }
  .privacy-pill { display: none; }
  .app-shell { padding: 18px 10px 42px; gap: 25px; }
  .section-card { padding: 15px; border-radius: 15px; }
  .preset-grid { grid-template-columns: repeat(3,1fr); }
  .preset { min-height: 62px; }
  .template-grid { grid-template-columns: repeat(4, minmax(60px,1fr)); gap: 6px; }
  .template-thumb { height: 58px; }
  .upload-grid,
  .two-col { grid-template-columns: 1fr; }
  .upload-box { min-height: 78px; }
  .color-grid { gap: 5px; }
  .color-grid label { padding: 6px; flex-direction: column; justify-content: center; }
  .action-grid { grid-template-columns: 1fr; }
  .preview-panel { padding: 0 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
