:root {
  --bg: #061512;
  --panel: #0b211d;
  --panel-strong: #0e3028;
  --field: #102c28;
  --line: rgba(141, 255, 222, 0.18);
  --text: #effffb;
  --muted: #a6c7be;
  --green: #49e6a7;
  --green-deep: #0c7d5b;
  --magenta: #ff45a8;
  --magenta-soft: #ff8bc8;
  --cyan: #56d8ff;
  --amber: #ffd166;
  --danger: #ff6b7a;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(73, 230, 167, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(255, 69, 168, 0.09), transparent 32%),
    var(--bg);
  color: var(--text);
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(16px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(6, 21, 18, 0.88);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(16px);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--magenta-soft);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2.4vw, 2.15rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.header-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(16, 44, 40, 0.72);
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 20px var(--green);
}

.header-status.expired .status-dot {
  background: var(--danger);
  box-shadow: 0 0 20px var(--danger);
}

.header-status.paid .status-dot {
  background: var(--magenta);
  box-shadow: 0 0 20px var(--magenta);
}

.compact-button {
  min-height: 40px;
  padding-inline: 14px;
}

.membership-strip {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  margin: 18px clamp(16px, 3vw, 40px) 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(14, 48, 40, 0.78);
  box-shadow: var(--shadow);
}

.membership-strip h2 {
  margin-bottom: 4px;
}

.membership-strip p {
  margin-bottom: 0;
  color: var(--muted);
}

.price-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.price-row span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border: 1px solid rgba(255, 69, 168, 0.22);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 69, 168, 0.08);
  font-weight: 800;
  white-space: nowrap;
}

.membership-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 8, 7, 0.72);
  backdrop-filter: blur(8px);
}

.membership-modal.show {
  display: flex;
}

.membership-dialog {
  width: min(980px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(14, 48, 40, 0.98), rgba(8, 28, 24, 0.98));
  box-shadow: var(--shadow);
}

.membership-note,
.membership-footnote {
  color: var(--muted);
  line-height: 1.6;
}

.membership-plans {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.plan-card {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 260px;
  padding: 16px;
  border: 1px solid rgba(166, 199, 190, 0.2);
  border-radius: var(--radius);
  background: rgba(3, 16, 14, 0.58);
}

.plan-card.featured {
  border-color: rgba(255, 69, 168, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255, 69, 168, 0.14);
}

.plan-card h3,
.plan-card p {
  margin: 0;
}

.plan-card p {
  color: var(--muted);
  line-height: 1.5;
}

.plan-price {
  color: var(--text) !important;
  font-size: 2rem;
  font-weight: 950;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(330px, 440px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px clamp(16px, 3vw, 40px) 36px;
}

.workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(14, 48, 40, 0.94), rgba(8, 28, 24, 0.94));
  box-shadow: var(--shadow);
}

.controls-panel,
.preview-panel,
.output-panel,
.details-panel {
  padding: 18px;
}

