:root {
  color-scheme: dark;
  --bg: #0b0b0b;
  --surface: #131313;
  --panel: #1c1b1b;
  --panel-soft: #202020;
  --border: #333333;
  --border-soft: #272727;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --subtle: #737373;
  --red: #dc2626;
  --red-dark: #991b1b;
  --green: #059669;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, Roboto, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
  font-family: var(--sans);
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(220, 38, 38, 0.12), transparent 28rem),
    linear-gradient(135deg, #090909 0%, #101010 45%, #070707 100%);
  color: var(--text);
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
[role="button"] {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

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

svg,
canvas {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.hidden { display: none !important; }
.flex { display: flex !important; }
.is-disabled-ui {
  opacity: 0.5;
  pointer-events: none;
}
.button-icon {
  width: 1rem;
  height: 1rem;
  pointer-events: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 330px;
  min-height: 100vh;
  max-width: 100vw;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--border-soft);
  background: rgba(19, 19, 19, 0.96);
  padding: 24px 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--red);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-mark,
.tool-icon {
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-color: rgba(220, 38, 38, 0.55);
  border-radius: 8px;
  background: rgba(220, 38, 38, 0.14);
  color: var(--red);
}

.sidebar-section {
  margin-top: 42px;
}

.sidebar-label,
.panel-label,
.eyebrow {
  margin: 0;
  color: var(--subtle);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.mode-button {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.mode-button:hover {
  border-color: var(--border);
  background: #181818;
  color: var(--text);
}

.mode-button[aria-selected="true"] {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  box-shadow: 0 12px 30px rgba(220, 38, 38, 0.22);
}

.mode-button[aria-selected="true"] .tool-icon {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.tool-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 6px;
  color: var(--subtle);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 800;
}

.queue-button,
.quick-actions button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #181818;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.queue-button:hover,
.quick-actions button:hover:not(:disabled) {
  border-color: var(--red);
  background: rgba(220, 38, 38, 0.12);
}

.main-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(19, 19, 19, 0.72);
  padding: 12px;
}

.security-pill {
  border: 1px solid rgba(5, 150, 105, 0.45);
  border-radius: 999px;
  background: rgba(5, 150, 105, 0.12);
  color: #86efac;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.workspace-card,
.drop-zone,
.progress-panel,
.queue-panel,
.right-panel,
.panel-block,
.run-panel,
.file-card {
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.24);
}

.workspace-card {
  min-width: 0;
  border-radius: 10px;
  padding: 18px;
}

.hero-card {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

#page-title {
  margin: 6px 0 0;
  color: #fff;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

#page-description,
.tool-description,
#action-hint,
.run-panel p {
  color: var(--muted);
}

#page-description {
  max-width: 680px;
  margin: 14px 0 0;
  overflow-wrap: anywhere;
}

.tool-description {
  max-width: 300px;
  margin: 0;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.settings-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-strip label,
.field-label {
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
}

.settings-strip select,
.pro-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #111;
  color: var(--text);
  outline: none;
}

.settings-strip select {
  max-width: 220px;
  padding: 10px;
}

.pro-input {
  margin-top: 8px;
  padding: 12px;
  font-family: var(--mono);
}

.settings-strip select:focus,
.pro-input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.16);
}

.message-box,
.rounded-lg {
  border-radius: 8px;
}

.border-red-200,
.border-emerald-200 {
  border: 1px solid var(--border);
}

.bg-red-50 {
  background: rgba(220, 38, 38, 0.12);
}

.bg-emerald-50 {
  background: rgba(5, 150, 105, 0.12);
}

.text-red-700 {
  color: #fecaca;
}

.text-emerald-700 {
  color: #a7f3d0;
}

.message-box,
#message {
  padding: 14px 16px;
  font-size: 0.9rem;
}

#message ul {
  margin-bottom: 0;
  padding-left: 18px;
}

.drop-zone {
  display: flex;
  min-height: 360px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  border-color: #383838;
  border-radius: 10px;
  padding: 44px 24px;
  text-align: center;
  outline: none;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.is-active {
  border-color: var(--red);
  background: rgba(220, 38, 38, 0.08);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.14);
}

.drop-zone-compact {
  min-height: 112px;
  flex-direction: row;
  justify-content: flex-start;
  gap: 16px;
  padding: 18px;
  text-align: left;
}

