:root {
  color-scheme: dark;
  --bg-a: #07111d;
  --bg-b: #102845;
  --bg-c: #0f1b2e;
  --panel: rgba(8, 15, 28, 0.82);
  --panel-strong: rgba(11, 21, 39, 0.94);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(131, 194, 255, 0.34);
  --text: #f4f8ff;
  --muted: #9aacbf;
  --soft: #d2dded;
  --accent: #8ac7ff;
  --accent-2: #8ff0c8;
  --warning: #ffd58a;
  --danger: #ff8f9b;
  --ok: #86efac;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "IBM Plex Sans", "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 18%, rgba(138, 199, 255, 0.18), transparent 28%),
    radial-gradient(circle at 82% 12%, rgba(143, 240, 200, 0.14), transparent 24%),
    radial-gradient(circle at 70% 78%, rgba(255, 213, 138, 0.08), transparent 22%),
    linear-gradient(155deg, var(--bg-a), var(--bg-b) 55%, var(--bg-c));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.28), transparent 90%);
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 36px 20px 56px;
}

.container {
  width: min(100%, 1220px);
}

.dashboard {
  display: grid;
  gap: 18px;
}

.hero,
.panel,
.card,
.editor,
.warning,
.statusbar {
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero {
  padding: 30px;
  border-radius: 28px;
}

.kicker {
  margin: 0 0 12px;
  color: var(--accent-2);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
  gap: 22px;
  align-items: start;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.lead {
  margin: 16px 0 0;
  color: var(--soft);
  font-size: 1rem;
  line-height: 1.6;
  max-width: 72ch;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
}

.badge[data-tone="ok"] {
  border-color: rgba(134, 239, 172, 0.26);
  color: #bbf7d0;
}

.badge[data-tone="warn"] {
  border-color: rgba(255, 213, 138, 0.28);
  color: #ffe6b8;
}

.badge[data-tone="danger"] {
  border-color: rgba(255, 143, 155, 0.28);
  color: #ffc3cd;
}

.hero-aside {
  display: grid;
  gap: 14px;
}

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

.metric,
.small-card {
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  padding: 16px;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-value {
  display: block;
  margin-top: 6px;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.metric-note {
  display: block;
  margin-top: 8px;
  color: var(--soft);
  font-size: 0.88rem;
  line-height: 1.45;
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

button,
input,
textarea {
  font: inherit;
}

.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  min-height: 48px;
  padding: 0 16px;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(138, 199, 255, 0.42);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.18);
}

.btn.primary {
  border-color: rgba(138, 199, 255, 0.45);
  background: linear-gradient(180deg, rgba(138, 199, 255, 0.24), rgba(138, 199, 255, 0.11));
}

.btn.ghost {
  color: var(--soft);
}

.btn.btn-small {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 14px;
  font-size: 0.84rem;
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1.1fr 0.9fr;
}

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

.panel h2,
.panel h3,
.editor h2 {
  margin: 0;
  letter-spacing: -0.03em;
}

.panel-header,
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

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

.stage-list,
.run-list,
.source-grid,
.cluster-list {
  display: grid;
  gap: 12px;
}

.stage-item,
.run-item,
.source-item,
.cluster-item {
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
}

.stage-top,
.run-top,
.source-top,
.cluster-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stage-title,
.run-title,
.source-title,
.cluster-title {
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.pill[data-tone="ok"] {
  color: #b7f7d0;
  background: rgba(134, 239, 172, 0.09);
}

.pill[data-tone="warn"] {
  color: #ffe2b0;
  background: rgba(255, 213, 138, 0.09);
}

.pill[data-tone="danger"] {
  color: #ffc1c9;
  background: rgba(255, 143, 155, 0.09);
}

.pill[data-tone="accent"] {
  color: #cfe8ff;
  background: rgba(138, 199, 255, 0.09);
}

.stage-meta,
.run-meta,
.source-meta,
.cluster-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.editor {
  border-radius: 26px;
  padding: 22px;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field input,
.field textarea {
  width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(4, 9, 18, 0.72);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
}

.field textarea {
  min-height: 420px;
  resize: vertical;
  line-height: 1.5;
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.9rem;
}

.field input:focus,
.field textarea:focus {
  border-color: rgba(138, 199, 255, 0.52);
  box-shadow: 0 0 0 3px rgba(138, 199, 255, 0.08);
}

.warning {
  border-radius: 20px;
  padding: 16px 18px;
  border-color: rgba(255, 213, 138, 0.28);
  color: #ffe6b8;
}

.statusbar {
  border-radius: 20px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.statusline {
  color: var(--soft);
  font-size: 0.95rem;
}

.details {
  display: grid;
  gap: 14px;
}

.draft {
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: pre-wrap;
  line-height: 1.55;
}

.reddit-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.reddit-export-controls {
  margin-top: -2px;
}

.reddit-btn {
  white-space: nowrap;
  min-height: 48px;
}

.export-status {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
}

.export-status-line {
  color: var(--soft);
  font-size: 0.92rem;
  line-height: 1.45;
}

.export-status-line.danger {
  color: #ffc3cd;
}

.item-list {
  display: grid;
  gap: 10px;
}

.item-row {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  padding: 14px 16px;
}

.item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.item-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
}

.item-date {
  font-size: 0.85rem;
}

.item-title {
  font-weight: 700;
  line-height: 1.4;
}

.item-link {
  color: var(--accent);
  text-decoration: none;
}

.item-link:hover {
  text-decoration: underline;
}

.footer-note {
  color: var(--muted);
  font-size: 0.9rem;
}

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

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

@media (max-width: 860px) {
  .reddit-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 18px 12px 40px;
  }

  .hero,
  .panel,
  .editor {
    padding: 18px;
    border-radius: 22px;
  }

  .metric-grid,
  .actions {
    grid-template-columns: 1fr;
  }

  .statusbar,
  .stage-top,
  .run-top,
  .source-top,
  .cluster-top,
  .panel-header,
  .editor-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
