:root {
  --paper: #f3efe4;
  --ink: #101a35;
  --red: #ef3f2f;
  --acid: #c9ff19;
  --pink: #ff76ae;
  --line: rgba(16, 26, 53, 0.22);
  --shadow: 0 14px 0 rgba(16, 26, 53, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, Arial, Helvetica, sans-serif;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(16, 26, 53, 0.08) 1px, transparent 1px);
  background-size: 18px 18px;
}

button, input { font: inherit; }
button { color: inherit; }

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 28px;
}

.hero { text-align: center; padding: 10px 0 28px; }

.stamp {
  display: inline-block;
  padding: 10px 18px 8px;
  border: 3px solid var(--red);
  color: var(--red);
  font-weight: 900;
  letter-spacing: 0.15em;
  transform: rotate(-2deg);
  background: var(--paper);
}

.hero h1 {
  margin: 22px 0 4px;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(3.6rem, 10vw, 7.4rem);
  line-height: 0.88;
  letter-spacing: -0.08em;
  text-transform: uppercase;
}

.hero h1 span { color: var(--ink); }
.hero h1 b { color: var(--red); font: inherit; }

.hero p {
  margin: 18px auto 0;
  max-width: 700px;
  font-size: clamp(1rem, 2.3vw, 1.35rem);
  font-weight: 700;
}

