/* ============================================================
   STORIMATIC ADS CONSOLE — Stylesheet
   Aesthetic: Editorial · Refined · Workshop
   ============================================================ */

:root {
  /* Palette — warm paper, deep ink, muted accents */
  --paper: #f4f1ea;
  --paper-2: #ebe6da;
  --paper-3: #e0dac9;
  --ink: #1a1814;
  --ink-soft: #3d3830;
  --ink-mute: #6a6358;
  --rule: #d8d2c2;
  --accent: #b54422;       /* burnt sienna */
  --accent-2: #5a6e3a;     /* moss */
  --accent-3: #7c5c2e;     /* tobacco */
  --signal: #d4a017;       /* mustard */
  --error: #9b2c2c;
  --success: #2f6b3a;

  /* Typography */
  --font-display: 'Fraunces', 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Inter Tight', -apple-system, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* Sizing */
  --shell-max: 1180px;
  --radius: 6px;
  --radius-sm: 3px;
  --shadow-soft: 0 1px 2px rgba(26,24,20,0.04), 0 4px 12px rgba(26,24,20,0.05);
  --shadow-card: 0 1px 0 var(--rule), 0 8px 24px rgba(26,24,20,0.06);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  min-height: 100vh;
  overflow-x: hidden;
}

/* Grain overlay */
.grain {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.06;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' /%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Selection */
::selection { background: var(--ink); color: var(--paper); }

/* Links */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Typography helpers */
.mono { font-family: var(--font-mono); font-size: 0.9em; color: var(--ink-mute); }
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--paper-2);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
}

/* ============================================================
   BRAND
   ============================================================ */
.brand { display: inline-flex; align-items: baseline; gap: 0.55rem; }
.brand__mark {
  font-size: 1.25rem;
  color: var(--accent);
  transform: translateY(2px);
}
.brand__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand__sub {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  border-left: 1px solid var(--rule);
  padding-left: 0.6rem;
  margin-left: 0.2rem;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.page--login { background: var(--paper); }

.login-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "header" "hero" "callout" "footer";
  gap: 2rem;
}

@media (min-width: 900px) {
  .login-shell {
    grid-template-columns: 1.4fr 1fr;
    grid-template-areas:
      "header  header"
      "hero    callout"
      "footer  footer";
    padding: 3rem 3rem 4rem;
    min-height: 100vh;
  }
}

.login-header {
  grid-area: header;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}
.login-header__meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-mute);
  display: flex; align-items: center; gap: 0.5rem;
}
.meta-dot {
  width: 6px; height: 6px;
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
}

.login-hero { grid-area: hero; padding-top: 1rem; }

.login-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-mute);
  margin: 0 0 1.5rem;
}

.login-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin: 0 0 1.8rem;
  color: var(--ink);
  font-variation-settings: "opsz" 144;
}
.login-title em {
  font-style: italic;
  color: var(--accent);
  font-weight: 300;
}

.login-lede {
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 52ch;
  line-height: 1.65;
  margin: 0 0 2.5rem;
}

.login-actions { display: flex; flex-direction: column; gap: 1rem; align-items: flex-start; }
.login-hint {
  font-size: 0.85rem;
  color: var(--ink-mute);
  max-width: 50ch;
  line-height: 1.55;
  margin: 0;
}

/* Callout panel */
.login-callout {
  grid-area: callout;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 2rem;
  align-self: start;
  position: relative;
}
.login-callout::before {
  content: "";
  position: absolute;
  top: -1px; left: 2rem;
  width: 40px; height: 3px;
  background: var(--accent);
}
.callout-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  margin: 0 0 1.5rem;
  letter-spacing: -0.01em;
}
.callout-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1.1rem; }
.callout-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem;
  align-items: baseline;
  font-size: 0.92rem;
  color: var(--ink-soft);
  line-height: 1.55;
}
.callout-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.05em;
}

.login-footer {
  grid-area: footer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-mute);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.93rem;
  letter-spacing: -0.005em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 150ms ease;
  text-decoration: none;
  line-height: 1;
}
.btn--primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn--primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(181, 68, 34, 0.25);
}
.btn--primary:active { transform: translateY(0); }
.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--rule);
}
.btn--ghost:hover {
  background: var(--paper-2);
  color: var(--ink);
  border-color: var(--ink-mute);
  text-decoration: none;
}
.btn--lg { padding: 1rem 2rem; font-size: 1rem; }
.btn--sm { padding: 0.45rem 0.9rem; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn__spinner { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   TOPBAR (app pages)
   ============================================================ */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}
.topbar__left { display: flex; align-items: center; gap: 0.75rem; }
.topbar__right { display: flex; align-items: center; gap: 1rem; }
.topbar__divider {
  width: 1px; height: 16px; background: var(--rule); display: inline-block;
}
.topbar__crumb {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.topbar__back {
  font-size: 1.4rem;
  color: var(--ink-mute);
  text-decoration: none;
  padding-right: 0.5rem;
  border-right: 1px solid var(--rule);
}
.topbar__back:hover { color: var(--ink); text-decoration: none; }
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 100px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.user-pill__dot {
  width: 6px; height: 6px;
  background: var(--success);
  border-radius: 50%;
}

/* ============================================================
   APP SHELL & STEP CARDS
   ============================================================ */
.app-shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 2.5rem 2rem 6rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.step-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-soft);
}
.step-card__head {
  display: flex;
  align-items: flex-start;
  gap: 1.2rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}
.step-card__head > div { flex: 1; }
.step-num {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
  background: var(--paper-2);
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  min-width: 38px;
  text-align: center;
}
.step-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.4rem;
  margin: 0 0 0.3rem;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.step-desc {
  font-size: 0.9rem;
  color: var(--ink-mute);
  margin: 0;
}

