/* AEO Social Studio 360 — visual layer. Loaded after the legacy inline styles and overrides them. */
:root {
  --red: #b0304a; --deep: #6d1d34; --accent: #b0304a; --accent-soft: #f6e8ec;
  --ink: #1d1a1c; --muted: #6f676b; --line: #ebe5e7; --paper: #f7f5f3; --card: #ffffff;
  --green: #1f6b4f; --green-soft: #e3f2ea; --amber: #8a5a00; --amber-soft: #fbf0d9;
  --side: #1c181b; --side-2: #26202a; --side-ink: #eee6ea; --side-muted: #a89aa1;
  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(29, 20, 25, .05), 0 4px 16px rgba(29, 20, 25, .05);
  --shadow-lg: 0 10px 40px rgba(29, 20, 25, .12);
  --ring: 0 0 0 3px rgba(176, 48, 74, .22);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.darkmode {
  --paper: #131114; --card: #1d1a1e; --ink: #f2edf0; --muted: #a99ea4; --line: #2f2930;
  --accent-soft: #3a1f29; --green-soft: #18332a; --green: #7fd1ad; --amber-soft: #3a2d12; --amber: #f1c46b;
  --side: #0f0d10; --side-2: #1b171c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ---------- base ---------- */
html { -webkit-text-size-adjust: 100%; }
body { font: 14px/1.6 var(--font); background: var(--paper); color: var(--ink); -webkit-font-smoothing: antialiased; }
h1 { letter-spacing: -.035em; font-weight: 780; }
h2 { letter-spacing: -.02em; font-weight: 720; }
h3 { font-weight: 680; }
a { color: var(--red); text-underline-offset: 2px; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: none; box-shadow: var(--ring); }

button { border-radius: var(--radius-sm); border-color: var(--line); background: var(--card); color: var(--ink); font-weight: 560; transition: border-color .15s, background .15s, box-shadow .15s, transform .05s; }
button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--red) 55%, var(--line)); }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary { background: linear-gradient(180deg, color-mix(in srgb, var(--red) 92%, white), var(--red)); border-color: var(--red); color: #fff; box-shadow: 0 1px 2px rgba(110, 20, 40, .25); }
button.primary:hover:not(:disabled) { background: var(--deep); border-color: var(--deep); }
button.danger { color: var(--red); }
button.linklike { border: 0; background: none; padding: 0; color: var(--red); text-decoration: underline; font-weight: 600; }
input, select, textarea { border-radius: var(--radius-sm); border-color: var(--line); background: var(--card); color: var(--ink); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
label { color: color-mix(in srgb, var(--ink) 85%, var(--muted)); }
small, .muted { color: var(--muted); }

/* ---------- surfaces ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.panel.stat { padding: 16px 18px; }
.stat small { text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; font-weight: 700; }
.stat strong { font-size: 30px; font-weight: 780; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.item { border-color: var(--line); }
.callout, .notice { background: var(--accent-soft); border-left: 3px solid var(--red); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink); }
.badge { border-radius: 999px; background: var(--accent-soft); color: var(--deep); font-weight: 650; letter-spacing: .01em; }
.darkmode .badge { color: #f3c3cf; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.danger { background: #fde4e4; color: #a01d1d; }
.darkmode .badge.danger { background: #4a1c1c; color: #ffb4b4; }
.step, .day { background: var(--card); }
.day div { background: var(--accent-soft); }
table th { color: var(--muted); letter-spacing: .05em; }
table tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
dialog { background: var(--card); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-lg); border-radius: 18px; }
dialog::backdrop { background: rgba(15, 10, 14, .55); backdrop-filter: blur(3px); }
.codebox { background: #17141a; }
.hero { border-radius: 20px; background: radial-gradient(120% 140% at 0% 0%, #8e2a45 0%, #6d1d34 45%, #3d1322 100%); box-shadow: var(--shadow); position: relative; overflow: hidden; padding: 32px; }
.hero::after { content: ""; position: absolute; inset: auto -80px -120px auto; width: 340px; height: 340px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 196, 210, .22), transparent 65%); pointer-events: none; }
.hero h1 { font-size: clamp(28px, 4.2vw, 44px); }
.wizhero { background: radial-gradient(120% 160% at 0% 0%, #b0304a 0%, #7a2039 50%, #2e0f1a 100%); }
.poster { box-shadow: var(--shadow-lg); }
.v5card { border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card); border-color: var(--line); transition: transform .15s, box-shadow .15s; }
.v5card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.v5portrait { border-radius: 12px; }
.mini-chart span { background: linear-gradient(180deg, var(--red), var(--deep)); }

/* Legacy dark-mode patches that hard-coded light colours */
.darkmode .panel, .darkmode input, .darkmode select, .darkmode textarea, .darkmode button:not(.primary), .darkmode .day, .darkmode .callout, .darkmode .step, .darkmode .v5card, .darkmode dialog { background: var(--card); color: var(--ink); }
.darkmode .callout, .darkmode .notice { background: var(--accent-soft); }
.darkmode .day div, .darkmode .wizstage span:first-child { background: var(--accent-soft); }
.darkmode .wiznotice, .darkmode .wizgrid details { border-color: var(--line); }

/* ---------- layout: sidebar ---------- */
.layout { grid-template-columns: 252px minmax(0, 1fr); }
aside { background: linear-gradient(180deg, var(--side) 0%, var(--side-2) 100%); padding: 22px 14px 18px; border-right: 1px solid rgba(255, 255, 255, .04); scrollbar-width: thin; scrollbar-color: #3a3138 transparent; }
aside .brand { font-size: 19px; letter-spacing: -.03em; display: flex; align-items: center; gap: 9px; }
aside .brand::before { content: ""; width: 26px; height: 26px; border-radius: 8px; flex: none; background: url(icon.svg) center/cover; }
aside > small:first-of-type { display: block; margin-top: 4px; color: var(--side-muted); }
aside label { color: var(--side-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; margin-top: 22px; }
aside select { background: #2c252b; border-color: #3d3439; color: #fff; }
aside .new { border-color: #3d3439; color: var(--side-ink); background: rgba(255, 255, 255, .02); }
aside .new:hover { background: rgba(255, 255, 255, .06); }
nav { margin-top: 18px; }
aside nav button { color: var(--side-ink); opacity: .86; padding: 7px 10px; border-radius: 8px; font-weight: 500; font-size: 13.5px; position: relative; }
aside nav button:hover:not(.active) { background: rgba(255, 255, 255, .06); opacity: 1; }
aside nav button.active { background: rgba(176, 48, 74, .92); color: #fff; opacity: 1; box-shadow: 0 2px 10px rgba(176, 48, 74, .35); }
aside nav button.navcta { font-weight: 700; margin-bottom: 4px; border: 1px solid rgba(255, 180, 200, .25); }
aside nav button.navcta:not(.active) { background: linear-gradient(90deg, rgba(176, 48, 74, .28), rgba(176, 48, 74, .08)); }
.darkmode aside nav button:not(.active) { background: transparent; color: var(--side-ink); }
.darkmode aside nav button:hover:not(.active) { background: rgba(255, 255, 255, .06); }
.darkmode aside nav button.navcta:not(.active) { background: linear-gradient(90deg, rgba(176, 48, 74, .28), rgba(176, 48, 74, .08)); }
.darkmode aside nav button.active { background: rgba(176, 48, 74, .92); color: #fff; }
.darkmode aside .new { background: rgba(255, 255, 255, .02); color: var(--side-ink); }
.darkmode .pager button.active { background: var(--red); color: #fff; }
.v5navhead { color: var(--side-muted); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; margin: 18px 10px 6px; }
.navfoot { display: block; margin: 22px 10px 0; color: #7f727a !important; font-size: 11px; line-height: 1.5; }

/* ---------- layout: top bar ---------- */
.workspace { padding: 22px clamp(14px, 3vw, 40px) 40px; }
.top { position: sticky; top: 0; z-index: 20; margin: -22px calc(-1 * clamp(14px, 3vw, 40px)) 20px; padding: 14px clamp(14px, 3vw, 40px);
  background: color-mix(in srgb, var(--paper) 82%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.top .toptitle { flex: 1; min-width: 0; }
.top h2 { margin: 0; font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .actions { align-items: center; justify-content: flex-end; }
.top .actions button { padding: 7px 12px; font-size: 13px; }
#userBadge5:empty { display: none; }
#feedback { border-radius: var(--radius-sm); }
.menutoggle { display: none; font-size: 18px; line-height: 1; padding: 8px 11px; }

.v5tag { background: var(--accent-soft); color: var(--deep); }
.darkmode .v5tag { color: #f3c3cf; }

/* ---------- auth ---------- */
.auth { background: var(--paper); color: var(--ink); }
.darkmode .auth-card { background: var(--card); color: var(--ink); }
.auth-hero { background: radial-gradient(130% 120% at 0% 0%, #5a1a2d 0%, #24161d 55%, #120d10 100%) !important; }
.auth-hero h1 { letter-spacing: -.045em; }
.auth-main { background: var(--paper); }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); }
.auth-card input { padding: 12px; }
.auth-card button.primary { width: 100%; padding: 12px; margin-top: 10px; font-size: 15px; }
#loginMsg5:not(:empty) { color: #a01d1d; background: #fde8e8; padding: 8px 10px; border-radius: 8px; }
.darkmode #loginMsg5:not(:empty) { background: #4a1c1c; color: #ffc6c6; }

/* ---------- wizard ---------- */
.wizgrid details, .wiznotice { border-radius: 12px; background: color-mix(in srgb, var(--paper) 55%, var(--card)); }
.wizstage.done span:first-child { background: var(--green-soft); color: var(--green); }
#wizPrompt { min-height: 140px; font-size: 15px; line-height: 1.55; }
#wizRun { padding: 12px 20px; font-size: 15px; }

/* ---------- responsive ---------- */
@media (max-width: 850px) {
  .layout { grid-template-columns: 1fr; }
  aside { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100vh; z-index: 60; transform: translateX(-102%); transition: transform .22s ease; padding: 18px 12px; box-shadow: var(--shadow-lg); }
  aside nav { display: block; overflow: visible; }
  aside nav button { width: 100%; white-space: normal; }
  aside .new { width: 100%; }
  body.navopen aside { transform: none; }
  body.navopen::after { content: ""; position: fixed; inset: 0; background: rgba(10, 6, 9, .5); z-index: 50; }
  .menutoggle { display: inline-block; }
  .top { gap: 10px; flex-wrap: wrap; }
  .top .actions { width: 100%; justify-content: flex-start; }
}
@media (max-width: 490px) {
  .hero { padding: 22px; border-radius: 16px; }
  .top .actions button { padding: 6px 10px; font-size: 12px; }
  .stat strong { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { aside, .top, #feedback { display: none !important; } .layout { display: block; } }