.counter-panel {
  max-width: 850px;
  margin: 0 auto 44px;
  padding: 30px clamp(20px, 5vw, 50px);
  text-align: center;
  background: rgba(255, 255, 255, 0.54);
  border: 2px solid var(--line);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.counter-line { display: flex; align-items: baseline; justify-content: center; gap: 14px; }
.counter-line strong { font: 900 clamp(3rem, 8vw, 5.6rem)/1 "Arial Black", Impact, sans-serif; letter-spacing: -0.07em; }
.counter-line span { font-size: clamp(1.2rem, 3vw, 2rem); font-weight: 800; color: rgba(16, 26, 53, 0.54); }
.counter-caption { margin-top: 8px; font-size: 0.8rem; font-weight: 900; letter-spacing: 0.17em; }

.progress-track { height: 14px; margin: 25px 0 12px; overflow: hidden; background: #ded9cc; border: 2px solid var(--line); border-radius: 999px; }
.progress-value { width: 0; height: 100%; min-width: 4px; background: linear-gradient(90deg, var(--red), #ff8c3a); transition: width 380ms ease; }
.counter-panel p { margin: 12px 0 20px; font-weight: 700; font-style: italic; }
.milestones { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.milestones span { min-width: 88px; padding: 8px 13px; border: 2px solid var(--line); border-radius: 999px; font-weight: 900; color: rgba(16, 26, 53, 0.45); }
.milestones .active { border-color: var(--red); color: var(--red); background: #fff5ec; }

.studio { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr); gap: 28px; align-items: start; }
.preview-column, .controls-column, .feed { min-width: 0; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; margin-bottom: 14px; }
.section-heading h2 { margin: 3px 0 0; font: 900 clamp(1.35rem, 3vw, 2rem)/1.05 "Arial Black", Impact, sans-serif; letter-spacing: -0.035em; }
.eyebrow { color: var(--red); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.14em; }
.live { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; padding: 8px 12px; border: 2px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.45); font-size: 0.8rem; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: #12a96b; box-shadow: 0 0 0 5px rgba(18,169,107,.13); }

.canvas-frame { padding: 12px; background: var(--ink); border-radius: 24px; box-shadow: 0 18px 0 rgba(16, 26, 53, 0.12); }
.ad-preview {
  --logo-scale: 1;
  --air: 0px;
  --cta-scale: 1;
  --tilt: 0deg;
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 440px;
  overflow: hidden;
  padding: calc(30px + var(--air));
  background: hsl(72 96% 55%);
  border: 3px solid var(--ink);
  transition: background 280ms ease, padding 280ms ease, filter 280ms ease;
  isolation: isolate;
}

.ad-preview.apple-mode { background: #f7f7f5 !important; color: #111; }
.ad-preview.apple-mode .ad-kicker, .ad-preview.apple-mode .ad-description { opacity: 0.68; }
.ad-preview.premium-mode::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .65;
  background: repeating-linear-gradient(120deg, transparent 0 28px, rgba(255,215,0,.28) 30px 34px);
}

.ad-topline { position: relative; z-index: 5; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.ad-logo {
  display: inline-block;
  padding: 8px 12px;
  background: var(--ink);
  color: white;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 1rem;
  letter-spacing: -0.05em;
  transform-origin: top left;
  transform: scale(var(--logo-scale)) rotate(var(--tilt));
  transition: transform 250ms cubic-bezier(.2,.9,.2,1.1);
}
.ad-mark { padding: 7px 9px; border: 2px solid currentColor; font-size: .64rem; font-weight: 900; transform: rotate(2deg); }

.ad-copy { position: relative; z-index: 3; display: flex; flex-direction: column; justify-content: center; height: calc(100% - 50px); padding-top: 10px; }
.ad-kicker { margin: 0 0 16px; max-width: 72%; font-size: .65rem; font-weight: 900; letter-spacing: .14em; }
.ad-copy h3 { margin: 0; max-width: 96%; font: 900 clamp(2.4rem, 7vw, 5.4rem)/.82 "Arial Black", Impact, sans-serif; letter-spacing: -.075em; transform: rotate(calc(var(--tilt) * -0.3)); }
.ad-copy h3 em { color: var(--red); font-style: normal; text-decoration: underline; text-decoration-thickness: .08em; }
.ad-description { max-width: 72%; margin: 22px 0 18px; font-size: clamp(.82rem, 1.6vw, 1.05rem); font-weight: 800; }
.fake-cta { align-self: flex-start; padding: 13px 18px; border: 3px solid var(--ink); border-radius: 0; background: var(--red); color: white; box-shadow: 6px 6px 0 var(--ink); font: 900 .75rem "Arial Black", Impact, sans-serif; transform: scale(var(--cta-scale)) rotate(var(--tilt)); transform-origin: left center; pointer-events: none; transition: transform 250ms ease; }

.font-1 { font-family: Georgia, "Times New Roman", serif; }
.font-1 .ad-copy h3, .font-1 .ad-logo, .font-1 .fake-cta { font-family: Georgia, "Times New Roman", serif; }
.font-2 { font-family: "Comic Sans MS", cursive; }
.font-2 .ad-copy h3, .font-2 .ad-logo, .font-2 .fake-cta { font-family: "Comic Sans MS", cursive; }
.font-3 { font-family: "Courier New", monospace; }
.font-3 .ad-copy h3, .font-3 .ad-logo, .font-3 .fake-cta { font-family: "Courier New", monospace; }
.font-4 { font-family: Impact, fantasy; }
.font-4 .ad-copy h3, .font-4 .ad-logo, .font-4 .fake-cta { font-family: Impact, fantasy; }
.font-5 { font-family: cursive; }
.font-5 .ad-copy h3, .font-5 .ad-logo, .font-5 .fake-cta { font-family: cursive; }

.badge-cloud, .cat-cloud, .note-cloud, .sparkles, .hook-marks { position: absolute; inset: 0; pointer-events: none; }
.badge-cloud { z-index: 7; }
.floating-badge { position: absolute; max-width: 145px; padding: 7px 9px; background: var(--pink); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); font-size: .63rem; font-weight: 1000; text-align: center; transform: rotate(var(--r)); }
.floating-cat { position: absolute; z-index: 6; font-size: clamp(1.8rem, 5vw, 3.7rem); transform: rotate(var(--r)); filter: drop-shadow(2px 3px 0 rgba(16,26,53,.35)); }
.floating-note { position: absolute; z-index: 9; width: min(180px, 42%); padding: 9px 10px; background: #fff6a2; border: 2px solid var(--ink); box-shadow: 4px 4px 0 rgba(16,26,53,.3); font-size: .63rem; font-weight: 800; transform: rotate(var(--r)); }
.floating-note::before { content: "ПРАВКА:"; display: block; margin-bottom: 3px; color: var(--red); font-size: .55rem; letter-spacing: .08em; }
.spark { position: absolute; z-index: 2; color: #d4a500; font-size: 1.6rem; }
.hook-word { position: absolute; z-index: 8; color: var(--red); font: 900 1.1rem "Arial Black", Impact, sans-serif; text-shadow: 2px 2px 0 white; transform: rotate(var(--r)); }

.last-edit { margin-top: 18px; padding: 17px 19px; border-left: 7px solid var(--red); background: rgba(255,255,255,.55); }
.last-edit span { display: block; margin-bottom: 5px; color: var(--red); font-size: .65rem; font-weight: 900; letter-spacing: .13em; }
.last-edit strong { font-size: 1.03rem; }
.last-edit p { margin: 4px 0 0; font-size: .88rem; }

.controls-column { position: sticky; top: 14px; padding: 22px; background: rgba(255,255,255,.58); border: 2px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.section-heading.compact { margin-bottom: 18px; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.action-grid button { min-height: 82px; padding: 10px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); box-shadow: 4px 4px 0 var(--ink); font-size: .78rem; font-weight: 900; cursor: pointer; transition: transform 100ms ease, box-shadow 100ms ease, background 100ms ease; }
.action-grid button span { display: block; margin-bottom: 4px; font-size: 1.45rem; }
.action-grid button:hover { background: var(--acid); transform: translate(-1px,-1px); box-shadow: 6px 6px 0 var(--ink); }
.action-grid button:active { transform: translate(4px,4px); box-shadow: 0 0 0 var(--ink); }
.action-grid button:disabled { opacity: .5; cursor: wait; }
.action-grid .danger { background: var(--red); color: white; }

.custom-form { margin-top: 22px; padding-top: 18px; border-top: 2px dashed var(--line); }
.custom-form label { display: block; margin-bottom: 8px; font-size: .78rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.custom-row { display: flex; gap: 7px; }
.custom-row input { min-width: 0; flex: 1; padding: 12px; border: 2px solid var(--ink); background: white; }
.custom-row button { padding: 10px 12px; border: 2px solid var(--ink); background: var(--acid); font-size: .72rem; font-weight: 1000; cursor: pointer; }
.form-message { min-height: 18px; margin: 6px 0 0; color: var(--red); font-size: .75rem; font-weight: 800; }
.share-button { width: 100%; margin-top: 10px; padding: 15px; border: 0; background: var(--ink); color: white; font-size: .75rem; font-weight: 1000; letter-spacing: .05em; cursor: pointer; }

.feed { margin-top: 50px; }
.history-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: nothing; }
.history-list li { position: relative; min-height: 122px; padding: 17px; background: rgba(255,255,255,.55); border: 2px solid var(--line); }
.history-list .history-number { display: block; margin-bottom: 16px; color: var(--red); font-size: .67rem; font-weight: 900; letter-spacing: .1em; }
.history-list strong { display: block; margin-bottom: 6px; }
.history-list p { margin: 0; font-size: .8rem; line-height: 1.35; }
.history-list time { position: absolute; right: 12px; top: 12px; font-size: .68rem; opacity: .55; }
.empty-history { grid-column: 1 / -1; min-height: auto !important; text-align: center; font-weight: 800; }

footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 45px; padding: 22px 0 0; border-top: 3px solid var(--ink); font-size: .78rem; }
footer b { color: var(--red); font-family: "Arial Black", Impact, sans-serif; }

.toast { position: fixed; left: 50%; bottom: 22px; z-index: 99; max-width: min(440px, calc(100% - 30px)); padding: 13px 17px; background: var(--ink); color: white; font-weight: 800; text-align: center; transform: translate(-50%, 130%); transition: transform 220ms ease; box-shadow: 6px 6px 0 var(--red); }
.toast.show { transform: translate(-50%, 0); }

@media (max-width: 880px) {
  .studio { grid-template-columns: 1fr; }
  .controls-column { position: static; }
  .ad-preview { min-height: 0; }
  .history-list { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .page-shell { width: min(100% - 18px, 1180px); padding-top: 22px; }
  .stamp { font-size: .68rem; }
  .hero h1 { font-size: 3.5rem; }
  .counter-panel { border-radius: 20px; }
  .counter-line { gap: 7px; }
  .counter-line strong { font-size: 2.65rem; }
  .counter-line span { font-size: 1rem; }
  .section-heading { align-items: flex-start; }
  .ad-preview { padding: calc(18px + var(--air)); }
  .ad-copy h3 { font-size: clamp(2.1rem, 13vw, 4rem); }
  .ad-description { max-width: 88%; margin-top: 15px; }
  .controls-column { padding: 16px; }
  .action-grid { gap: 7px; }
  .action-grid button { min-height: 76px; font-size: .72rem; }
  .custom-row { flex-direction: column; }
  .history-list { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
}

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