.drop-icon {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  margin-bottom: 18px;
  border: 1px solid rgba(220, 38, 38, 0.42);
  border-radius: 14px;
  background: rgba(220, 38, 38, 0.14);
  color: var(--red);
}

.drop-icon svg {
  width: 34px;
  height: 34px;
}

.drop-icon-compact {
  width: 52px;
  height: 52px;
  margin-bottom: 0;
  flex: 0 0 auto;
}

.drop-title {
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
}

.drop-subtitle {
  margin-top: 8px;
  color: var(--subtle);
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.drop-accepts {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 7px 12px;
  font-family: var(--mono);
  font-size: 0.72rem;
}

.progress-panel {
  border-radius: 10px;
  padding: 16px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.progress-meta p {
  margin: 0;
}

#progress-percent,
#estimate-label,
.file-meta,
#file-count {
  font-family: var(--mono);
}

#progress-percent {
  color: var(--red);
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #2a2a2a;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--red);
  transition: width 220ms ease;
}

.queue-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-radius: 10px;
  padding: 18px;
}

.queue-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.queue-header h2 {
  margin: 5px 0 0;
  font-size: 1.25rem;
}

#file-count {
  margin: 5px 0 0;
  color: var(--subtle);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.queue-actions {
  display: flex;
  gap: 8px;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-card {
  overflow: hidden;
  border-radius: 9px;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.file-card:hover,
.file-card.is-drop-target {
  border-color: var(--red);
  transform: translateY(-2px);
}

.file-card.is-dragging {
  opacity: 0.65;
}

.file-preview {
  position: relative;
  display: grid;
  aspect-ratio: 4 / 3;
  place-items: center;
  overflow: hidden;
  background: #151515;
}

.file-preview canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 200ms ease;
}

.order-badge,
.status-badge {
  position: absolute;
  border-radius: 6px;
  padding: 5px 7px;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 800;
}

.order-badge {
  left: 12px;
  top: 12px;
  border: 1px solid var(--border);
  background: rgba(19, 19, 19, 0.9);
  color: var(--text);
}

.status-badge {
  right: 12px;
  bottom: 12px;
}

.status-badge-red {
  background: var(--red);
  color: #fff;
}

.drag-handle {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--subtle);
  cursor: grab;
}

.file-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
}

.file-name {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  margin: 5px 0 0;
  overflow: hidden;
  color: var(--subtle);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #161616;
  color: var(--muted);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--red);
  background: rgba(220, 38, 38, 0.12);
  color: #fff;
}

.icon-button:disabled,
.quick-actions button:disabled {
  opacity: 0.42;
}

.right-panel {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 14px;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  padding: 22px;
}

.panel-block,
.run-panel {
  border-radius: 10px;
  padding: 16px;
}

.panel-label {
  margin-bottom: 14px;
}

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

.run-panel {
  margin-top: auto;
  background: linear-gradient(180deg, #211111 0%, #171717 100%);
}

.run-panel p {
  margin: 0 0 14px;
  font-size: 0.84rem;
}

#action-button {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 900;
  box-shadow: 0 18px 40px rgba(220, 38, 38, 0.3);
  transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

#action-button:hover:not(:disabled) {
  background: #ef4444;
  transform: translateY(-1px);
}

#action-button:disabled {
  background: #3a3a3a;
  color: #8a8a8a;
  box-shadow: none;
}

#action-button.success {
  background: var(--green);
  box-shadow: 0 18px 40px rgba(5, 150, 105, 0.24);
}

#estimate-label {
  display: block;
  margin-top: 12px;
  color: var(--subtle);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: center;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .right-panel {
    position: static;
    grid-column: 1 / -1;
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--border-soft);
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .sidebar,
  .right-panel {
    position: static;
    height: auto;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .sidebar {
    gap: 24px;
    padding: 18px 16px;
  }

  .quick-actions,
  .file-grid {
    grid-template-columns: 1fr;
  }

  .tool-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .mode-button {
    flex: 0 0 auto;
    width: auto;
    min-width: 118px;
  }

  .topbar,
  .hero-card,
  .queue-header,
  .settings-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .workspace-card,
  .drop-zone,
  .progress-panel,
  .queue-panel,
  .right-panel {
    width: 100%;
    max-width: calc(100vw - 32px);
  }

  .queue-actions {
    flex-wrap: wrap;
  }

  .main-column {
    padding: 16px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  #page-title {
    font-size: 2.35rem;
  }
}

@media (min-width: 640px) {
  .sm\:hidden {
    display: none;
  }
}
