:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #1c2327;
  --muted: #667277;
  --line: #dce3e6;
  --accent: #167a6d;
  --accent-dark: #0f5d53;
  --accent-soft: #e5f5f2;
  --warning: #c77a12;
  --danger: #ba3939;
  --shadow: 0 18px 45px rgba(24, 38, 42, 0.1);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 24px;
  background: #eef3f4;
  border-right: 1px solid var(--line);
}

.brand,
.toolbar,
.topbar,
.editor-actions,
.stage-row,
.filters {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 800;
  background: #1c2327;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.4rem, 3vw, 2.35rem);
}

h3 {
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.toolbar {
  gap: 10px;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 750;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.primary-button {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  background: var(--accent);
}

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

.ghost-button,
.icon-button {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.ghost-button:hover,
.icon-button:hover {
  border-color: #aebdc2;
}

.danger-button {
  color: var(--danger);
  background: #fff;
  border-color: #f0c9c9;
}

.danger-button:hover {
  background: #fff4f4;
}

.icon-button {
  display: grid;
  flex: 0 0 42px;
  place-items: center;
  padding: 0;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.field.compact {
  gap: 6px;
}

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

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 122, 109, 0.14);
}

.filters {
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  background: #fff;
  font-size: 0.83rem;
  font-weight: 750;
}

.filter-chip.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: #b9ded8;
}

.script-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.script-item {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-align: left;
  background: #fff;
}

.script-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 122, 109, 0.12);
}

.script-item-title {
  color: var(--ink);
  font-weight: 800;
}

.script-item-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.status-pill {
  justify-self: start;
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.72rem;
  font-weight: 800;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.empty-state,
.editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 34px;
  text-align: center;
}

.empty-state p {
  max-width: 520px;
  color: var(--muted);
}

.editor {
  padding: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(150px, 1fr) minmax(220px, 1.2fr) minmax(160px, 0.9fr);
  gap: 14px;
  margin-bottom: 18px;
}

.stage-row {
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.stage-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--muted);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 800;
}

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

.stage-button.done {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: #b9ded8;
}

.links-panel {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

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

.editor-actions {
  justify-content: space-between;
  gap: 14px;
  margin-top: 22px;
}

.editor-actions > div {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .script-list {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  }

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

@media (max-width: 720px) {
  .sidebar,
  .workspace {
    padding: 18px;
  }

  .topbar,
  .editor-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .editor-actions > div {
    justify-content: stretch;
  }

  .topbar-actions button,
  .editor-actions button {
    flex: 1;
  }

  .form-grid,
  .links-grid {
    grid-template-columns: 1fr;
  }
}
