:root {
  --brand: #2b6cb0;
  --bg: #f7f8fa;
  --card: #ffffff;
  --border: #e2e5ea;
  --text: #1a202c;
  --muted: #667085;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
}

header h1 { font-size: 1.1rem; margin: 0; }

.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand .logo { height: 36px; width: auto; max-width: 160px; object-fit: contain; }
.brand .tagline { font-size: 0.72rem; color: var(--muted); margin-top: 0.15rem; letter-spacing: 0.02em; }

#authArea { position: relative; }
.auth-area-row { display: flex; align-items: center; gap: 0.75rem; }
/* Two classes on the selector (not just one) so this reliably wins over the plain
   button.secondary rule further down regardless of source order - both target the
   same button, and button.secondary's own element+class specificity would otherwise
   override a bare .sign-out-btn rule. */
button.secondary.sign-out-btn {
  background: #000;
  color: #fff;
  border-color: #000;
}
button.secondary.sign-out-btn:hover,
button.secondary.sign-out-btn:focus,
button.secondary.sign-out-btn:active {
  background: #000;
  color: #fff;
  border-color: #000;
}

.history-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  max-width: min(90vw, 380px);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  padding: 0.85rem;
  text-align: left;
  z-index: 30;
}
.history-progress-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 0.6rem;
}
.history-progress-track > div {
  height: 100%;
  width: 30%;
  background: var(--brand);
  animation: indeterminate-slide 1.1s ease-in-out infinite;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
}
.history-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.15rem;
}
.history-close:hover { color: #c0392b; }
.history-empty { color: var(--muted); font-size: 0.85rem; padding: 0.4rem 0; }
.history-item { border-top: 1px solid var(--border); padding: 0.6rem 0; }
.history-item:first-child { border-top: none; padding-top: 0; }
.history-batch {
  background: #f7f0f4;
  border: 1px solid var(--brand);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.6rem;
}
.history-batch .history-name { color: var(--brand); font-weight: 600; }
.history-name {
  font-size: 0.85rem;
  font-weight: 600;
  word-break: break-all;
  overflow-wrap: anywhere;
  margin-bottom: 0.3rem;
}
.history-meta { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.4rem; line-height: 1.4; }
.history-row { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.history-row code { flex: 1 1 auto; min-width: 0; word-break: break-all; font-size: 0.75rem; }
.history-row button { font-size: 0.75rem; padding: 0.3rem 0.6rem; flex-shrink: 0; }

main {
  max-width: 560px;
  margin: 3rem auto;
  padding: 0 1.5rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 1.5rem;
}
.dropzone.dragover { border-color: var(--brand); color: var(--brand); }
.dropzone-alt { margin: 0.4rem 0 0; font-size: 0.85rem; }
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--brand);
  text-decoration: underline;
  font-size: inherit;
  cursor: pointer;
}

.field { margin-bottom: 1.25rem; }
.field label { display: block; font-size: 0.9rem; margin-bottom: 0.4rem; color: var(--muted); }
.field input[type="range"] { width: 100%; }
.field .row { display: flex; justify-content: space-between; align-items: center; }

button.primary {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  cursor: pointer;
}
button.primary:disabled { background: #a0aec0; cursor: not-allowed; }

button.primary.loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}
button.primary.loading::before {
  content: '';
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-track.indeterminate > div {
  width: 30% !important;
  animation: indeterminate-slide 1.1s ease-in-out infinite;
}
@keyframes indeterminate-slide {
  0%   { margin-left: -30%; }
  100% { margin-left: 100%; }
}

.progress {
  margin-top: 1rem;
  display: none;
}
.progress-track {
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}
.progress-track > div { height: 100%; background: var(--brand); width: 0%; transition: width 0.15s; }
.progress-info {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.cancel-btn {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  padding: 0.5rem;
}
.cancel-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.result {
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 8px;
  background: #edf7ed;
  border: 1px solid #b7e4c7;
  display: none;
  word-break: break-all;
}

.result-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}
.result-list li {
  padding: 0.6rem 0;
  border-top: 1px solid #b7e4c7;
}
.result-list li:first-child { border-top: none; padding-top: 0; }
.result-list li.result-batch {
  background: #f7f0f4;
  border: 1px solid var(--brand);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.6rem;
}
.result-list li.result-batch + li { border-top: none; padding-top: 0.6rem; }
.result-list li.result-batch .result-name { color: var(--brand); font-weight: 600; }
.result-list .result-name {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  word-break: break-all;
  overflow-wrap: anywhere;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
}
.result-list .result-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.result-list code { flex: 1 1 auto; min-width: 0; word-break: break-all; }
.result-list .result-meta {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.result-list .result-error { color: #c0392b; font-size: 0.85rem; }

.file-list {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
}
.file-list li {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}
.file-list .file-name {
  display: block;
  word-break: break-all;
  overflow-wrap: anywhere;
  margin-bottom: 0.35rem;
}
.file-list .file-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.file-list .file-size {
  color: var(--muted);
  font-size: 0.8rem;
  flex-shrink: 0;
}
.file-list .file-remove {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.25rem;
  flex-shrink: 0;
}
.file-list .file-remove:hover { color: #c0392b; }

.progress-file-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.error {
  margin-top: 1rem;
  color: #c0392b;
  font-size: 0.9rem;
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
}

.version-badge {
  position: fixed;
  bottom: 8px;
  right: 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.65;
  background: var(--card);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  pointer-events: none;
  user-select: text;
}
