:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --sidebar: #101318;
  --panel: #151920;
  --panel-2: #1b2028;
  --field: #0f1217;
  --line: #2c333d;
  --line-strong: #414b58;
  --text: #eef2f6;
  --muted: #929dab;
  --accent: #52d3a7;
  --accent-dark: #183c34;
  --info: #68a9ff;
  --danger: #ff6678;
  --warning: #e4b65a;
  --shadow: 0 20px 55px rgba(0, 0, 0, .34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }

.workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px 14px 14px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 7px 18px; }
.brand-mark, .login-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid #3c6d60;
  border-radius: 6px;
  color: var(--accent);
  background: #13231f;
  font-weight: 850;
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  margin: 0 4px 20px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0c0f13;
}
.mode-button {
  min-height: 34px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 750;
}
.mode-button.active { color: var(--text); background: var(--panel-2); }

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
  padding: 0 7px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.icon-button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  background: var(--panel);
  font-size: 18px;
  line-height: 1;
}
.icon-button:hover { border-color: var(--accent); }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 3px 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: var(--field);
}
.search input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 12px; }
.sidebar-list { flex: 1; min-height: 0; overflow-y: auto; }
.list-item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 8px;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 52px;
  margin-bottom: 3px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  text-align: left;
  background: transparent;
}
.list-item:hover { background: var(--panel); }
.list-item.active { border-color: #3e4a56; background: var(--panel-2); }
.list-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  color: #b8c5d2;
  background: #29313a;
  font-size: 12px;
  font-weight: 850;
}
.preset-avatar { color: var(--accent); background: var(--accent-dark); }
.list-copy { min-width: 0; }
.list-copy strong, .list-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-copy strong { font-size: 12px; }
.list-copy small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.list-status { width: 7px; height: 7px; border-radius: 50%; background: #56606b; }
.list-status.online { background: var(--accent); box-shadow: 0 0 8px rgba(82, 211, 167, .55); }
.sidebar-blank { padding: 18px 10px; color: var(--muted); font-size: 12px; text-align: center; }
.sidebar-footer { display: flex; align-items: center; gap: 7px; padding: 13px 7px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.link-button { margin-left: auto; padding: 3px; border: 0; color: var(--muted); background: transparent; font-size: 11px; }
.link-button:hover { color: var(--text); }

.content { min-width: 0; padding: 34px clamp(22px, 4vw, 62px) 80px; }
.editor { width: 100%; max-width: 1180px; margin: 0 auto; }
.empty-state { max-width: 440px; margin: 28vh auto 0; text-align: center; }
.empty-icon { width: 58px; height: 58px; margin: auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--panel); font-size: 28px; }
.empty-state h1 { margin: 18px 0 0; font-size: 21px; }
.editor-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; min-height: 90px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.eyebrow { margin-bottom: 7px; color: var(--accent); font-size: 10px; font-weight: 850; text-transform: uppercase; }
.editor-title { margin: 0; font-size: 30px; line-height: 1.15; }
.header-meta { margin-top: 7px; color: var(--muted); font-size: 12px; }
.state-badge { padding: 6px 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font-size: 11px; }
.state-badge.success { border-color: #2f6456; color: var(--accent); background: #11231f; }
.title-input { width: min(600px, 62vw); padding: 0 0 3px; border: 0; border-bottom: 1px solid transparent; outline: 0; color: var(--text); background: transparent; font-size: 30px; font-weight: 780; }
.title-input:focus { border-bottom-color: var(--accent); }
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }

.assignment-bar { display: flex; align-items: flex-end; gap: 10px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.assignment-bar .field-label { flex: 1; max-width: 620px; }
.sequence-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 25px 0 14px; }
.sequence-toolbar strong { margin-right: 9px; font-size: 14px; }
.muted { color: var(--muted); font-size: 11px; }
.content-blank { padding: 44px 0; color: var(--muted); text-align: center; }

.button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  background: var(--panel-2);
  font-size: 11px;
  font-weight: 750;
}
.button:hover { border-color: var(--line-strong); background: #232a33; }
.button.primary { border-color: #317461; color: #eafff8; background: #1c5949; }
.button.primary:hover { background: #246b58; }
.button.danger { border-color: #66313a; color: #ffadb8; background: #3d1c23; }
.button.wide { width: 100%; min-height: 42px; }
.button:disabled { cursor: wait; opacity: .52; }

.step-list { display: grid; gap: 10px; }
.step-card { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.step-position { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 5px; color: var(--accent); background: var(--accent-dark); font-size: 12px; font-weight: 850; }
.step-main { min-width: 0; }
.step-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 1px 0 13px; }
.step-head strong, .action-code { display: block; }
.step-head strong { font-size: 13px; }
.action-code { margin-top: 4px; color: var(--muted); font: 10px Consolas, monospace; }
.step-body { border-top: 1px solid #252c35; padding-top: 14px; }
.step-footer { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding-top: 13px; }
.node-order { display: flex; gap: 5px; }
.small-button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: var(--field); }
.small-button:hover { color: var(--text); border-color: var(--line-strong); }
.small-button.danger:hover { color: var(--danger); border-color: #6e3540; }
.small-button:disabled { cursor: default; opacity: .35; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field-label { display: grid; gap: 6px; min-width: 0; color: var(--muted); font-size: 10px; font-weight: 750; }
.field-label.wide, .settings-note.wide, .binding-grid.wide { grid-column: 1 / -1; }
.field-label.compact { gap: 5px; }
input, select, textarea { border: 1px solid var(--line); border-radius: 5px; outline: 0; color: var(--text); background: var(--field); }
.field-label input, .field-label select, .field-label textarea, .modal-card input, .modal-card select { width: 100%; min-width: 0; padding: 9px 10px; font-size: 12px; }
.field-label textarea { min-height: 82px; resize: vertical; line-height: 1.45; }
.field-label select[multiple] { min-height: 98px; padding: 5px; }
.field-label select[multiple] option { padding: 6px 7px; border-radius: 3px; }
input:focus, select:focus, textarea:focus { border-color: #4b756a; }
.settings-note { padding: 9px 10px; border-left: 2px solid #46515e; color: var(--muted); background: #11151a; font-size: 10px; line-height: 1.45; }
.media-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; grid-column: 1 / -1; margin-top: -5px; }
.media-status { min-height: 16px; color: var(--accent); font-size: 10px; font-weight: 750; }
.binding-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.toggle-field { display: flex; align-items: center; gap: 9px; min-height: 34px; color: #c6ced7; font-size: 11px; cursor: pointer; }
.toggle-field input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-switch { position: relative; width: 34px; height: 18px; border: 1px solid #46515e; border-radius: 9px; background: #20262e; }
.toggle-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 10px; height: 10px; border-radius: 50%; background: #8d98a6; transition: left .16s, background .16s; }
.toggle-field input:checked + .toggle-switch { border-color: #377a68; background: #183d34; }
.toggle-field input:checked + .toggle-switch::after { left: 19px; background: var(--accent); }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(410px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); box-shadow: var(--shadow); }
.login-mark { width: 48px; height: 48px; margin-bottom: 22px; }
.login-card h1 { margin: 0 0 24px; font-size: 24px; }
.login-card label { display: grid; gap: 7px; margin-bottom: 14px; color: var(--muted); font-size: 10px; font-weight: 750; }
.login-card input { width: 100%; padding: 11px; }
.form-error { min-height: 17px; margin-top: 10px; color: var(--danger); font-size: 11px; }
.toast { position: fixed; z-index: 20; right: 20px; bottom: 20px; max-width: 420px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 5px; color: var(--text); background: #1d242c; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: #70404a; color: #ffb2bc; }
.modal { width: min(520px, calc(100% - 28px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--line); border-radius: 7px; color: var(--text); background: var(--panel); box-shadow: var(--shadow); }
.step-modal { width: min(760px, calc(100% - 28px)); }
.modal::backdrop { background: rgba(3, 5, 8, .78); }
.modal-card { padding: 25px; overflow-y: auto; }
.modal-card h2 { margin: 0 0 16px; font-size: 20px; }
.modal-card > p { margin: 0 0 18px; line-height: 1.45; }
.modal-card > label { display: grid; gap: 7px; margin-bottom: 18px; color: var(--muted); font-size: 10px; font-weight: 750; }
.modal-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 20px; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 250px minmax(0, 1fr); }
  .content { padding: 28px 20px 60px; }
  .settings-grid, .binding-grid { grid-template-columns: 1fr; }
  .field-label.wide, .settings-note.wide, .binding-grid.wide { grid-column: auto; }
}

@media (max-width: 680px) {
  .workspace { display: block; }
  .sidebar { position: relative; height: 360px; border-right: 0; border-bottom: 1px solid var(--line); }
  .content { padding: 22px 14px 50px; }
  .editor-header { min-height: 0; align-items: flex-start; flex-direction: column; }
  .editor-title, .title-input { width: 100%; font-size: 24px; }
  .header-actions { justify-content: flex-start; }
  .assignment-bar { align-items: stretch; flex-direction: column; }
  .assignment-bar .field-label { max-width: none; }
  .media-actions .button { flex: 1 1 150px; }
  .step-card { grid-template-columns: 32px minmax(0, 1fr); padding: 12px; }
  .step-position { width: 32px; height: 32px; }
  .step-footer { align-items: flex-end; flex-direction: column; }
  .sequence-toolbar { align-items: flex-start; }
}
