:root {
  color-scheme: dark;
  --bg: #07090b;
  --panel: rgba(25, 27, 32, 0.88);
  --panel-solid: #17191f;
  --line: rgba(186, 255, 18, 0.55);
  --lime: #baff12;
  --lime-2: #78a713;
  --cyan: #2df6d2;
  --violet: #865cff;
  --amber: #ffaf28;
  --text: #f4f7fb;
  --muted: #9aa4b8;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 24% 18%, rgba(186, 255, 18, 0.12), transparent 28%),
    radial-gradient(circle at 78% 70%, rgba(45, 246, 210, 0.10), transparent 26%),
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    #08090c;
  background-size: auto, auto, 32px 32px, 32px 32px, auto;
}

.auth-panel {
  width: min(440px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(14, 16, 20, 0.86);
  box-shadow: var(--shadow);
}

.brand-lockup,
.top-left,
.top-actions,
.modal-head,
.inline-form,
.share-form {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 14px;
  margin-bottom: 28px;
}

.brand-mark,
.brand-mini {
  display: grid;
  place-items: center;
  color: var(--lime);
  font-weight: 900;
  line-height: 1;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border: 1px solid rgba(186, 255, 18, 0.24);
  border-radius: 8px;
  background: rgba(186, 255, 18, 0.08);
  font-size: 34px;
}

.brand-mini {
  font-size: 28px;
  width: 34px;
  height: 34px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand-lockup h1 {
  font-size: 26px;
}

.brand-lockup p,
.auth-form span,
.node-subtitle,
.muted {
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

label {
  display: grid;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  outline: none;
}

input,
select {
  height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 94px;
  resize: vertical;
  padding: 12px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(186, 255, 18, 0.64);
  box-shadow: 0 0 0 3px rgba(186, 255, 18, 0.12);
}

.primary-button,
.ghost-button,
.inline-form button,
.share-form button,
.admin-form button,
.generator-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button,
.inline-form button,
.share-form button,
.admin-form button,
.generator-button {
  color: #101608;
  background: var(--lime);
}

.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
}

.app-shell {
  width: 100vw;
  height: 100vh;
  background:
    radial-gradient(circle at 65% 40%, rgba(109, 167, 17, 0.11), transparent 30%),
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    #07090b;
  background-size: auto, 30px 30px, 30px 30px, auto;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: 54px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.top-left,
.top-actions {
  gap: 10px;
}

.workspace-button,
.icon-button,
.icon-text,
.avatar-button,
.credit-pill,
.left-toolbar,
.zoom-controls {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(13, 15, 19, 0.72);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.32);
}

.workspace-button {
  color: var(--text);
  min-width: 160px;
  max-width: 280px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.avatar-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--text);
}

.icon-text {
  height: 34px;
  color: var(--text);
  padding: 0 12px;
  border-radius: 8px;
}

.avatar-button {
  border-color: rgba(45, 246, 210, 0.35);
  background: linear-gradient(135deg, #159dff, #2df6d2);
  color: #061014;
  font-weight: 900;
}

.credit-pill {
  min-width: 110px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #ffd56d;
  font-weight: 800;
  font-size: 13px;
}

.left-toolbar {
  position: fixed;
  left: 14px;
  top: 50%;
  z-index: 18;
  transform: translateY(-50%);
  width: 46px;
  display: grid;
  gap: 6px;
  padding: 9px 6px;
  border-radius: 8px;
}

.left-toolbar button {
  width: 32px;
  height: 32px;
  border: 0;
  color: #dce3ef;
  background: transparent;
  border-radius: 8px;
  font-weight: 900;
}

.left-toolbar button:hover,
.icon-button:hover,
.icon-text:hover,
.workspace-button:hover,
.ghost-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.board-viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  cursor: grab;
}

.board-viewport.panning {
  cursor: grabbing;
}

.world {
  position: absolute;
  left: 0;
  top: 0;
  width: 5000px;
  height: 3200px;
  transform-origin: 0 0;
}

.edge-layer,
.node-layer {
  position: absolute;
  inset: 0;
}

.edge-layer {
  pointer-events: none;
  overflow: visible;
}

.edge-path {
  fill: none;
  stroke: var(--lime);
  stroke-width: 8;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(186, 255, 18, 0.45));
}

.node {
  position: absolute;
  border: 1px solid rgba(186, 255, 18, 0.16);
  border-radius: 8px;
  background: rgba(19, 22, 28, 0.88);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.46), 0 0 32px rgba(186, 255, 18, 0.08);
  overflow: visible;
  user-select: none;
}

.node.dragging {
  opacity: 0.88;
}

.node-card {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    rgba(12, 15, 21, 0.94);
  background-size: 24px 24px;
}

.node.image .node-card {
  background: #11141a;
}

.image-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 8px;
}

.node-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100% - 72px);
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  color: #f3f7ee;
  font-size: 13px;
  font-weight: 800;
  background: rgba(32, 36, 42, 0.68);
  backdrop-filter: blur(12px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.node-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 12px var(--lime);
}

.node-actions {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 3;
  display: flex;
  gap: 6px;
}

.node-actions button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: rgba(35, 38, 43, 0.66);
  backdrop-filter: blur(10px);
}

.connector {
  position: absolute;
  z-index: 4;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--lime);
  border: 4px solid rgba(15, 17, 20, 0.95);
  box-shadow: 0 0 12px rgba(186, 255, 18, 0.8);
}

