:root {
  --ink: #10211b;
  --muted: #65736d;
  --line: #dbe4df;
  --paper: #f6f8f5;
  --card: #ffffff;
  --green: #1d5a45;
  --green-dark: #123d30;
  --lime: #d7f06a;
  --soft-green: #e9f3ed;
  --red: #b44343;
  --amber: #946b16;
  --shadow: 0 18px 50px rgba(16, 33, 27, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 85% 0%, rgba(215, 240, 106, 0.13), transparent 24rem),
    var(--paper);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.shell { max-width: 1440px; margin: 0 auto; padding: 0 38px; }

.topbar {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 50%; background: var(--green); color: white;
  font-weight: 900; letter-spacing: -0.04em;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { color: var(--muted); margin-top: 2px; }
.top-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.pulse, .status-dot { width: 8px; height: 8px; border-radius: 50%; background: #50a77e; box-shadow: 0 0 0 4px rgba(80, 167, 126, 0.12); }

.hero {
  min-height: 330px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 70px;
  align-items: center;
  padding: 64px 0 56px;
}

.eyebrow { margin: 0 0 10px; text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 800; color: var(--green); }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 780px; margin-bottom: 18px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(44px, 6vw, 76px); line-height: .98; letter-spacing: -.045em; font-weight: 500; }
.hero-copy { max-width: 680px; margin-bottom: 0; color: var(--muted); font-size: 18px; line-height: 1.6; }

.pipeline { display: flex; align-items: center; padding: 22px 24px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.7); }
.pipeline i { width: 28px; height: 1px; margin: 0 8px; background: var(--line); }
.pipeline-step { display: grid; justify-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.pipeline-step span { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: white; }
.pipeline-step.active { color: var(--green); }
.pipeline-step.active span { background: var(--green); color: white; border-color: var(--green); }

.section { padding: 58px 0 64px; border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.section-heading h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 38px; font-weight: 500; letter-spacing: -.025em; }
.section-heading > p { max-width: 520px; margin: 0 0 4px; color: var(--muted); text-align: right; line-height: 1.5; }

.connection-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }
.connection-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; padding: 26px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.provider-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 15px; color: white; font-weight: 900; }
.provider-icon.grok { background: #111; }
.provider-icon.openai { background: #10a37f; }
.provider-icon.gemini { background: linear-gradient(135deg, #4285f4, #9b72cb, #d96570); }
.provider-icon.shotstack { background: #6c46da; }
.provider-icon.oneup { background: #f36b3d; }
.connection-title { min-height: 56px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.connection-title h3 { margin-bottom: 4px; font-size: 18px; }
.connection-title p { margin: 0; color: var(--muted); font-size: 14px; }
label { display: block; margin-bottom: 7px; color: #34453e; font-size: 13px; font-weight: 750; }
.secret-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
input, textarea, select { width: 100%; border: 1px solid #cad7d0; border-radius: 11px; background: white; color: var(--ink); outline: none; transition: border-color .2s, box-shadow .2s; }
input, select { height: 46px; padding: 0 13px; }
textarea { padding: 13px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29, 90, 69, .1); }

.button { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 800; color: var(--ink); transition: transform .15s, background .15s, opacity .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { background: var(--soft-green); color: var(--green-dark); white-space: nowrap; }
.button.ghost { border: 1px solid var(--line); background: white; }
.button.large { min-width: 190px; padding: 15px 20px; }
.text-button { margin-top: 15px; padding: 0; border: 0; background: none; color: var(--green); font-weight: 800; }
.text-button span { margin-left: 4px; }
.production-key { position: relative; margin-top: 15px; padding-top: 14px; border-top: 1px solid var(--line); }
.production-key summary { color: var(--green); font-size: 12px; font-weight: 800; cursor: pointer; }
.production-key[open] summary { margin-bottom: 14px; }
.production-key .sub-badge { position: absolute; top: 9px; right: 0; }
.drive-destination { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.drive-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.drive-heading strong, .drive-heading small { display: block; }
.drive-heading small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.drive-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: #eaf1ff; color: #3367d6; font-weight: 900; }
.drive-destination > p { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.connection-note { margin: 15px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.badge { display: inline-flex; align-items: center; min-height: 27px; padding: 4px 9px; border-radius: 100px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge.muted { background: #eef1ef; color: #6e7a75; }
.badge.good { background: #dff2e7; color: #226a4d; }
.badge.warn { background: #f7edcf; color: var(--amber); }
.badge.bad { background: #f8e3e3; color: var(--red); }
.badge.soft { background: rgba(255,255,255,.14); color: white; }

.studio-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr); gap: 24px; align-items: stretch; }
.production-form, .preview-panel { border: 1px solid var(--line); border-radius: 22px; background: var(--card); box-shadow: var(--shadow); }
.production-form { padding: 30px; }
.sheet-source-note { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 22px; padding: 14px; border: 1px solid #cfe0d7; border-radius: 13px; background: #f2f8f4; }
.sheet-source-note strong { display: block; margin-bottom: 3px; color: var(--green-dark); font-size: 13px; }
.sheet-source-note p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.sheet-source-icon { flex: 0 0 auto; width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; background: var(--green); color: white; font-weight: 900; }
.fixed-template-card { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 16px; align-items: center; margin: -8px 0 22px; padding: 13px; border: 1px solid #c8dfd2; border-radius: 14px; background: #fbfcfb; }
.fixed-template-card img { width: 92px; height: 126px; display: block; object-fit: cover; object-position: center bottom; border-radius: 10px; background: #f1eee7; }
.fixed-template-card strong { display: block; margin: 8px 0 4px; color: var(--green-dark); font-size: 13px; }
.fixed-template-card p { margin: 0 0 7px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.fixed-template-card a { color: var(--green); font-size: 11px; font-weight: 800; text-decoration: none; }
.fixed-template-card.template-missing { border-color: #ecd2d2; background: #fff8f8; }
.field { margin-bottom: 20px; }
.field-meta { display: flex; justify-content: space-between; gap: 20px; margin-top: 7px; color: var(--muted); font-size: 12px; }
.field-grid { display: grid; gap: 12px; }
.field-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field-grid .field { margin-bottom: 0; }
.sheet-row-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.sheet-selection { display: grid; gap: 9px; margin: -5px 0 22px; }
.empty-selection { padding: 14px; border: 1px dashed #bdcbc4; border-radius: 12px; color: var(--muted); font-size: 12px; text-align: center; }
.sheet-row-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: #fbfcfb; }
.sheet-row-card.ready { border-color: #c8dfd2; background: #f3f8f5; }
.sheet-row-card.missing { border-color: #ecd2d2; background: #fff8f8; }
.sheet-row-number { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--green); color: white; font-size: 12px; font-weight: 900; }
.sheet-row-card strong, .sheet-row-card small { display: block; }
.sheet-row-card strong { font-size: 13px; }
.sheet-row-card small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.sheet-row-card .badge { max-width: 260px; height: auto; white-space: normal; text-align: center; }
.image-generator-card { margin: 0 0 24px; padding: 18px; border: 1px solid #b9d8cb; border-radius: 15px; background: linear-gradient(135deg, #f2faf6, #fbfcfb); }
.image-generator-card > div:first-child strong { display: block; margin: 4px 0; color: var(--green-dark); }
.image-generator-card > div:first-child p { margin: 0 0 14px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.image-generator-controls { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; gap: 12px; align-items: end; }
.field.compact { margin: 0; }
.mini-confirmation { display: flex; align-items: center; gap: 8px; min-height: 46px; margin: 0; font-size: 12px; }
.mini-confirmation input { width: 17px; height: 17px; accent-color: var(--green); }
.image-generation-results { display: grid; gap: 7px; margin-top: 12px; }
.generation-progress, .generation-error { margin: 0; padding: 10px; border-radius: 9px; font-size: 12px; }
.generation-progress { background: #eaf3ef; color: var(--green-dark); }
.generation-error { background: #fff0f0; color: var(--red); }
.generation-result { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 9px 11px; border-radius: 9px; background: white; font-size: 11px; }
.generation-result.created { border-left: 3px solid var(--green); }
.generation-result.error { border-left: 3px solid var(--red); }
.generation-result.skipped { border-left: 3px solid #8b9892; }
.generation-result a { color: var(--green); font-weight: 800; text-decoration: none; }

.environment-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 24px 0 18px; }
.video-provider-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 4px 0 20px; }
.video-provider-choice label { position: relative; display: flex; align-items: center; min-height: 72px; margin: 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px; cursor: pointer; }
.video-provider-choice input { width: 18px; height: 18px; margin: 0 11px 0 0; accent-color: var(--green); }
.video-provider-choice strong, .video-provider-choice small { display: block; }
.video-provider-choice small { margin-top: 3px; color: var(--muted); font-weight: 500; }
.video-provider-choice label:has(input:checked) { border-color: var(--green); background: #f3f8f5; box-shadow: inset 0 0 0 1px var(--green); }
.environment-choice label { position: relative; display: flex; align-items: center; min-height: 72px; margin: 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px; cursor: pointer; }
.environment-choice input { width: 18px; height: 18px; margin: 0 11px 0 0; accent-color: var(--green); }
.environment-choice strong, .environment-choice small { display: block; }
.environment-choice small { margin-top: 3px; color: var(--muted); font-weight: 500; }
.environment-choice label:has(input:checked) { border-color: var(--green); background: #f3f8f5; box-shadow: inset 0 0 0 1px var(--green); }

.confirmation { display: flex; align-items: flex-start; gap: 11px; margin: 0; padding: 14px; border-radius: 12px; background: #f7f4e8; color: #5a4b1e; font-weight: 600; line-height: 1.45; }
.confirmation input { flex: 0 0 auto; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--green); }
.form-actions { display: flex; align-items: center; gap: 18px; margin-top: 24px; }
.form-actions p { max-width: 330px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.preview-panel { overflow: hidden; background: #10261f; color: white; padding: 18px; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 3px 2px 14px; font-size: 13px; font-weight: 800; }
.video-preview { position: relative; isolation: isolate; min-height: 500px; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; border-radius: 16px; background: linear-gradient(#91c4d3 0 46%, #4f8652 46% 100%); text-align: center; }
.video-preview.landscape { min-height: 320px; margin-top: 90px; }
.video-preview.square { min-height: 410px; margin-top: 45px; }
.preview-sky { position: absolute; z-index: -3; inset: 0 0 54%; background: linear-gradient(#79b6cb, #dfe9d3); }
.preview-fairway { position: absolute; z-index: -2; left: 50%; bottom: -10%; width: 60%; height: 65%; transform: translateX(-50%); background: linear-gradient(90deg, #376e3f, #80a95e 48%, #376e3f); clip-path: polygon(37% 0, 63% 0, 100% 100%, 0 100%); }
.preview-ball { position: absolute; z-index: -1; left: 50%; bottom: 18%; width: 12px; height: 12px; transform: translateX(-50%); border-radius: 50%; background: white; box-shadow: 0 4px 6px rgba(0,0,0,.28); }
.cover-chip { padding: 6px 10px; border-radius: 100px; background: var(--lime); color: var(--green-dark); text-transform: uppercase; letter-spacing: .1em; font-size: 10px; font-weight: 900; }
.video-preview h3 { max-width: 380px; margin: 16px 0 10px; padding: 13px 18px; border-radius: 14px; background: rgba(16, 38, 31, .76); color: white; font-size: clamp(25px, 3vw, 40px); line-height: 1.05; letter-spacing: -.035em; text-shadow: 0 3px 14px rgba(0,0,0,.45); }
.video-preview p { margin: 0; color: rgba(255,255,255,.86); font-size: 12px; }
.preview-note { display: flex; align-items: center; gap: 9px; padding: 16px 3px 1px; color: rgba(255,255,255,.72); font-size: 11px; line-height: 1.4; }

.jobs-list { display: grid; gap: 12px; }
.empty-state { padding: 54px 20px; border: 1px dashed #bdcbc4; border-radius: 18px; text-align: center; color: var(--muted); }
.empty-state > span { width: 44px; height: 44px; display: grid; place-items: center; margin: 0 auto 13px; border-radius: 50%; background: var(--soft-green); color: var(--green); }
.empty-state h3 { margin-bottom: 6px; color: var(--ink); }
.empty-state p { margin: 0; }

.job-card { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(260px, 1.4fr) minmax(220px, 1fr); align-items: center; gap: 24px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.job-title h3 { margin: 0 0 6px; font-size: 16px; }
.job-title p, .job-meta { margin: 0; color: var(--muted); font-size: 12px; }
.job-source { margin-top: 7px !important; color: var(--green) !important; font-weight: 750; }
.progress-track { height: 8px; overflow: hidden; border-radius: 100px; background: #e8eeea; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--green); transition: width .4s ease; }
.progress-copy { display: flex; justify-content: space-between; gap: 16px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.job-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.job-actions a { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--green); text-decoration: none; font-size: 12px; font-weight: 800; }
.job-action-button { min-height: 38px; padding: 8px 12px; border: 1px solid var(--green); border-radius: 9px; background: var(--soft-green); color: var(--green-dark); font-size: 12px; font-weight: 800; }
.job-error { margin-top: 8px; color: var(--red); font-size: 12px; }

.oneup-form { padding: 28px; border: 1px solid var(--line); border-radius: 22px; background: white; box-shadow: var(--shadow); }
.oneup-setup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.fixed-category { min-height: 46px; display: flex; align-items: center; gap: 9px; padding: 0 13px; border: 1px solid #c8dfd2; border-radius: 11px; background: #f3f8f5; }
.fixed-category strong { color: var(--green-dark); font-size: 13px; }
.fixed-category small { margin-left: auto; color: var(--muted); font-size: 11px; }
.draft-media-map { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 2px 0 22px; }
.draft-media-map span { padding: 13px 15px; border-radius: 12px; background: var(--soft-green); color: var(--green-dark); font-size: 12px; }
.draft-media-map strong { display: block; margin-bottom: 3px; }
.channel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.channel-card { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: #fbfcfb; }
.channel-card label:not(:first-of-type) { margin-top: 14px; }
.channel-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.channel-heading h3 { margin: 0 0 3px; font-size: 16px; }
.channel-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.channel-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: white; font-weight: 900; }
.channel-icon.fb { background: #1877f2; }
.channel-icon.ig { background: linear-gradient(135deg, #7b3fbd, #e04666, #f5a542); }
.channel-icon.tt { background: #111; text-shadow: 2px 1px #25f4ee, -2px -1px #fe2c55; }
.channel-icon.yt { background: #ff0033; }
.channel-icon.pin { background: #bd081c; }
.oneup-confirmation { margin-top: 20px; }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 30px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: min(420px, calc(100vw - 48px)); padding: 14px 17px; border-radius: 12px; background: var(--ink); color: white; box-shadow: 0 18px 40px rgba(0,0,0,.2); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #7e3030; }

@media (max-width: 1060px) {
  .hero { grid-template-columns: 1fr; gap: 30px; }
  .pipeline { width: fit-content; }
  .connection-grid, .studio-grid { grid-template-columns: 1fr; }
  .preview-panel { max-width: 520px; width: 100%; justify-self: center; }
  .field-grid.four { grid-template-columns: repeat(2, 1fr); }
  .channel-grid { grid-template-columns: 1fr; }
  .job-card { grid-template-columns: 1fr 1.2fr; }
  .job-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 680px) {
  .shell { padding: 0 18px; }
  .topbar { height: 72px; }
  .top-status { font-size: 0; }
  .hero { min-height: 0; padding: 46px 0 44px; }
  h1 { font-size: 46px; }
  .hero-copy { font-size: 16px; }
  .pipeline { width: 100%; justify-content: space-between; padding: 17px 12px; overflow-x: auto; }
  .pipeline i { min-width: 10px; margin: 0 3px; }
  .section { padding: 44px 0; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: 12px; text-align: left; }
  .connection-card { grid-template-columns: 1fr; padding: 20px; }
  .provider-icon { width: 44px; height: 44px; }
  .secret-row { grid-template-columns: 1fr; }
  .sheet-row-entry { grid-template-columns: 1fr; }
  .image-generator-controls, .generation-result { grid-template-columns: 1fr; }
  .fixed-template-card { grid-template-columns: 72px minmax(0, 1fr); align-items: start; }
  .fixed-template-card img { width: 72px; height: 104px; }
  .sheet-row-card { grid-template-columns: auto minmax(0, 1fr); }
  .sheet-row-card .badge { grid-column: 1 / -1; justify-self: start; max-width: none; }
  .field-grid.four { grid-template-columns: 1fr; }
  .oneup-setup-grid, .draft-media-map { grid-template-columns: 1fr; }
  .fixed-category { flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .fixed-category small { flex-basis: 100%; margin-left: 17px; }
  .oneup-form { padding: 20px; }
  .environment-choice { grid-template-columns: 1fr; }
  .video-provider-choice { grid-template-columns: 1fr; }
  .production-form { padding: 20px; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .job-card { grid-template-columns: 1fr; gap: 16px; }
  .job-actions { grid-column: auto; justify-content: flex-start; }
  footer { flex-direction: column; }
}
