:root {
  color-scheme: light;
  --bg: #f4f7f4;
  --bg-soft: #f8faf8;
  --panel: #ffffff;
  --panel-muted: #f8faf8;
  --line: #e2e9e2;
  --line-strong: #d2ddd3;
  --ink: #16251b;
  --muted: #647269;
  --quiet: #8b988f;
  --accent: #86bb42;
  --accent-strong: #5f9630;
  --accent-soft: #edf7dc;
  --accent-ink: #274317;
  --orange: #c98246;
  --red: #c95f58;
  --blue: #548eae;
  --mono: "DM Mono", monospace;
  --display: "Space Grotesk", sans-serif;
  --body: "Manrope", "PingFang SC", sans-serif;
  --shadow-sm: 0 2px 8px rgba(38, 66, 42, .04);
  --shadow-md: 0 12px 30px rgba(38, 66, 42, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 88% 7%, rgba(171, 214, 119, .15), transparent 25rem),
    linear-gradient(180deg, #f8faf8 0%, var(--bg) 62%, #f2f6f2 100%);
  color: var(--ink);
  font: 14px/1.5 var(--body);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .42;
  background-image: linear-gradient(rgba(108, 142, 113, .045) 1px, transparent 1px), linear-gradient(90deg, rgba(108, 142, 113, .045) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .55), transparent 72%);
}

.grain { display: none; }

.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  z-index: 2;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: 252px;
  padding: 23px 16px 18px;
  background: rgba(255, 255, 255, .9);
  border-right: 1px solid var(--line);
  box-shadow: 5px 0 24px rgba(37, 62, 42, .025);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px 25px;
  color: var(--ink);
  font: 700 18px var(--display);
  letter-spacing: -.05em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid #79a93e;
  border-radius: 9px;
  background: linear-gradient(145deg, #b6df75, #8bc64b);
  color: #1f3717;
  font-size: 17px;
  box-shadow: 0 4px 9px rgba(103, 153, 46, .18);
}

.brand-dot { width: 5px; height: 5px; margin: -16px 0 0 -5px; border-radius: 50%; background: var(--orange); }

.workspace-switcher {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 24px;
  padding: 10px 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-muted);
  box-shadow: var(--shadow-sm);
}

.workspace-switcher b, .workspace-switcher small { display: block; }
.workspace-switcher b { color: var(--ink); font-size: 11px; font-weight: 700; }
.workspace-switcher small { margin-top: 1px; color: var(--quiet); font: 9px var(--mono); }

.workspace-avatar, .profile-avatar {
  display: grid;
  place-items: center;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font: 11px var(--mono);
}

