:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #d8dee6;
  --text: #1a2332;
  --text-muted: #5c6b7f;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #15803d;
  --error: #b91c1c;
  --warning: #b45309;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1419;
  --surface: #1a222d;
  --surface-2: #242d3a;
  --border: #334155;
  --text: #e8edf4;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1419;
    --surface: #1a222d;
    --surface-2: #242d3a;
    --border: #334155;
    --text: #e8edf4;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --success: #4ade80;
    --error: #f87171;
    --warning: #fbbf24;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.hint {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.key-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.input-wrap {
  flex: 1 1 220px;
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

.input-wrap:focus-within {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
  outline-offset: 0;
}

.input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.6rem 0.75rem;
  font: inherit;
  color: var(--text);
  min-width: 0;
}

.input-wrap input:focus {
  outline: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface-2);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

.btn-icon {
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  padding: 0 0.75rem;
  flex-shrink: 0;
}

.theme-icon-dark {
  display: none;
}

[data-theme="dark"] .theme-icon-light,
:root:not([data-theme="light"]) .theme-icon-light {
  display: none;
}

[data-theme="dark"] .theme-icon-dark,
:root:not([data-theme="light"]) .theme-icon-dark {
  display: inline;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-icon-light {
    display: inline;
  }
  :root:not([data-theme="dark"]) .theme-icon-dark {
    display: none;
  }
}

[data-theme="light"] .theme-icon-light {
  display: inline;
}

[data-theme="light"] .theme-icon-dark {
  display: none;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface-2));
  outline: none;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
}

.drop-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
}

.drop-title {
  margin: 0 0 0.25rem;
  font-weight: 600;
}

.drop-sub {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.queue-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
}

.queue-summary {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.queue {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.queue-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem 1rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: var(--surface-2);
  font-size: 0.9rem;
}

.queue-item:last-child {
  margin-bottom: 0;
}

.queue-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.queue-status {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.status-queued {
  background: color-mix(in srgb, var(--text-muted) 20%, transparent);
  color: var(--text-muted);
}

.status-processing {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
}

.status-done {
  background: color-mix(in srgb, var(--success) 20%, transparent);
  color: var(--success);
}

.status-error {
  background: color-mix(in srgb, var(--error) 20%, transparent);
  color: var(--error);
}

.queue-error {
  grid-column: 1 / -1;
  font-size: 0.8rem;
  color: var(--error);
  margin-top: -0.25rem;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.log-header h2 {
  margin: 0;
}

.log {
  max-height: 220px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}

.log-entry {
  margin: 0 0 0.35rem;
  word-break: break-word;
}

.log-entry:last-child {
  margin-bottom: 0;
}

.log-time {
  color: var(--text-muted);
  margin-right: 0.5rem;
}

.log-info .log-msg {
  color: var(--text);
}

.log-success .log-msg {
  color: var(--success);
}

.log-error .log-msg {
  color: var(--error);
}

.log-warn .log-msg {
  color: var(--warning);
}

.footer {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.footer .version {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

.footer a {
  color: var(--accent);
}

@media (max-width: 520px) {
  .queue-item {
    grid-template-columns: 1fr auto;
  }

  .queue-meta {
    grid-column: 1;
  }

  .queue-status {
    grid-row: 1;
    grid-column: 2;
  }

  .queue-summary {
    margin-left: 0;
    width: 100%;
  }
}
