:root {
  --bg: #f4f7f3;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --ink: #13231f;
  --muted: #5f736d;
  --line: rgba(19, 35, 31, 0.12);
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --danger: #a43f2c;
  --danger-soft: rgba(164, 63, 44, 0.12);
  --focus: rgba(15, 118, 110, 0.22);
  --shadow: 0 24px 48px rgba(30, 63, 56, 0.14);
  --shadow-soft: 0 12px 28px rgba(30, 63, 56, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-body: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: "Bahnschrift", "Segoe UI", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(199, 244, 228, 0.9), transparent 28%),
    radial-gradient(circle at bottom right, rgba(249, 217, 177, 0.48), transparent 26%),
    linear-gradient(135deg, #f4f7f3 0%, #edf5f2 50%, #f8f3eb 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.55), transparent 85%);
}

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

button {
  border: 0;
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--ink);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

textarea {
  min-height: 220px;
  padding: 1rem 1.05rem;
  resize: vertical;
  font-family: var(--font-mono);
  line-height: 1.5;
}

input,
select {
  min-height: 48px;
  padding: 0.8rem 0.95rem;
}

.backdrop {
  position: fixed;
  inset: auto;
  width: 360px;
  height: 360px;
  border-radius: 999px;
  filter: blur(18px);
  pointer-events: none;
  opacity: 0.48;
}

.glow-a {
  top: -120px;
  right: -80px;
  background: radial-gradient(circle, rgba(15, 118, 110, 0.32) 0%, transparent 70%);
}

.glow-b {
  bottom: -140px;
  left: -80px;
  background: radial-gradient(circle, rgba(214, 124, 55, 0.26) 0%, transparent 70%);
}

.page-shell {
  position: relative;
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 2.25rem;
}

.auth-shell {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  width: min(100% - 2rem, 520px);
  margin: 0 auto;
}

.auth-card {
  width: 100%;
  padding: 2rem 2rem 1.85rem;
  border-radius: 32px;
}

.auth-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 3.25rem);
  letter-spacing: -0.05em;
}

.auth-copy,
.hero-subtext,
.slug-helper,
.subscription-link {
  color: var(--muted);
  line-height: 1.6;
}

.auth-status {
  margin: 1rem 0 0;
  padding: 0.85rem 0.95rem;
  border-radius: var(--radius-md);
  background: rgba(255, 242, 238, 0.88);
  border: 1px solid rgba(164, 63, 44, 0.16);
  color: var(--danger);
}

.auth-form {
  margin-top: 1.5rem;
}

.surface {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.44);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.surface-soft {
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(19, 35, 31, 0.08);
}

.hero-card {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: minmax(0, 1.9fr) minmax(280px, 0.86fr);
  padding: 1rem 1.05rem;
  border-radius: 20px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(247, 252, 250, 0.82)),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.1), transparent 34%);
}

.eyebrow,
.panel-kicker {
  margin: 0 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent-strong);
}

.hero-copy h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.42rem, 2vw, 2rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.hero-text {
  max-width: 60ch;
  color: var(--muted);
  line-height: 1.5;
  margin: 0.55rem 0 0;
  font-size: 0.9rem;
}

.hero-subtext {
  margin: 0.55rem 0 0;
  font-size: 0.88rem;
}

.hero-stats {
  display: grid;
  gap: 0.55rem;
  align-content: start;
}

.hero-stat {
  padding: 0.72rem 0.82rem;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(242, 248, 246, 0.8));
  border: 1px solid rgba(19, 35, 31, 0.08);
  box-shadow: var(--shadow-soft);
}

.hero-stat-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.stat-label {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.status-bar {
  margin: 0.85rem 0 1rem;
  padding: 0.82rem 0.95rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(19, 35, 31, 0.1);
  color: var(--muted);
  box-shadow: 0 8px 22px rgba(30, 63, 56, 0.06);
}

.status-bar.error {
  color: var(--danger);
  background: rgba(255, 244, 240, 0.9);
  border-color: rgba(164, 63, 44, 0.18);
}

.runtime-hint {
  margin: 0 0 1.2rem;
  padding: 1rem 1.05rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 236, 0.92);
  border: 1px solid rgba(190, 123, 36, 0.18);
  color: #8a5614;
  box-shadow: var(--shadow-soft);
}

