:root {
  color-scheme: light;
  --bg: #f7f5ed;
  --ink: #151614;
  --muted: #61645e;
  --line: #d8d4c5;
  --panel: #fffdf6;
  --panel-strong: #eeeadc;
  --green: #1e8f62;
  --green-soft: #dff5e9;
  --red: #c4432f;
  --red-soft: #ffe2da;
  --yellow: #d6a51d;
  --blue: #2d6cdf;
  --shadow: 0 16px 40px rgba(21, 22, 20, 0.08);
  --radius: 8px;
  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;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.88), rgba(247, 245, 237, 0.94)),
    repeating-linear-gradient(90deg, rgba(21, 22, 20, 0.035) 0 1px, transparent 1px 72px),
    var(--bg);
}

a {
  color: inherit;
}

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

button {
  border: 0;
  cursor: pointer;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 10;
  transform: translateY(-140%);
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid rgba(21, 22, 20, 0.12);
  background: rgba(247, 245, 237, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  color: #fffdf6;
  background: var(--ink);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 246, 0.76);
}

.nav a {
  min-width: 92px;
  padding: 9px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-align: center;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.nav a.active {
  color: #fffdf6;
  background: var(--ink);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 56px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.hero-strip,
.panel,
.module-card,
.editor-shell,
.runner-shell {
  border: 1px solid rgba(21, 22, 20, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 253, 246, 0.88);
  box-shadow: var(--shadow);
}

.hero-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  padding: 26px;
  margin-bottom: 18px;
  overflow: hidden;
}

.eyebrow,
.module-kind,
.stat-label {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 10px;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 0.95;
}

h2 {
  font-size: 24px;
  line-height: 1.15;
}

h3 {
  font-size: 16px;
}

p {
  color: var(--muted);
  line-height: 1.6;
}

.hero-copy {
  max-width: 720px;
  font-size: 17px;
}

.hero-meter {
  display: grid;
  min-width: 220px;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat {
  min-height: 90px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--panel-strong);
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  margin: 18px 0;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf6;
  color: var(--ink);
  outline: 0;
}

.input,
.select {
  min-height: 44px;
  padding: 0 12px;
}

.textarea {
  min-height: 132px;
  padding: 12px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fffdf6;
  text-decoration: none;
  font-weight: 800;
}

.button.secondary {
  border: 1px solid var(--line);
  background: #fffdf6;
  color: var(--ink);
}

.button.warning {
  background: var(--red);
}

.button:focus,
.input:focus,
.select:focus,
.textarea:focus {
  outline: 3px solid rgba(30, 143, 98, 0.22);
  outline-offset: 2px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.module-card {
  min-height: 238px;
  padding: 18px;
  transition: transform 160ms ease, border-color 160ms ease;
}

.module-card:hover {
  transform: translateY(-2px);
  border-color: rgba(30, 143, 98, 0.4);
}

.module-link {
  display: block;
  min-height: 154px;
  text-decoration: none;
}

.module-card h2 {
  margin: 8px 0;
}

.tag-row,
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.tag,
.pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--green-soft);
  color: #126340;
  font-size: 12px;
  font-weight: 800;
}

.pill.red {
  background: var(--red-soft);
  color: var(--red);
}

.pill.blue {
  background: #e5edff;
  color: var(--blue);
}

.panel {
  padding: 18px;
}

.note-panel {
  border-color: rgba(196, 67, 47, 0.26);
  background: linear-gradient(180deg, rgba(255, 226, 218, 0.56), rgba(255, 253, 246, 0.9));
}

.sidebar {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 14px;
}

.list-plain {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.list-plain a {
  display: block;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  font-weight: 700;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
}

.code-block,
.result-table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #151614;
}

.code-block pre {
  margin: 0;
  padding: 16px;
  color: #f8f4e8;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.result-table-wrap {
  background: #fffdf6;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--panel-strong);
  font-size: 12px;
  text-transform: uppercase;
}

tr.SUCCESS td:first-child {
  color: var(--green);
  font-weight: 800;
}

tr.ERROR td:first-child {
  color: var(--red);
  font-weight: 800;
}

tr.INFO td:first-child {
  color: var(--blue);
  font-weight: 800;
}

.editor-shell,
.runner-shell {
  padding: 20px;
}

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

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

.form-field.full {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.runner-console {
  display: grid;
  gap: 14px;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-strong);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--red));
  transition: width 180ms ease;
}

.runner-frame {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.empty-state,
.loading-panel {
  display: grid;
  min-height: 280px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.loading-orbit {
  width: 42px;
  height: 42px;
  border: 4px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: min(360px, calc(100% - 36px));
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fffdf6;
  box-shadow: var(--shadow);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 880px) {
  .topbar,
  .hero-strip,
  .workspace,
  .detail-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    align-items: stretch;
  }

  .nav {
    width: 100%;
    overflow-x: auto;
  }

  .nav a {
    min-width: 0;
    flex: 1;
  }

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

  .sidebar {
    position: static;
  }

  h1 {
    font-size: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
