:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #181c20;
  --panel-2: #20262b;
  --line: #343c42;
  --text: #f3f5f1;
  --muted: #a8b1aa;
  --accent: #61c0bf;
  --gold: #e3b448;
  --bad: #dc6b5d;
  --ok: #9fd37b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #101214;
}

.login-screen.is-hidden {
  display: none;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(380px, 100%);
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

.app {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 2px 0 0;
  font-size: 24px;
}

.run-picker {
  display: flex;
  gap: 8px;
  align-items: center;
}

.user-badge {
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--line);
}

.tab,
button,
select,
input {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 6px;
}

button {
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

.tab {
  border-bottom: 0;
  min-height: 38px;
}

.tab.is-active {
  background: var(--panel);
  color: #fff;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06100f;
  font-weight: 700;
}

.panel {
  display: none;
  min-height: 0;
  padding: 14px;
}

.panel.is-active {
  display: block;
}

.config-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  min-height: calc(100vh - 132px);
}

.files-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 280px;
  gap: 14px;
  min-height: calc(100vh - 132px);
}

.controls,
.editor-wrap,
.progress-card,
article {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.controls {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.check {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
}

input,
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 0 10px;
}

input[type="file"] {
  min-height: 0;
  padding: 7px;
  overflow: hidden;
}

.controls > button {
  width: 100%;
}

.editor-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.section-title {
  padding: 10px 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}

.section-title.flush {
  margin: -14px -14px 0;
}

.section-title.inline-title {
  padding: 0 0 8px;
  border-bottom: 0;
}

.hint {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.template-links {
  display: grid;
  gap: 6px;
}

.template-links a {
  color: var(--accent);
}

.table-wrap a,
.link-button {
  color: var(--accent);
}

.link-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
}

.admin-panel {
  display: none;
}

.admin-panel.is-visible {
  display: grid;
}

textarea {
  width: 100%;
  height: 100%;
  min-height: 560px;
  resize: none;
  padding: 12px;
  border: 0;
  outline: 0;
  background: #0f1214;
  color: #edf2ea;
  font-family: Consolas, Menlo, monospace;
  font-size: 13px;
  line-height: 1.45;
}

.message {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.progress-layout {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(0, 1fr);
  gap: 14px;
}

.progress-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
}

.pulse {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0 34%, rgba(97, 192, 191, 0.16) 36% 100%);
  animation: breathe 1.8s ease-in-out infinite;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(0.92);
    opacity: 0.62;
  }
  50% {
    transform: scale(1.03);
    opacity: 1;
  }
}

.status-text {
  font-size: 22px;
  font-weight: 800;
}

.stage-text,
.progress-meta,
.badges,
.download {
  color: var(--muted);
}

.bar {
  grid-column: 1 / -1;
  height: 12px;
  overflow: hidden;
  border-radius: 4px;
  background: #0e1113;
  border: 1px solid var(--line);
}

.bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 260ms ease;
}

.progress-meta {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  gap: 8px;
}

.badge {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.badge::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: #687078;
}

.badge.is-ready {
  color: var(--ok);
  border-color: rgba(159, 211, 123, 0.55);
}

.badge.is-ready::before {
  background: var(--ok);
}

#viewerFrame {
  width: 100%;
  height: calc(100vh - 132px);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1011;
}

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

article {
  min-width: 0;
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 210px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-card {
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-card strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
}

.download {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin-top: 12px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
}

@media (max-width: 980px) {
  .config-grid,
  .progress-layout,
  .files-layout,
  .split,
  .summary-grid {
    grid-template-columns: 1fr;
  }
}
