:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel2: #20242d;
  --line: #2a2f3a;
  --text: #e8eaef;
  --muted: #9aa1ae;
  --accent: #e0a458;
  --accent-ink: #1a1206;
  --ok: #6cc28a;
  --warn: #e0a458;
  --bad: #e06c6c;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
body.center { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 18px 0 10px; }
.muted { color: var(--muted); font-size: 14px; }
.err { color: var(--bad); }
.hidden { display: none !important; }

header.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(15, 17, 21, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
header.top img { width: 28px; height: 28px; }
header.top .title { font-weight: 650; font-size: 18px; flex: 1; }
.iconbtn { background: none; border: 0; color: var(--muted); font-size: 22px; padding: 4px 6px; cursor: pointer; }

main { max-width: 680px; margin: 0 auto; padding: 12px 16px; }

.auth { width: 100%; max-width: 360px; text-align: center; }
.auth form { text-align: left; margin-top: 16px; }

label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 0; }
input, textarea, select {
  width: 100%; margin-top: 6px; padding: 12px 14px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  font: inherit; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }

button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 14px; padding: 13px 16px;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 12px; font: inherit; font-weight: 650; cursor: pointer;
}
button.ghost { background: var(--panel2); color: var(--text); }
button.small { width: auto; margin: 0; padding: 7px 12px; font-size: 14px; font-weight: 550; }
button:disabled { opacity: .55; }

.ask {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px; margin: 4px 0 18px; border-radius: var(--radius);
  background: linear-gradient(135deg, #e0a458, #d07a4a); color: var(--accent-ink);
  text-decoration: none; font-weight: 700; font-size: 17px;
}

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin: 10px 0;
}
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.card .body { white-space: pre-wrap; margin-top: 6px; }
.card.tap { cursor: pointer; }

.chip {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  background: var(--panel2); color: var(--muted); font-size: 12px;
}
.st-ready { color: var(--ok); }
.st-pending, .st-processing { color: var(--warn); }
.st-queued_pc { color: #8fb3e0; }
.st-error { color: var(--bad); }

.seg { display: flex; gap: 6px; margin: 6px 0 2px; flex-wrap: wrap; }
.seg button { width: auto; flex: 1; margin: 0; padding: 9px 10px; background: var(--panel); color: var(--muted); border: 1px solid var(--line); font-weight: 550; }
.seg button.on { background: var(--panel2); color: var(--text); border-color: var(--accent); }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(20, 22, 28, .97); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  margin: 0; border-radius: 0; background: none; color: var(--muted);
  flex-direction: column; gap: 2px; padding: 9px 4px 10px; font-size: 12px; font-weight: 550;
}
nav.tabs button span { font-size: 21px; line-height: 1; }
nav.tabs button.on { color: var(--accent); }

.chunk { border-top: 1px solid var(--line); padding: 10px 0; }
.chunk a { font-size: 13px; text-decoration: none; }
.md { white-space: pre-wrap; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(86px + env(safe-area-inset-bottom));
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 12px; z-index: 20; max-width: 90vw;
}
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

/* job progress */
.job { margin-top: 10px; }
.bar { height: 6px; border-radius: 99px; background: var(--panel2); overflow: hidden; margin: 8px 0 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .6s ease; }
.bar.indet > i { width: 35%; animation: indet 1.3s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.steps { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; }
.steps li { display: flex; gap: 8px; align-items: center; padding: 2px 0; color: var(--muted); }
.steps li .ic { width: 18px; text-align: center; }
.steps li.done { color: var(--ok); }
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.waiting { color: var(--warn); }
.steps li.error { color: var(--bad); }
.steps li.queued_pc { color: #8fb3e0; }
.headline { font-size: 14px; font-weight: 600; }
.headline.st-ready { color: var(--ok); }

/* original links + auto-summary */
a.orig { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
  background: var(--panel2); color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 600; }
a.orig.big { padding: 9px 14px; font-size: 15px; }
.banner { border-color: #3a3326; background: #1d1a14; font-size: 14px; }
.notice { margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: #1c2230; color: #b9c7e0; font-size: 13px; line-height: 1.45; }
