:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f242d;
  --text: #e6e8ec;
  --muted: #8a93a4;
  --accent: #6aa9ff;
  --accent-2: #4f8cff;
  --ok: #5fd07a;
  --warn: #f0b14a;
  --err: #ff6b6b;
  --border: #2a313d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

header {
  padding: 28px 24px 8px;
  max-width: 960px;
  margin: 0 auto;
}
header h1 { margin: 0 0 6px; font-size: 22px; }
header .hint { color: var(--muted); margin: 0; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 24px 64px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: var(--panel);
  padding: 28px;
  text-align: center;
  transition: border-color .15s, background .15s;
  position: relative;
}
.dropzone.drag {
  border-color: var(--accent);
  background: #1a2230;
}
.dz-text { margin: 0 0 6px; font-size: 16px; }
.dz-sub { margin: 0; color: var(--muted); font-size: 13px; }

.dropzone button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  padding: 0;
}

#preview {
  display: block;
  max-width: 100%;
  max-height: 360px;
  margin: 16px auto 0;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.thumb {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-2);
}
.thumb img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
}
.thumb-label {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
}
.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.thumb-remove:hover { background: rgba(220, 60, 60, 0.85); }

.actions {
  display: flex;
  gap: 10px;
  margin: 16px 0;
  align-items: center;
}

button#run, button#reset {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-2);
}
button#run {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: white;
  font-weight: 600;
}
button#run:disabled {
  background: #2a313d;
  border-color: #2a313d;
  color: var(--muted);
  cursor: not-allowed;
}
button.ghost { background: transparent; }

.status {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}
.status.err { color: var(--err); border-color: #5a2929; }

.tasks h2 { font-size: 18px; margin: 8px 0 10px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th { background: var(--panel-2); color: var(--muted); font-weight: 500; font-size: 13px; }
tr:last-child td { border-bottom: none; }
td.num, th.num { width: 56px; font-variant-numeric: tabular-nums; }
td.answer { font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge.thinking { color: var(--accent); border-color: #2c3e5e; background: #142036; }
.badge.searching { color: var(--warn); border-color: #4a3a1a; background: #2a2418; }
.badge.ok { color: var(--ok); border-color: #1f3d2a; background: #142a1c; }
.badge.err { color: var(--err); border-color: #4a2222; background: #2a1414; }

details#raw {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--muted);
}
details#raw pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  max-height: 360px;
  overflow: auto;
  margin: 8px 0 0;
}

tr.task-text td {
  padding: 0 12px 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
tr.task-text details {
  color: var(--muted);
  font-size: 12px;
}
tr.task-text summary {
  cursor: pointer;
  padding: 4px 0;
}
tr.task-text pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 6px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  background: var(--panel-2);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

details#ocr {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
details#ocr summary {
  cursor: pointer;
}
details#ocr pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 8px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  background: var(--panel-2);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  max-height: 300px;
  overflow: auto;
}
