:root {
  --bg: #0b0d14;
  --card: #141827;
  --card-2: #1a1f33;
  --line: #262c45;
  --text: #e8ebf5;
  --dim: #8b91ad;
  --accent: #7c5cff;
  --accent-2: #c04cff;
  --ok: #3ddc97;
  --warn: #ffb86b;
  --err: #ff6b81;
}
* { box-sizing: border-box }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(124, 92, 255, .16), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(192, 76, 255, .12), transparent 60%),
    var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
}
.wrap { max-width: 680px; margin: 0 auto; padding: 28px 20px 60px }

header.hero { text-align: center; margin-bottom: 26px }
header.hero h1 {
  margin: 0 0 6px;
  font-size: 34px;
  letter-spacing: -1px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
}
header.hero p { margin: 0; color: var(--dim); font-size: 14px }

.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.card h2 { margin: 0 0 14px; font-size: 17px; font-weight: 700 }
.hidden { display: none !important }

input, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0e1120;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}
input:focus, textarea:focus { border-color: var(--accent) }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 13px; resize: vertical; line-height: 1.5 }

button {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 11px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: transform .12s, opacity .2s;
}
button:hover { transform: translateY(-1px) }
button:disabled { opacity: .55; cursor: wait; transform: none }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--dim) }
button.ghost:hover { color: var(--text) }

.row { display: flex; gap: 10px; align-items: center; margin-top: 10px }
.row label { flex: 0 0 auto; color: var(--dim); font-size: 13px }
.row input#maxtokens { width: 90px }
.row input#instruction { flex: 1 }

.msg { color: var(--err); font-size: 13px; min-height: 1.2em }
.hint { color: var(--dim); font-size: 12.5px; margin: 10px 0 0 }

.bar { height: 10px; background: #0e1120; border: 1px solid var(--line); border-radius: 99px; overflow: hidden }
#barFill { height: 100%; width: 2%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s ease }
#stage { color: var(--dim); font-size: 14px }
#elapsed { color: var(--text); font-weight: 600 }

pre {
  white-space: pre-wrap;
  background: #0e1120;
  border: 1px solid var(--line);
  padding: 14px;
  border-radius: 10px;
  font-size: 12.5px;
  max-height: 240px;
  overflow: auto;
}
#draftState { font-size: 12px; color: var(--dim); font-weight: 400 }

/* history */
#history ul { list-style: none; margin: 0; padding: 0 }
#history li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent;
}
#history li:hover { background: #0e1120; border-color: var(--line) }
#history .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px }
#history .d { color: var(--dim); font-size: 11.5px; flex: 0 0 auto }
.badge { padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; flex: 0 0 auto }
.badge.done { background: rgba(61, 220, 151, .15); color: var(--ok) }
.badge.error { background: rgba(255, 107, 129, .15); color: var(--err) }
.badge.working { background: rgba(124, 92, 255, .18); color: var(--accent) }
.empty { color: var(--dim); font-size: 13px; text-align: center; padding: 10px }

/* advanced options */
details.controls { margin: 10px 0 2px; border: 1px solid var(--line); border-radius: 10px; background: #0e1120 }
details.controls summary { padding: 10px 14px; cursor: pointer; color: var(--dim); font-size: 13.5px; list-style: none }
details.controls summary::before { content: "▸ "; color: var(--accent) }
details.controls[open] summary::before { content: "▾ "; color: var(--accent) }
details.controls > div { padding: 0 14px 12px }
details.controls label { flex: 0 0 130px }
details.controls select, details.controls input[type="number"] {
  flex: 1; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: #141827; color: var(--text); font-size: 13px;
}
