:root {
  color-scheme: light;
  --bg: #edf2f4;
  --ink: #172033;
  --muted: #66768a;
  --paper: #ffffff;
  --line: #d8e0e8;
  --green: #16845f;
  --blue: #286fb4;
  --amber: #b07818;
  --danger: #b42318;
  --shadow: 0 18px 46px rgba(25, 39, 54, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(22, 132, 95, 0.13), transparent 34%),
    linear-gradient(300deg, rgba(176, 120, 24, 0.13), transparent 32%),
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

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

.sidebar {
  min-height: 100vh;
  padding: 22px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 28px;
  background: #15202f;
  color: #f8fafc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #15202f;
  font-weight: 800;
}

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

.brand small,
.build {
  color: #b7c3d2;
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  color: #dfe7f0;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 8px;
}

nav a.active,
nav a:hover {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.build {
  align-self: end;
}

.workspace {
  padding: 28px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.toolbar,
.metric,
.composer,
.response-card {
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 22px;
}

.toolbar p {
  margin: 0 0 6px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
}

h2 {
  font-size: 18px;
}

.status-badge {
  padding: 10px 12px;
  border-radius: 8px;
  background: #edf7f2;
  color: var(--green);
  border: 1px solid #bde0d1;
  font-weight: 700;
}

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

.metric {
  min-height: 118px;
  padding: 18px;
  display: grid;
  gap: 12px;
  border-top-width: 5px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  font-size: 38px;
  line-height: 1;
}

.metric-green { border-top-color: var(--green); }
.metric-blue { border-top-color: var(--blue); }
.metric-amber { border-top-color: var(--amber); }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.composer,
.response-card {
  padding: 20px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.mode-card {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid #bfccd9;
  border-radius: 8px;
  background: #fbfdff;
  cursor: pointer;
}

.mode-card input {
  width: 18px;
  height: 18px;
}

.mode-card.is-active {
  border-color: var(--blue);
  background: #edf6ff;
}

.mode-panel[hidden] {
  display: none;
}

.queue-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.progress-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: 2px 0 16px;
}

progress {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #dce5ed;
}

progress::-webkit-progress-bar {
  background: #dce5ed;
}

progress::-webkit-progress-value {
  background: var(--green);
}

progress::-moz-progress-bar {
  background: var(--green);
}

#progressText {
  min-width: 68px;
  color: var(--muted);
  font-weight: 700;
  text-align: right;
}

label {
  color: var(--ink);
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid #bfccd9;
  border-radius: 8px;
  background: #fbfdff;
  color: var(--ink);
  padding: 12px;
  outline: none;
}

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

input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(40, 111, 180, 0.13);
}

input:disabled,
textarea:disabled {
  color: #8a9aab;
  background: #eef3f7;
}

.form-row,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.check input {
  width: 18px;
  height: 18px;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.button-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#sendButton,
#stopButton {
  min-width: 150px;
  padding: 12px 18px;
  color: #ffffff;
}

#sendButton {
  background: var(--blue);
}

#stopButton {
  background: var(--danger);
}

#sendButton:disabled,
#stopButton:disabled {
  cursor: wait;
  opacity: 0.65;
}

.panel-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-head button {
  padding: 8px 10px;
  color: var(--muted);
  background: #eef3f7;
}

.side-panel {
  display: grid;
  gap: 18px;
}

pre {
  min-height: 240px;
  margin: 14px 0 0;
  padding: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-radius: 8px;
  background: #111827;
  color: #e5eef7;
  font-size: 13px;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-row,
.history-empty {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.history-row {
  display: grid;
  gap: 5px;
}

.history-row span,
.history-row small,
.history-empty {
  color: var(--muted);
}

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

  .sidebar {
    min-height: auto;
    grid-template-rows: auto;
  }

  nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .build {
    align-self: auto;
  }

  .content-grid,
  .metric-grid,
  .mode-switch,
  .queue-grid {
    grid-template-columns: 1fr;
  }
}

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

  .toolbar,
  .form-row,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 28px;
  }

  .button-row,
  #sendButton,
  #stopButton {
    width: 100%;
  }
}
