:root {
  color-scheme: dark;
  --bg: #121412;
  --surface: #1a1d1a;
  --surface-raised: #222622;
  --line: #333833;
  --text: #f0f2ec;
  --muted: #a7aea4;
  --green: #b8f34a;
  --green-dark: #263318;
  --red: #ff7a70;
  --amber: #f5c45b;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 0; overflow-x: hidden; }
body { margin: 0; min-width: 0; min-height: 100vh; overflow-x: hidden; background: radial-gradient(circle at 15% -10%, #29321e 0, transparent 35rem), var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; max-width: 1180px; margin: 0 auto; padding: 14px 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 18px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--green); color: #11160b; font-family: Georgia, serif; font-size: 22px; font-style: italic; }
.account { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }

main { max-width: 1180px; margin: 0 auto; padding: 40px 24px 80px; }
.login-view { min-height: calc(100vh - 150px); display: grid; place-items: center; }
.hero-card { max-width: 720px; padding: clamp(30px, 7vw, 72px); border: 1px solid var(--line); border-radius: 28px; background: linear-gradient(145deg, rgba(34, 38, 34, .96), rgba(21, 24, 21, .96)); box-shadow: 0 30px 90px rgba(0, 0, 0, .3); }
h1, h2, p { margin-top: 0; }
h1 { max-width: 820px; margin-bottom: 12px; font-size: clamp(34px, 7vw, 70px); line-height: .98; letter-spacing: -.055em; }
h2 { margin-bottom: 0; font-size: 22px; letter-spacing: -.025em; }
.lead { max-width: 590px; margin: 24px 0 32px; color: var(--muted); font-size: 18px; line-height: 1.6; }
.eyebrow { margin-bottom: 8px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.fine-print { margin: 18px 0 0; color: var(--muted); font-size: 12px; }

.app-shell { display: grid; min-width: 0; gap: 24px; }
.intro-row { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.intro-row h1 { margin: 0; }
.safety-pill { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid #3d4a2a; border-radius: 999px; color: #cfdfa9; background: rgba(38, 51, 24, .55); font-size: 12px; }
.safety-pill span { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(184, 243, 74, .1); }
.panel { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(26, 29, 26, .88); box-shadow: 0 18px 45px rgba(0, 0, 0, .13); }
.composer { display: grid; gap: 22px; }
.field-row { display: flex; align-items: end; gap: 18px; }
.grow { flex: 1; }
.field { display: grid; gap: 9px; }
.field > span { color: #d8dcd4; font-size: 13px; font-weight: 700; }
.field small { margin-left: 5px; color: var(--muted); font-weight: 450; }
select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; outline: none; background: #121512; color: var(--text); transition: border-color .15s, box-shadow .15s; }
select { min-height: 46px; padding: 0 42px 0 13px; }
textarea { min-height: 300px; padding: 15px; resize: vertical; font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; line-height: 1.65; }
select:focus, textarea:focus { border-color: #73992d; box-shadow: 0 0 0 3px rgba(184, 243, 74, .09); }
.toggle-field { display: flex; align-items: center; gap: 9px; min-height: 46px; color: var(--muted); font-size: 13px; cursor: pointer; }
.toggle-field input { position: absolute; opacity: 0; pointer-events: none; }
.toggle { position: relative; width: 38px; height: 22px; border-radius: 999px; background: #3a403a; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; transition: transform .15s; }
.toggle-field input:checked + .toggle { background: #6f942b; }
.toggle-field input:checked + .toggle::after { transform: translateX(16px); }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.composer-footer p { margin: 0; color: var(--muted); font-size: 13px; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; padding: 0 17px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-raised); color: var(--text); text-decoration: none; font-weight: 750; cursor: pointer; }
.button:hover { filter: brightness(1.08); }
.button:disabled { cursor: wait; opacity: .55; }
.button.primary { border-color: var(--green); background: var(--green); color: #151a0f; }
.button.danger { border-color: #5f3733; color: #ffaaa3; background: #2b1d1b; }
.button.large { min-height: 50px; padding: 0 23px; }
.button.small { min-height: 34px; padding: 0 12px; font-size: 12px; }
.text-button, .icon-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.text-button:hover, .icon-button:hover { color: var(--text); }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; font-size: 20px; }

.plan-card { padding: 24px; border: 1px solid #52672c; border-radius: var(--radius); background: linear-gradient(140deg, rgba(38, 51, 24, .8), rgba(26, 29, 26, .95)); }
.plan-top, .section-heading, .plan-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 20px 0; }
.metric { padding: 14px; border: 1px solid rgba(184, 243, 74, .16); border-radius: 12px; background: rgba(0, 0, 0, .12); }
.metric strong { display: block; font-size: 26px; letter-spacing: -.04em; }
.metric span { color: var(--muted); font-size: 11px; }
.step-list { display: grid; gap: 7px; margin: 0 0 20px; padding: 0; list-style: none; }
.step-list li { display: flex; justify-content: space-between; gap: 12px; color: #d8ddd2; font-size: 13px; }
.step-list strong { color: var(--green); }
.content-grid { display: grid; min-width: 0; grid-template-columns: 1.15fr .85fr; gap: 24px; }
.section-heading { margin-bottom: 18px; }
.count-badge, .status { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 999px; background: var(--surface-raised); color: var(--muted); font-size: 11px; font-weight: 750; }
.status.applied { background: var(--green-dark); color: var(--green); }
.status.failed { background: #35221f; color: var(--red); }
.status.undone { color: #c1c7bd; }
.stack, .playlist-list { display: grid; gap: 10px; }
.plan-row, .playlist-row { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.plan-row:first-child, .playlist-row:first-child { border-top: 0; }
.plan-row h3, .playlist-row strong { margin: 0; font-size: 14px; }
.plan-row p, .playlist-row span { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.plan-row > div:first-child, .playlist-row > div:first-child { min-width: 0; }
.plan-row h3, .playlist-row strong, .step-list span { overflow-wrap: anywhere; }
.row-actions { display: flex; flex: none; flex-wrap: wrap; gap: 7px; }
.muted { color: var(--muted); font-size: 13px; }
.empty { padding: 20px 0; text-align: center; color: var(--muted); }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; max-width: min(420px, calc(100vw - 32px)); padding: 14px 17px; border: 1px solid var(--line); border-radius: 12px; background: #262a26; box-shadow: 0 18px 50px rgba(0, 0, 0, .35); font-size: 13px; }
.toast.error { border-color: #69403b; color: #ffc0ba; }

@media (max-width: 760px) {
  .topbar { min-height: 62px; padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); }
  main { padding: 24px max(16px, env(safe-area-inset-right)) calc(56px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .account span { display: none; }
  .intro-row { align-items: start; flex-direction: column; }
  .intro-row h1 { font-size: clamp(36px, 12vw, 42px); }
  .safety-pill { width: 100%; white-space: normal; }
  .panel, .plan-card { padding: 18px; }
  .field-row, .composer-footer { align-items: stretch; flex-direction: column; }
  .field small { display: block; margin: 3px 0 0; }
  select, textarea { font-size: 16px; }
  textarea { min-height: min(360px, 48vh); }
  .composer-footer .button { width: 100%; }
  .toggle-field { min-height: 36px; }
  .toggle { flex: 0 0 38px; }
  .content-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric:last-child { grid-column: 1 / -1; }
  .plan-top, .plan-actions { align-items: start; flex-direction: column; }
  .plan-actions .button { width: 100%; }
  .step-list li { align-items: start; }
  .step-list span { min-width: 0; }
  .step-list strong { flex: none; }
  .plan-row { align-items: stretch; flex-direction: column; }
  .row-actions { width: 100%; align-items: center; }
  .row-actions .status { margin-right: auto; }
  .row-actions .button { min-height: 44px; }
  .button, .icon-button, .text-button { min-height: 44px; }
  .toast { right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); left: max(16px, env(safe-area-inset-left)); max-width: none; }
}

@media (max-width: 380px) {
  .hero-card { padding: 28px 22px; border-radius: 22px; }
  h1 { font-size: 34px; }
  .panel, .plan-card { padding: 16px; }
  .metrics { grid-template-columns: 1fr; }
  .metric:last-child { grid-column: auto; }
}