.workspace-avatar { width: 26px; height: 26px; border: 1px solid #d7eac3; border-radius: 8px; }
.profile-avatar { width: 28px; height: 28px; border: 1px solid #d8e8d3; border-radius: 50%; font-size: 9px; }
.chevron { margin-left: auto; color: var(--quiet); font-size: 16px; }

.nav { display: grid; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: .2s ease;
}

.nav-item:hover { background: #f2f7f1; color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-strong); box-shadow: inset 3px 0 var(--accent); }
.nav-icon { width: 16px; color: currentColor; text-align: center; font-size: 17px; }
.nav-item kbd, .nav-count { margin-left: auto; color: var(--quiet); font: 10px var(--mono); }

.sidebar-spacer { flex: 1; }

.system-card {
  padding: 13px 13px 11px;
  border: 1px solid #dce8da;
  border-radius: 11px;
  background: linear-gradient(145deg, #f8fcf5, #eff7e9);
  box-shadow: var(--shadow-sm);
}

.system-head { display: flex; align-items: center; gap: 7px; color: var(--ink); font-size: 11px; font-weight: 700; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 99px; background: var(--quiet); box-shadow: 0 0 0 3px rgba(139, 152, 143, .13); }
.status-dot.ok { background: var(--accent); box-shadow: 0 0 0 3px rgba(134, 187, 66, .16); }
.status-dot.bad { background: var(--red); box-shadow: 0 0 0 3px rgba(201, 95, 88, .13); }
.live-pill { margin-left: auto; padding: 2px 5px; border: 1px solid #cfe5b7; border-radius: 4px; color: var(--accent-strong); font: 8px var(--mono); }
.system-card p { margin: 7px 0 10px; color: var(--quiet); font: 10px var(--mono); }

.text-button, .help-button, .icon-button, .profile-button { border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; }
.text-button { font-size: 11px; }
.text-button span { margin-left: 4px; color: var(--accent-strong); }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; padding: 18px 9px 0; color: var(--quiet); font: 9px var(--mono); }
.help-button { width: 20px; height: 20px; border: 1px solid var(--line-strong); border-radius: 50%; font: 11px var(--mono); }

.main { width: calc(100% - 252px); min-height: 100vh; margin-left: 252px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 73px;
  padding: 0 clamp(25px, 4vw, 60px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .54);
  backdrop-filter: blur(16px);
}

.breadcrumbs { display: flex; align-items: center; gap: 10px; color: var(--quiet); font: 11px var(--mono); }
.breadcrumbs b { color: var(--ink); font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 20px; }
.icon-button { color: var(--muted); font-size: 20px; transition: .2s ease; }
.icon-button:hover { color: var(--accent-strong); transform: rotate(-45deg); }
.profile-button { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 12px; }

.view { display: none; max-width: 1480px; margin: 0 auto; padding: 47px clamp(25px, 4vw, 60px) 80px; }
.view.active { display: block; animation: rise .45s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero-row { display: flex; justify-content: space-between; max-width: 1130px; margin: 0 auto 42px; }
.kicker, .section-label { margin: 0 0 12px; color: var(--accent-strong); font: 10px var(--mono); letter-spacing: .16em; }
.hero-row h1, .view-heading h1 { margin: 0 0 16px; color: var(--ink); font: 600 clamp(36px, 5vw, 64px)/1.03 var(--display); letter-spacing: -.075em; }
.hero-row h1 em, .view-heading h1 em { color: var(--accent-strong); font-style: normal; }
.hero-copy, .view-heading p { max-width: 560px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.75; }

.hero-orbit { position: relative; display: grid; place-items: center; width: 147px; height: 147px; margin: 7px 55px 0 40px; color: var(--accent-strong); font: 10px var(--mono); text-align: center; }
.orbit-ring { position: absolute; border: 1px solid #c9dbbe; border-radius: 50%; transform: rotate(-25deg); }
.ring-one { inset: 0; }
.ring-two { inset: 17px; border-color: #a9c98a; transform: rotate(55deg); }
.orbit-core { display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid #9dc875; border-radius: 50%; background: #f0f8e8; font-size: 14px; box-shadow: 0 4px 14px rgba(102, 153, 55, .12); }
.orbit-label { position: absolute; top: 37px; right: -32px; color: var(--quiet); font-size: 9px; letter-spacing: .14em; line-height: 1.2; }

.create-grid { display: grid; grid-template-columns: minmax(430px, 1fr) minmax(360px, .78fr); gap: 18px; max-width: 1130px; margin: 0 auto; }
.panel { border: 1px solid var(--line); border-radius: 13px; background: rgba(255, 255, 255, .88); box-shadow: var(--shadow-md); }
.composer, .script-panel { padding: 24px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 23px; }
.panel-heading h2 { margin: 3px 0 0; color: var(--ink); font: 600 19px var(--display); letter-spacing: -.04em; }
.step-badge { padding: 4px 7px; border: 1px solid #b9d79a; border-radius: 5px; color: var(--accent-strong); font: 10px var(--mono); background: #f4faed; }

.field-label { display: block; margin: 0 0 8px; color: #536259; font: 10px var(--mono); letter-spacing: .03em; }
.optional { margin-left: 7px; color: var(--quiet); font: 10px var(--body); }
.source-field { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; transition: .2s ease; }
.source-field:focus-within { border-color: #94c467; box-shadow: 0 0 0 3px rgba(134, 187, 66, .14); }
.input-prefix { padding-left: 13px; color: var(--accent-strong); font-size: 15px; }
.source-field input { flex: 1; min-width: 0; padding: 13px 10px; border: 0; outline: 0; background: none; color: var(--ink); font: 13px var(--body); }
.source-field input::placeholder, input::placeholder, textarea::placeholder { color: #9aa69d; }
.field-action { height: 36px; padding: 0 13px; border: 0; border-left: 1px solid var(--line); background: #f1f8ea; color: var(--accent-strong); font: 10px var(--mono); cursor: pointer; }
.field-action:hover { background: #e6f3d8; }
.field-hint { margin: 8px 1px 18px; color: var(--quiet); font-size: 11px; }
.quick-picks { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--quiet); font-size: 10px; }
.quick-picks button { padding: 5px 8px; border: 1px solid #dce8d9; border-radius: 5px; background: #f7faf6; color: #6c7c70; font: 10px var(--body); cursor: pointer; }
.quick-picks button:hover { border-color: #a8cf80; color: var(--accent-strong); background: #f0f8e9; }
.divider { height: 1px; margin: 23px 0; background: var(--line); }
.two-col, .field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-bottom: 16px; }

select, input, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 7px; outline: 0; background: #fff; color: var(--ink); font: 12px var(--body); transition: .2s ease; }
select:focus, input:focus, textarea:focus { border-color: #94c467; box-shadow: 0 0 0 3px rgba(134, 187, 66, .13); }
select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, #849486 50%), linear-gradient(135deg, #849486 50%, transparent 50%); background-position: calc(100% - 15px) 48%, calc(100% - 11px) 48%; background-repeat: no-repeat; background-size: 4px 4px, 4px 4px; }
.stepper { display: flex; height: 38px; }
.stepper button { width: 38px; border: 1px solid var(--line-strong); background: #f5f9f4; color: var(--accent-strong); font-size: 16px; cursor: pointer; }
.stepper button:hover { background: #eaf5e2; }
.stepper button:first-child { border-radius: 7px 0 0 7px; }
.stepper button:last-child { border-radius: 0 7px 7px 0; }
.stepper input { padding: 0; border-right: 0; border-left: 0; border-radius: 0; text-align: center; }

.advanced-line { display: flex; align-items: center; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); color: #536259; font-size: 11px; cursor: pointer; }
.advanced-icon { color: var(--accent-strong); font-size: 15px; }
.advanced-note { color: var(--quiet); font-size: 10px; }
.toggle { width: 31px; height: 18px; margin-left: auto; padding: 2px; border: 1px solid #cbd9c9; border-radius: 20px; background: #eef3ee; cursor: pointer; }
.toggle span { display: block; width: 12px; height: 12px; border-radius: 50%; background: #aab7aa; transition: .2s ease; }
.toggle.on { border-color: #a7cf7e; background: #e7f3d7; }
.toggle.on span { transform: translateX(12px); background: var(--accent); }
.advanced-options { display: none; padding: 4px 0 3px; }
.advanced-options.open { display: block; animation: rise .25s ease both; }
.advanced-options textarea { resize: vertical; }

.composer-actions { display: flex; gap: 10px; margin-top: 22px; }
.primary-button, .ghost-button { height: 39px; padding: 0 14px; border-radius: 7px; font: 700 11px var(--body); cursor: pointer; transition: .2s ease; }
.primary-button { border: 1px solid var(--accent); background: linear-gradient(145deg, #a8d96a, #8ac34b); color: var(--accent-ink); box-shadow: 0 6px 15px rgba(108, 158, 47, .16); }
.primary-button:hover { border-color: #76ad3b; background: linear-gradient(145deg, #b2df76, #95ce57); transform: translateY(-1px); }
.primary-button:disabled, .ghost-button:disabled { opacity: .45; cursor: wait; transform: none; }
.primary-button span:last-child, .ghost-button span:last-child { margin-left: 8px; opacity: .65; font: 9px var(--mono); }
.button-spark { margin-right: 5px; }
.ghost-button { border: 1px solid var(--line-strong); background: #fff; color: #526158; }
.ghost-button:hover { border-color: #9fc878; background: #f4faef; color: var(--accent-strong); }
.inline-status { min-height: 18px; margin-top: 12px; color: var(--quiet); font-size: 11px; }
.inline-status.success { color: var(--accent-strong); }
.inline-status.error { color: var(--red); }

.script-panel { display: flex; flex-direction: column; min-height: 620px; }
.script-status, .config-state { padding-top: 5px; color: var(--quiet); font: 10px var(--mono); }
.script-status.ready, .config-state.ready { color: var(--accent-strong); }
.script-empty { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; min-height: 420px; padding: 35px 20px; border: 1px dashed #cddccd; border-radius: 9px; background: #fbfdfb; text-align: center; }
.empty-glyph { margin-bottom: 15px; color: #9fbc91; font-size: 27px; }
.script-empty h3, .library-empty h3 { margin: 0 0 8px; color: var(--ink); font: 600 17px var(--display); letter-spacing: -.04em; }
.script-empty p, .library-empty p { max-width: 250px; margin: 0; color: var(--quiet); font-size: 11px; line-height: 1.7; }
.empty-tip { margin-top: 28px; color: #96a692; font: 9px var(--mono); }
.script-editor-wrap { display: none; flex: 1; flex-direction: column; min-height: 420px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; }
.script-editor-wrap.open { display: flex; }
.editor-toolbar { display: flex; align-items: center; gap: 14px; padding: 9px 11px; background: #f5f9f4; color: var(--quiet); font: 10px var(--mono); }
.editor-toolbar span { margin-right: auto; }
.editor-toolbar button { border: 0; background: none; color: var(--muted); font: 10px var(--body); cursor: pointer; }
.editor-toolbar button:hover { color: var(--accent-strong); }
#scriptEditor { flex: 1; min-height: 320px; padding: 17px; border: 0; border-radius: 0; outline: 0; background: #fff; font-size: 13px; line-height: 1.85; resize: none; }
.script-footer { display: flex; align-items: center; gap: 9px; padding-top: 15px; color: var(--quiet); font: 10px var(--mono); }
.mini-chip { padding: 3px 5px; border: 1px solid #c5dea8; border-radius: 4px; color: var(--accent-strong); background: #f2f9e9; font-size: 8px; }

.view-heading { display: flex; align-items: flex-end; justify-content: space-between; max-width: 1130px; margin: 0 auto 38px; }
.view-heading h1 { font-size: 54px; }
.settings-lock { padding: 7px 9px; border: 1px solid #c9dfb3; border-radius: 5px; background: #f4faed; color: var(--accent-strong); font: 10px var(--mono); }
.settings-layout { display: grid; grid-template-columns: minmax(480px, 720px) minmax(220px, 310px); gap: 18px; max-width: 1048px; margin: 0 auto; }
.settings-main { padding: 25px; }
.compact { margin-top: 3px; margin-bottom: 19px; }
.settings-main input { margin-bottom: 17px; }
.setting-link { min-height: 16px; color: var(--orange); font-size: 10px; }
.setting-link a { color: var(--orange); }
.settings-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 25px; }
.security-note, .connection-card { padding: 19px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .84); box-shadow: var(--shadow-sm); }
.security-note { border-top: 2px solid var(--accent); }
.note-icon { color: var(--accent-strong); font-size: 19px; }
.security-note h3 { margin: 11px 0 7px; color: var(--ink); font: 600 16px var(--display); }
.security-note p { color: var(--muted); font-size: 11px; line-height: 1.7; }
.security-note ul { margin: 15px 0 0; padding: 13px 0 0 16px; border-top: 1px solid var(--line); color: var(--quiet); font-size: 10px; line-height: 2; }
.connection-card { margin-top: 13px; }
.connection-title { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font: 700 11px var(--mono); }
.connection-row { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); color: var(--quiet); font-size: 10px; }
.connection-row b { color: var(--muted); font: 9px var(--mono); font-weight: 400; }

.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; max-width: 1130px; margin: 0 auto; }
.library-empty { display: flex; grid-column: 1 / -1; flex-direction: column; align-items: center; justify-content: center; min-height: 380px; border: 1px dashed #cddccd; border-radius: 10px; background: rgba(255, 255, 255, .48); text-align: center; }
.library-empty .primary-button { margin-top: 22px; }
.job-card { overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: var(--shadow-sm); }
.job-thumb { display: flex; align-items: center; justify-content: center; height: 155px; background: linear-gradient(145deg, #edf5e9, #e2eee0); color: #7f9f78; font: 11px var(--mono); }
.job-body { padding: 14px; }
.job-title { overflow: hidden; color: var(--ink); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { display: flex; justify-content: space-between; margin-top: 10px; color: var(--quiet); font: 9px var(--mono); }
.job-state { color: var(--accent-strong); }
.job-card video { display: block; width: 100%; height: 155px; object-fit: cover; background: #e9f0e9; }

.toast { position: fixed; right: 27px; bottom: 25px; z-index: 20; padding: 11px 15px; border: 1px solid #c7dda9; border-radius: 8px; background: #f0f8e4; color: #345222; font-size: 11px; font-weight: 700; box-shadow: 0 10px 28px rgba(38, 66, 42, .15); opacity: 0; pointer-events: none; transform: translateY(8px); transition: .25s ease; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 980px) {
  .sidebar { width: 212px; }
  .main { width: calc(100% - 212px); margin-left: 212px; }
  .create-grid { grid-template-columns: 1fr; }
  .hero-orbit { margin-right: 10px; }
  .script-panel { min-height: 480px; }
  .script-empty { min-height: 300px; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-aside { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .connection-card { margin-top: 0; }
}

@media (max-width: 700px) {
  .sidebar { position: static; display: block; width: 100%; height: auto; min-height: 0; padding: 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding-bottom: 13px; }
  .workspace-switcher, .sidebar-spacer, .system-card, .sidebar-footer { display: none; }
  .nav { display: flex; gap: 4px; }
  .nav-item { flex: 1; justify-content: center; padding: 8px; }
  .nav-item kbd, .nav-count { display: none; }
  .main { width: 100%; margin-left: 0; }
  .topbar { height: 52px; padding: 0 18px; }
  .view { padding: 30px 16px 60px; }
  .hero-row { margin-bottom: 28px; }
  .hero-row h1, .view-heading h1 { font-size: 39px; }
  .hero-orbit { display: none; }
  .composer, .script-panel, .settings-main { padding: 18px; }
  .two-col, .field-grid { gap: 8px; }
  .composer-actions { flex-direction: column; }
  .primary-button, .ghost-button { width: 100%; }
  .view-heading { display: block; }
  .view-heading .ghost-button, .settings-lock { margin-top: 20px; }
  .settings-aside { display: block; }
  .connection-card { margin-top: 12px; }
}