.runtime-hint strong {
  display: block;
  margin-bottom: 0.45rem;
}

.runtime-hint p {
  margin: 0;
  line-height: 1.6;
}

.runtime-hint code {
  padding: 0.15rem 0.35rem;
  border-radius: 8px;
  background: rgba(19, 35, 31, 0.08);
  font-family: var(--font-mono);
}

.runtime-hint a {
  color: inherit;
}

.editing-banner {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-lg);
  background: rgba(232, 248, 244, 0.88);
  border: 1px solid rgba(15, 118, 110, 0.16);
  box-shadow: var(--shadow-soft);
}

.editing-banner strong {
  display: block;
}

.editing-banner p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.workspace-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.88fr);
}

.side-stack {
  display: grid;
  gap: 1rem;
}

.panel {
  padding: 1.05rem;
  border-radius: 22px;
}

.main-panel {
  min-height: 720px;
}

.panel-head,
.panel-subhead,
.subscription-head,
.node-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-head h2,
.panel-subhead h3,
.hero-stat strong,
.subscription-head strong {
  margin: 0;
}

.panel-head h2,
.panel-subhead h3 {
  font-family: var(--font-display);
  font-size: 1.08rem;
}

.panel-copy {
  margin: 0.32rem 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.9rem;
}

.panel-subhead p,
.subscription-head p,
.helper-copy,
.node-meta,
#parse-meta {
  margin: 0.35rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.panel-head {
  padding-bottom: 0.85rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid rgba(19, 35, 31, 0.08);
}

.panel-subhead {
  margin-bottom: 0.45rem;
}

.latency-note {
  margin: 0.55rem 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.93rem;
}

.form-stack,
.result-stack {
  display: grid;
  gap: 0.85rem;
}

.inline-settings {
  margin-top: 0.85rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
}

.compact-inline-settings {
  padding: 0.8rem 0.85rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(248, 251, 249, 0.72));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.compact-subhead {
  align-items: center;
}

.compact-subhead p {
  margin-top: 0.22rem;
  font-size: 0.88rem;
}

.test-settings-grid {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: minmax(0, 1.45fr) repeat(2, minmax(140px, 0.75fr));
  margin-top: 0.6rem;
}

.test-setting {
  padding: 0.68rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(19, 35, 31, 0.08);
  box-shadow: 0 10px 22px rgba(30, 63, 56, 0.05);
}

.test-setting-wide {
  min-width: 0;
}

.compact-stack {
  gap: 0.9rem;
}

.field-grid {
  display: grid;
  gap: 0.8rem;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field span {
  font-size: 0.88rem;
  font-weight: 600;
}

.helper-row,
.inline-actions,
.subscription-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-button {
  background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
  color: #f5fffd;
  box-shadow: 0 16px 28px rgba(17, 94, 89, 0.22);
}

.secondary-button {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(240, 245, 243, 0.78));
  color: var(--ink);
  border: 1px solid rgba(19, 35, 31, 0.08);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--line);
  color: var(--ink);
  backdrop-filter: blur(8px);
}

.small-button {
  min-height: 36px;
  padding: 0.45rem 0.85rem;
  font-size: 0.88rem;
}

.danger-button {
  color: var(--danger);
  border-color: rgba(164, 63, 44, 0.18);
  background: var(--danger-soft);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(30, 63, 56, 0.1);
}

.section-divider {
  height: 1px;
  margin: 1rem 0;
  background: linear-gradient(90deg, transparent 0%, var(--line) 20%, var(--line) 80%, transparent 100%);
}