/* ============================================================
   ACCOUNT GRID
   ============================================================ */
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.account-loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--ink-mute);
  font-style: italic;
}
.account-card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.3rem;
  cursor: pointer;
  transition: all 200ms ease;
  text-align: left;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.account-card:hover {
  border-color: var(--ink);
  background: var(--paper);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}
.account-card.is-selected {
  border-color: var(--accent);
  border-width: 2px;
  background: var(--paper);
}
.account-card__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.account-card__id {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-mute);
}
.account-card__meta {
  display: flex; gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.6rem;
}
.account-card__tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  background: var(--paper-3);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.account-card__tag--test {
  background: var(--signal);
  color: var(--ink);
}

/* ============================================================
   CAMPAIGN TYPE GRID
   ============================================================ */
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.type-card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.8rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  position: relative;
  transition: all 200ms ease;
  min-height: 200px;
}
.type-card:hover {
  background: var(--paper);
  border-color: var(--ink);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
  text-decoration: none;
}
.type-card__icon {
  width: 44px; height: 44px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.type-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 0;
  letter-spacing: -0.015em;
}
.type-card p {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.55;
}
.type-card__arrow {
  position: absolute;
  top: 1.8rem; right: 1.8rem;
  font-size: 1.5rem;
  color: var(--ink-mute);
  transition: transform 200ms ease;
}
.type-card:hover .type-card__arrow {
  transform: translateX(4px);
  color: var(--accent);
}

/* ============================================================
   FORM
   ============================================================ */
.form-shell {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.form-section {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-soft);
}
.form-section__head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}
.form-section__head > h2 { flex: 1; }
.form-section__num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 500;
  background: var(--paper-2);
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  min-width: 34px;
  text-align: center;
}
.form-section__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.25rem;
  margin: 0;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.form-grid {
  display: grid;
  gap: 1.25rem;
}
.form-grid--2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 700px) { .form-grid--2 { grid-template-columns: 1fr; } }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.field--span2 { grid-column: 1 / -1; }
.field--inline {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 1.2rem;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  background: var(--paper-2);
}
.field--inline legend {
  padding: 0 0.5rem;
  margin-left: -0.5rem;
}
.field__label {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 500;
  letter-spacing: -0.005em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.field__hint {
  font-size: 0.76rem;
  color: var(--ink-mute);
  font-weight: 400;
  font-style: italic;
}
.field__help {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: lowercase;
}

input[type=text],
input[type=number],
input[type=date],
input[type=url],
input[type=email],
select,
textarea {
  font-family: var(--font-body);
  font-size: 0.93rem;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  color: var(--ink);
  transition: all 150ms ease;
  width: 100%;
  font-feature-settings: "ss01";
}
textarea {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 60px;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--paper);
  box-shadow: 0 0 0 3px rgba(181, 68, 34, 0.12);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236a6358' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.5rem;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.checkbox input { width: auto; margin: 0; cursor: pointer; }

/* ============================================================
   AD GROUPS (dynamic)
   ============================================================ */
.ad-group {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent-2);
  border-radius: var(--radius);
  padding: 1.5rem;
  background: var(--paper-2);
  margin-bottom: 1.2rem;
}
.ad-group__head {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 0.8rem;
  margin-bottom: 1.2rem;
  align-items: center;
}
@media (max-width: 700px) {
  .ad-group__head { grid-template-columns: 1fr; }
}
.ag-section {
  margin-bottom: 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--paper);
}
.ag-section summary {
  cursor: pointer;
  padding: 0.7rem 1rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-soft);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ag-section summary::before {
  content: "▸";
  font-size: 0.75rem;
  color: var(--ink-mute);
  transition: transform 150ms ease;
}
.ag-section[open] summary::before { transform: rotate(90deg); }
.ag-section[open] summary { border-bottom: 1px solid var(--rule); }
.ag-section > textarea,
.ag-section > .ag-ads,
.ag-section > .field__hint,
.ag-section > .btn {
  margin: 1rem;
  width: calc(100% - 2rem);
}
.ag-section > .field__hint { margin-top: -0.5rem; display: block; }

/* RSA ads */
.rsa-ad {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.3rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.rsa-ad__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}
.rsa-ad__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: -0.01em;
}
.headline-counter,
.description-counter {
  font-family: var(--font-mono);
}
.headline-counter.is-valid,
.description-counter.is-valid { color: var(--success); }
.headline-counter.is-invalid,
.description-counter.is-invalid { color: var(--error); }

/* ============================================================
   PMAX NOTICE
   ============================================================ */
.pmax-notice {
  border-left: 4px solid var(--signal);
  background: linear-gradient(to right, rgba(212, 160, 23, 0.08), var(--paper));
}
.pmax-notice .form-section__num {
  background: var(--signal);
  color: var(--ink);
  border-color: var(--signal);
}
.pmax-notice p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.6;
  font-size: 0.92rem;
}

/* ============================================================
   FORM SUBMIT & RESULT
   ============================================================ */
.form-submit {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule);
}
.result-box {
  background: var(--paper);
  border: 2px solid var(--success);
  border-radius: var(--radius);
  padding: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  white-space: pre-wrap;
  color: var(--ink-soft);
  max-height: 400px;
  overflow-y: auto;
}
.result-box.is-error { border-color: var(--error); }
.result-box pre { margin: 0; }

/* ============================================================
   ERROR & STATUS
   ============================================================ */
.error-banner {
  color: var(--error);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.step-card,
.form-section { animation: fadeUp 400ms ease backwards; }
.form-section:nth-child(2) { animation-delay: 80ms; }
.form-section:nth-child(3) { animation-delay: 160ms; }
.form-section:nth-child(4) { animation-delay: 240ms; }
.form-section:nth-child(5) { animation-delay: 320ms; }
