:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef3f2;
  --text: #15201d;
  --muted: #5f6f69;
  --line: #d7dfdc;
  --accent: #0f7f6f;
  --accent-strong: #0a5f54;
  --warn: #a35f00;
  --danger: #a53535;
  --ok: #237a4d;
  --shadow: 0 12px 30px rgba(22, 38, 34, .08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: #e3ece9;
  color: var(--text);
}

button.secondary:hover {
  background: #d4e0dc;
}

button.ghost {
  background: transparent;
  color: var(--accent-strong);
  border: 1px solid var(--line);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

.topbar {
  min-height: 64px;
  padding: 0 clamp(16px, 4vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

.brand,
.topnav a {
  color: var(--text);
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 760;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
}

.topnav {
  display: flex;
  gap: 8px;
}

.topnav a {
  padding: 9px 11px;
  border-radius: 7px;
}

.topnav a:hover {
  background: var(--surface-soft);
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 30px);
}

.split-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: clamp(20px, 5vw, 56px);
  align-items: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .78rem;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.12;
}

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
}

h2 {
  font-size: clamp(1.35rem, 3vw, 2rem);
}

h3 {
  font-size: 1.05rem;
}

.muted,
.form-note {
  color: var(--muted);
}

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

.auth-stack {
  display: grid;
  gap: 18px;
}

.form-stack label {
  display: grid;
  gap: 7px;
  font-weight: 690;
}

.form-note {
  margin: 0;
  font-size: .92rem;
}

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

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(320px, 1.05fr);
  gap: 18px;
  align-items: start;
}

.sidebar {
  display: grid;
  gap: 10px;
  align-content: start;
}

.station-button {
  width: 100%;
  min-height: 54px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.station-button.active {
  border-color: var(--accent);
  background: #e9f5f2;
}

.station-button.locked {
  opacity: .55;
  cursor: not-allowed;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .8rem;
  white-space: nowrap;
}

.status-pill.ok {
  background: #dff2e8;
  color: var(--ok);
}

.status-pill.warn {
  background: #fff0d8;
  color: var(--warn);
}

.task-list {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.task-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.task-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.audio-material {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.audio-material audio {
  display: block;
  width: 100%;
}

.file-material {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.file-material a {
  color: var(--accent-strong);
  font-weight: 700;
  white-space: nowrap;
}

.station-materials {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.result-space {
  margin-top: 16px;
}

.circuit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.circuit-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.material-fields {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
}

.material-header,
.material-row-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.material-list {
  display: grid;
  gap: 8px;
}

.material-item,
.material-upload-box {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.material-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.material-item-main {
  display: grid;
  gap: 3px;
}

.material-item-main strong,
.material-item-main span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.material-item-actions {
  display: flex;
  gap: 6px;
}

.material-add-button {
  justify-self: start;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 1.25rem;
  line-height: 1;
}

.material-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.solution-box,
.feedback-box {
  margin-top: 12px;
  border-left: 4px solid var(--accent);
  background: #edf7f4;
  padding: 12px;
}

.feedback-box {
  border-color: #486baf;
  background: #edf2ff;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.toolbar.compact {
  margin-bottom: 10px;
}

.station-editor {
  display: grid;
  gap: 14px;
}

.station-edit {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

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

th {
  color: var(--muted);
  font-size: .85rem;
  font-weight: 760;
}

.answer {
  max-width: 360px;
  white-space: pre-wrap;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.error {
  border-color: #f2c7c7;
  background: #fff5f5;
  color: var(--danger);
}

@media (max-width: 800px) {
  .split-panel,
  .layout,
  .editor-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 12px;
    padding-bottom: 12px;
    gap: 10px;
  }

  .topnav {
    width: 100%;
  }

  .topnav a {
    flex: 1;
    text-align: center;
  }

  .file-material,
  .material-row-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .material-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}
