:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1c1f2a;
  --muted: #6b7083;
  --border: #e3e5ee;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --danger: #c2373b;
  --danger-soft: #fdeeee;
  --ok: #1f8a4c;
  --ok-soft: #e7f6ed;
  --warn: #a8660b;
  --warn-soft: #fff4e0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 22, 40, .05), 0 4px 16px rgba(20, 22, 40, .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141b;
    --surface: #1b1e27;
    --text: #e7e9f0;
    --muted: #9196a8;
    --border: #2c303d;
    --accent: #8b85ff;
    --accent-soft: #252642;
    --danger: #f07a7d;
    --danger-soft: #3a2124;
    --ok: #5fd08f;
    --ok-soft: #1c3226;
    --warn: #f0b45a;
    --warn-soft: #3a2e1a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .4rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.row { display: flex; align-items: center; gap: .75rem; }
.between { justify-content: space-between; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 880px; margin: 0 auto; padding: 16px;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; font-size: .8rem; }

main { max-width: 880px; margin: 0 auto; padding: 0 16px 64px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.narrow { max-width: 400px; margin: 10vh auto 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-size: .9rem; font-weight: 500; text-decoration: none;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: .85rem; }

input[type=password], input[type=url] {
  width: 100%; font: inherit; padding: 10px 12px; margin: 12px 0;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
}
input[type=password]:focus, input[type=url]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#login-form .btn { width: 100%; padding: 10px; }
.error { color: var(--danger); }

.hero { margin: 1.5rem 0 1.25rem; }

.drive-row { display: flex; gap: 8px; margin-top: 12px; }
.drive-row input { margin: 0; flex: 1; min-width: 0; background: var(--surface); }
.drive-row .btn { flex-shrink: 0; }
.hint { margin: 6px 0 0; }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 36px 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.dropzone.busy { cursor: default; }
.dz-icon { font-size: 1.8rem; color: var(--accent); }
.dz-title { font-weight: 600; margin: .25rem 0; overflow-wrap: anywhere; }
.dz-uploading { text-align: left; }
.bar { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; margin: 10px 0 8px; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }


.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.history a {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); text-decoration: none;
}
.history a:hover { border-color: var(--accent); }
.h-main { flex: 1; min-width: 0; }
.h-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { flex-shrink: 0; font-size: .78rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.error { background: var(--danger-soft); color: var(--danger); }
.badge.processing, .badge.queued { background: var(--warn-soft); color: var(--warn); }

.back { display: inline-block; margin: .5rem 0 1rem; text-decoration: none; }
.job-head { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.filename { overflow-wrap: anywhere; font-size: 1.35rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.steps { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.steps li::before {
  content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0;
}
.steps li.done { color: var(--text); }
.steps li.done::before { background: var(--ok); border-color: var(--ok); }
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.active::before { border-color: var(--accent); border-top-color: transparent; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-card { background: var(--danger-soft); border-color: transparent; color: var(--danger); }

.markdown { overflow-wrap: anywhere; }
.markdown h1 { font-size: 1.45rem; margin-top: .25rem; }
.markdown h2 { font-size: 1.15rem; margin: 1.6rem 0 .5rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 1rem; margin: 1.2rem 0 .3rem; }
.markdown ul, .markdown ol { padding-left: 1.4rem; }
.markdown li { margin: .25rem 0; }
.markdown code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.markdown blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: .9rem;
  max-width: calc(100% - 32px);
}

@media (max-width: 600px) {
  h1 { font-size: 1.35rem; }
  .card { padding: 16px; }
  .actions .btn { flex: 1 1 auto; }
}