.summary-strip,
.placeholder-list {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.summary-pill,
.tag,
.placeholder-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tag {
  font-size: 0.84rem;
  text-transform: uppercase;
}

.tag-secondary {
  background: rgba(19, 35, 31, 0.08);
  color: var(--ink);
}

.tag-active {
  background: rgba(15, 118, 110, 0.14);
  color: var(--accent-strong);
}

.tag-disabled {
  background: rgba(164, 63, 44, 0.12);
  color: var(--danger);
}

.placeholder-chip {
  font-family: var(--font-mono);
  background: rgba(19, 35, 31, 0.06);
  color: var(--ink);
}

.error-box {
  margin-top: 0.9rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 242, 238, 0.88);
  border: 1px solid rgba(164, 63, 44, 0.16);
  color: var(--danger);
}

.hidden {
  display: none;
}

.node-list,
.template-list,
.subscription-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.node-card,
.template-card,
.subscription-card {
  padding: 0.9rem;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(244, 248, 247, 0.86));
  border: 1px solid rgba(19, 35, 31, 0.08);
  box-shadow: var(--shadow-soft);
}

.subscription-card-disabled {
  border-color: rgba(164, 63, 44, 0.18);
  background: linear-gradient(180deg, rgba(255, 249, 247, 0.92), rgba(248, 241, 239, 0.88));
}

.node-editor-card {
  gap: 1rem;
}

.node-card-head {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}

.node-card-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.node-editor-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0.85rem;
}

.compact-field span {
  font-size: 0.82rem;
  color: var(--muted);
}

.compact-field input,
.compact-field select {
  min-height: 42px;
  padding: 0.72rem 0.85rem;
}

.boolean-field {
  display: grid;
  gap: 0.45rem;
}

.boolean-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.boolean-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 42px;
  padding: 0.25rem;
  border-radius: var(--radius-md);
  background: rgba(19, 35, 31, 0.05);
  border: 1px solid rgba(19, 35, 31, 0.08);
}

.boolean-option {
  min-height: 34px;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.boolean-option.active {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.16), rgba(17, 94, 89, 0.09));
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.12);
}

.probe-note {
  margin: 0.35rem 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.latency-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
}

.latency-badge-idle {
  background: rgba(19, 35, 31, 0.06);
  color: var(--muted);
}

.latency-badge-pending {
  background: rgba(190, 123, 36, 0.14);
  color: #8a5614;
}

.latency-badge-ok {
  background: rgba(15, 118, 110, 0.14);
  color: var(--accent-strong);
}

.latency-badge-limited {
  background: rgba(102, 88, 33, 0.14);
  color: #685921;
}

.latency-badge-fail {
  background: rgba(164, 63, 44, 0.12);
  color: var(--danger);
}

.template-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
}

.template-card-active {
  border-color: rgba(15, 118, 110, 0.2);
  background: linear-gradient(180deg, rgba(240, 252, 249, 0.96), rgba(247, 252, 250, 0.9));
}

.template-card-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.template-card p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  line-height: 1.45;
  word-break: break-all;
  font-size: 0.88rem;
}

.subscription-tags {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

.subscription-link {
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  word-break: break-all;
  background: rgba(19, 35, 31, 0.04);
  padding: 0.45rem 0.55rem;
  border-radius: 12px;
}

.empty-state {
  padding: 1.2rem;
  border: 1px dashed rgba(19, 35, 31, 0.18);
  border-radius: var(--radius-lg);
  color: var(--muted);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

#preview-output,
#result-url {
  font-family: var(--font-mono);
}

#preview-output {
  min-height: 240px;
}

@media (max-width: 1080px) {
  .hero-card,
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 1rem, 1380px);
    padding-top: 1rem;
  }

  .panel,
  .hero-card {
    padding: 1rem;
  }

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

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

  .test-settings-grid {
    grid-template-columns: 1fr;
  }

  .node-editor-grid {
    grid-template-columns: 1fr;
  }

  .helper-row,
  .inline-actions,
  .subscription-actions,
  .node-card-head,
  .node-card-actions,
  .editing-banner {
    align-items: stretch;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }
}