.controls-panel {
  align-self: start;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.settings-form {
  display: grid;
  gap: 16px;
}

.source-mode-panel {
  border-color: rgba(255, 69, 168, 0.34);
}

.source-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.source-mode-button {
  min-height: 50px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.source-mode-button.selected {
  color: #04120f;
  background: var(--green);
  border-color: var(--green);
}

.source-mode-description {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.source-fieldset-hidden {
  display: none;
}

fieldset {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(5, 17, 15, 0.28);
}

legend {
  padding: 0 8px;
  color: var(--green);
  font-weight: 800;
}

label,
.compact-field {
  display: grid;
  gap: 7px;
}

label span,
.compact-field span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

fieldset > label + label,
fieldset > label + .field-grid,
fieldset > .field-grid + label,
.tool-hint {
  margin-top: 12px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid rgba(166, 199, 190, 0.24);
  border-radius: 7px;
  outline: none;
  background: var(--field);
  color: var(--text);
}

input[type="file"] {
  padding: 8px;
}

input[type="file"]::file-selector-button {
  min-height: 32px;
  margin-right: 10px;
  border: 0;
  border-radius: 6px;
  color: #04120f;
  background: var(--green);
  font-weight: 900;
}

.field-button {
  display: grid;
  gap: 7px;
}

.field-button span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.origin-picker-field {
  display: grid;
  gap: 7px;
}

.origin-picker-field > span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.origin-picker {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 22px);
  grid-template-rows: repeat(3, 22px);
  justify-content: space-between;
  align-content: space-between;
  width: 100%;
  height: 104px;
  padding: 10px;
  border: 1px solid rgba(166, 199, 190, 0.28);
  border-radius: 7px;
  background:
    linear-gradient(rgba(166, 199, 190, 0.13), rgba(166, 199, 190, 0.13)) center / calc(100% - 40px) 1px no-repeat,
    linear-gradient(90deg, rgba(166, 199, 190, 0.13), rgba(166, 199, 190, 0.13)) center / 1px calc(100% - 40px) no-repeat,
    var(--field);
}

.origin-point {
  min-width: 22px;
  min-height: 22px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 3px solid #071a16;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 1px rgba(166, 199, 190, 0.36);
}

.origin-point:hover {
  transform: scale(1.15);
  background: var(--magenta-soft);
}

.origin-point.selected {
  background: var(--green);
  box-shadow: 0 0 0 2px var(--magenta), 0 0 16px rgba(73, 230, 167, 0.54);
}

.origin-description {
  margin: 0;
  color: var(--cyan);
  font-size: 0.82rem;
  font-weight: 800;
}

input:focus,
select:focus {
  border-color: var(--magenta);
  box-shadow: 0 0 0 3px rgba(255, 69, 168, 0.16);
}

input:disabled {
  opacity: 0.52;
}

.tool-hint {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--cyan);
  background: rgba(86, 216, 255, 0.08);
  border: 1px solid rgba(86, 216, 255, 0.18);
}

.compact-field {
  width: min(230px, 100%);
}

.compact-field input {
  min-height: 38px;
}

button {
  min-height: 46px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px;
  color: #04120f;
  background: linear-gradient(135deg, var(--green), #88ffd2);
  font-weight: 900;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease, border-color 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

button:active {
  transform: translateY(0);
}

.secondary-button {
  color: #150611;
  background: linear-gradient(135deg, var(--magenta), var(--magenta-soft));
}

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

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.button-row.tight {
  justify-content: flex-end;
  margin-top: 0;
}

#previewCanvas {
  display: block;
  width: 100%;
  height: 320px;
  border: 1px solid rgba(166, 199, 190, 0.22);
  border-radius: var(--radius);
  background: #03100e;
}

.code-editor {
  min-height: 320px;
  max-height: 520px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid rgba(166, 199, 190, 0.22);
  border-radius: var(--radius);
  background: #020a09;
  color: #d9fff2;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.58;
}

.status-message {
  display: none;
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 7px;
  font-weight: 750;
}

.status-message.show {
  display: block;
}

.status-message.success {
  color: #caffec;
  border: 1px solid rgba(73, 230, 167, 0.36);
  background: rgba(73, 230, 167, 0.1);
}

.status-message.error {
  color: #ffe5e8;
  border: 1px solid rgba(255, 107, 122, 0.48);
  background: rgba(255, 107, 122, 0.12);
}

.status-message.info {
  color: #e8f7ff;
  border: 1px solid rgba(86, 216, 255, 0.3);
  background: rgba(86, 216, 255, 0.1);
}

.job-details {
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.detail-grid div {
  min-height: 72px;
  padding: 12px;
  border: 1px solid rgba(166, 199, 190, 0.17);
  border-radius: 7px;
  background: rgba(3, 16, 14, 0.55);
}

.detail-grid dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.detail-grid dd {
  margin: 5px 0 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 850;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .membership-strip {
    grid-template-columns: 1fr;
  }

  .price-row {
    justify-content: flex-start;
  }

  .controls-panel {
    align-self: stretch;
  }
}

@media (max-width: 720px) {
  .app-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .membership-plans {
    grid-template-columns: 1fr;
  }

  .source-mode-switch {
    grid-template-columns: 1fr;
  }

  .field-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .panel-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row,
  .button-row.tight {
    display: grid;
    grid-template-columns: 1fr;
  }

  #previewCanvas {
    height: 280px;
  }
}
