:root {
  color-scheme: dark;
  --bg: #121820;
  --bg-soft: #18212b;
  --panel: #f7faf8;
  --panel-strong: #ffffff;
  --ink: #15202b;
  --muted: #66717c;
  --line: #d8e0df;
  --accent: #0b7c75;
  --accent-strong: #075c57;
  --amber: #c98718;
  --danger: #9f2d20;
  --radius: 6px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
  font-family: Inter, Segoe UI, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: #eef4f2;
}

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

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

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

.icon-button {
  width: 42px;
  min-height: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 2px 18px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1;
  letter-spacing: 0;
}

.topbar p {
  margin: 8px 0 0;
  color: #b9c5c8;
  font-size: 15px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.config-panel,
.preview-panel,
.small-panel {
  padding: 18px;
}

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

.section-title h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.section-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e8f4f2;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
}

.field span {
  color: #40505c;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 124, 117, 0.14);
}

.field-grid,
.lower-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.preview-column {
  display: grid;
  gap: 16px;
}

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

.button-row.compact {
  justify-content: flex-end;
}

.exercise-preview {
  display: grid;
  gap: 10px;
  max-height: 56vh;
  overflow: auto;
  padding-right: 4px;
}

.empty-state {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.exercise-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 13px;
}

.exercise-card h3 {
  margin: 0 0 7px;
  font-size: 14px;
}

.exercise-card p {
  margin: 0;
  color: #27333d;
  line-height: 1.45;
}

.list-stack {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.list-item {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: var(--radius);
  padding: 10px;
}

.list-item strong {
  display: block;
  font-size: 13px;
}

.list-item span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 4px;
}

.settings-dialog {
  width: min(520px, calc(100% - 24px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(7, 11, 15, 0.68);
}

.dialog-body {
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .exercise-preview {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    padding-bottom: 12px;
  }

  .topbar p {
    max-width: 260px;
  }

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

  .button-row,
  .button-row.compact {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  button {
    width: 100%;
  }
}

@media print {
  body {
    background: white;
    color: black;
  }
}
