:root {
  --black: #000000;
  --white: #FFFFFF;
  --orange: #F97316;
  --orange-dim: rgba(249, 115, 22, 0.15);
  --orange-glow: rgba(249, 115, 22, 0.08);
  --gray-950: #0A0A0A;
  --gray-900: #111111;
  --gray-850: #161616;
  --gray-800: #1A1A1A;
  --gray-750: #1F1F1F;
  --gray-700: #252525;
  --gray-600: #333333;
  --gray-500: #555555;
  --gray-400: #777777;
  --gray-300: #999999;
  --gray-200: #BBBBBB;
  --gray-100: #DDDDDD;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --bg: var(--black);
  --panel: var(--gray-950);
  --panel-raised: var(--gray-900);
  --text: var(--white);
  --muted: var(--gray-400);
  --accent: var(--orange);
  --danger: var(--red);
  --warn: var(--yellow);
  --border: var(--gray-800);
  --border-strong: var(--gray-700);
  --font-display: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;
  --radius-sm: 4px;
  --radius-md: 8px;
  --settings-panel-width: 320px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 48%, rgba(249, 115, 22, 0.045), transparent 26%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  height: 100dvh;
  min-height: 100dvh;
  padding: 12px;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1 {
  margin: 0 0 12px;
  color: var(--white);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.1;
}

h1 a {
  color: inherit;
  text-decoration: none;
}

h1 a:visited {
  color: inherit;
}

h1 a:hover {
  text-decoration: underline;
}

html.embedded h1 {
  display: none;
  height: 0;
  margin: 0;
}

@media (min-width: 981px) {
  html.embedded body {
    height: 100dvh;
    min-height: 100dvh;
    padding: 0;
  }

  html.embedded .container {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    align-items: stretch;
  }

  html.embedded form.settings-panel,
  html.embedded .panel {
    height: 100dvh;
    max-height: 100dvh;
  }

  html.embedded .output-wrapper,
  html.embedded .document-workspace {
    flex: 1 1 auto;
    height: 100dvh;
    min-height: 0;
  }

  html.embedded .document-viewer {
    height: 100%;
    min-height: 0;
  }
}

.container {
  display: flex;
  flex: 1;
  gap: 12px;
  min-height: 0;
  align-items: flex-start;
}

.settings-toggle {
  display: none;
}

form.settings-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-600) var(--black);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.015);
}

form.settings-panel {
  flex: 0 0 300px;
}

.panel {
  flex: 0 0 320px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  color: var(--gray-200);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

input[type='text'],
input[type='number'],
select {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--gray-900);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

input[type='color'] {
  min-height: 40px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--gray-900);
  color: var(--text);
}

input[type='range'] {
  accent-color: var(--accent);
  min-height: 28px;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

input[type='text']:focus,
input[type='number']:focus,
input[type='color']:focus,
input[type='range']:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--black);
  box-shadow: 0 0 0 2px var(--orange-glow);
}

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-row span {
  font-size: 12px;
  color: var(--muted);
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.options-row {
  flex-direction: row;
  justify-content: flex-start;
  flex-wrap: wrap;
  background: var(--black);
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--gray-200);
  cursor: pointer;
}

.checkbox-label input {
  accent-color: var(--accent);
}

.main-button {
  background: var(--accent);
  color: var(--black);
  padding: 10px;
  min-height: 42px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  transition: opacity 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.1s ease;
  font-family: inherit;
  font-size: 12px;
}

.main-button:hover {
  opacity: 0.9;
}

.main-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.main-button:not(:disabled):active {
  transform: translateY(1px);
}

.secondary-button {
  background: var(--gray-900);
  color: var(--text);
  border-color: var(--border);
}

.secondary-button:not(:disabled):hover {
  border-color: var(--accent);
  background: var(--black);
}

.ingest-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mini-button {
  min-height: 36px;
  padding: 8px;
  font-size: 11px;
}

.file-name {
  font-size: 12px;
  color: var(--muted);
}

.queue-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--black);
  max-height: 200px;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.queue-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 12px;
  text-align: center;
}

.queue-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gray-900);
  background: transparent;
  color: inherit;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}

.queue-item:last-child { border-bottom: none; }
.queue-item:hover { background: var(--gray-900); }
.queue-item.active { background: var(--orange-dim); }

.queue-name {
  min-width: 0;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-path {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.queue-badge {
  font-size: 10px;
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 999px;
  text-transform: uppercase;
  white-space: nowrap;
}

.queue-badge.pending { color: var(--muted); }
.queue-badge.processing { color: var(--warn); border-color: rgba(234, 179, 8, 0.45); }
.queue-badge.saved, .queue-badge.done { color: var(--accent); border-color: rgba(249, 115, 22, 0.55); }

.queue-remove {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--gray-900);
  color: var(--muted);
  cursor: pointer;
}

.queue-remove:hover { color: var(--danger); border-color: rgba(239, 68, 68, 0.45); }
.queue-remove:disabled { opacity: 0.4; cursor: not-allowed; }
.output-wrapper { position: relative; }

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
  pointer-events: none;
}