.connector.left {
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
}

.connector.right {
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
}

.generator-card {
  display: grid;
  grid-template-rows: 118px 1fr;
  height: 100%;
}

.generator-visual {
  position: relative;
  padding: 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at 52% 38%, rgba(186, 255, 18, 0.76), transparent 13%),
    radial-gradient(circle at 66% 65%, rgba(134, 92, 255, 0.7), transparent 2%),
    radial-gradient(circle at 28% 36%, rgba(186, 255, 18, 0.9), transparent 2%),
    radial-gradient(circle at 78% 28%, rgba(45, 246, 210, 0.8), transparent 2%),
    linear-gradient(135deg, rgba(17, 24, 35, 0.92), rgba(19, 18, 38, 0.92));
}

.generator-visual::after {
  content: "";
  position: absolute;
  width: 130px;
  height: 130px;
  left: 50%;
  top: 22px;
  transform: translateX(-50%);
  border-radius: 28px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.88), rgba(186, 255, 18, 0.72) 18%, rgba(45, 246, 210, 0.36) 44%, rgba(20, 17, 38, 0.8) 74%);
  filter: blur(1px);
}

.generator-body {
  display: grid;
  gap: 9px;
  padding: 14px;
}

.generator-title {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 2;
  font-size: 23px;
  font-weight: 900;
}

.generator-row {
  display: grid;
  grid-template-columns: 1.1fr 0.8fr 0.8fr;
  gap: 8px;
}

.generator-row.compact {
  grid-template-columns: 1fr 1fr;
}

.generator-body textarea {
  min-height: 74px;
  max-height: 104px;
}

.generator-button[disabled] {
  opacity: 0.65;
  cursor: wait;
}

.generator-row.size-row {
  grid-template-columns: 0.72fr 1.68fr;
}

.custom-size-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.custom-size-row input {
  min-width: 0;
}

.progress-strip {
  position: absolute;
  left: 0;
  right: 0;
  top: -48px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border: 1px solid rgba(186, 255, 18, 0.22);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(83, 120, 15, 0.52), rgba(38, 27, 64, 0.78));
  box-shadow: 0 0 22px rgba(186, 255, 18, 0.16);
}

.progress-strip strong {
  font-size: 13px;
}

.progress-strip span {
  color: var(--lime);
  font-size: 16px;
  font-weight: 900;
}

.progress-strip .duration-counter {
  font-size: 13px;
  color: #f5ffdd;
}

.text-card {
  padding: 58px 18px 18px;
  color: #f2f5f8;
  line-height: 1.6;
}

.text-card textarea {
  height: calc(100% - 16px);
  min-height: 120px;
  background: rgba(0, 0, 0, 0.16);
}

.empty-image {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.48);
  text-align: center;
}

.empty-image strong {
  display: block;
  font-size: 40px;
  margin-bottom: 8px;
}

.zoom-controls {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 19;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 38px;
  padding: 4px;
  border-radius: 8px;
}

.zoom-controls button {
  width: 30px;
  height: 30px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.zoom-controls span {
  min-width: 58px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
}

.modal-card {
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(18, 20, 26, 0.96);
  box-shadow: var(--shadow);
}

.modal-card.narrow {
  width: min(540px, calc(100vw - 32px));
  padding: 18px;
}

.modal-card.wide {
  width: min(1180px, calc(100vw - 32px));
  padding: 18px;
}

.modal-head {
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-head h2 {
  font-size: 19px;
}

.close-modal {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  font-size: 22px;
}

.inline-form,
.share-form {
  gap: 8px;
  margin-bottom: 14px;
}

.inline-form input,
.share-form input {
  flex: 1;
}

.share-form select {
  width: 120px;
}

.inline-form button,
.share-form button {
  padding: 0 16px;
}

.stack-list,
.admin-list {
  display: grid;
  gap: 8px;
}

.list-item,
.admin-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.list-item button,
.admin-item button {
  justify-self: start;
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: #101608;
  background: var(--lime);
  font-weight: 800;
}

button[disabled],
.admin-item button[disabled] {
  opacity: 0.62;
  cursor: wait;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-item button.danger-button {
  color: #fff;
  background: rgba(255, 93, 93, 0.86);
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
}

.admin-grid h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.admin-form {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-form textarea {
  min-height: 74px;
}

.admin-item {
  font-size: 13px;
}

.admin-item strong {
  font-size: 14px;
}

.admin-item code {
  color: var(--cyan);
  overflow-wrap: anywhere;
}

.provider-result {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.provider-result.ok {
  border-color: rgba(186, 255, 18, 0.24);
}

.provider-result.error {
  border-color: rgba(255, 93, 93, 0.44);
}

.provider-result pre {
  max-height: 180px;
  overflow: auto;
  margin: 0;
  padding: 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: #dce3ef;
  white-space: pre-wrap;
}

.fetched-models {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.credit-adjust {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 80;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid rgba(186, 255, 18, 0.22);
  border-radius: 8px;
  background: rgba(18, 22, 26, 0.94);
  box-shadow: var(--shadow);
  color: var(--text);
}

@media (max-width: 900px) {
  .topbar {
    height: 62px;
    padding: 8px;
  }

  .workspace-button {
    min-width: 120px;
    max-width: 170px;
  }

  .credit-pill {
    min-width: 86px;
    font-size: 12px;
  }

  .left-toolbar {
    left: 8px;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 12px;
  }
}
