:root {
  --ink: #111827;
  --ink-soft: #374151;
  --muted: #6b7280;
  --line: #dfe3e8;
  --line-strong: #c8ced7;
  --surface: #fdfdfe;
  --surface-soft: #f3f4f7;
  --canvas: #e6e9ee;
  --heading-bg: var(--surface-soft);
  --line-soft: #e9edf2;
  --blue: #2357d9;
  --blue-dark: #173da2;
  --blue-soft: #edf3ff;
  --blue-ink: #ffffff;
  --yellow-soft: #fff8e9;
  --yellow-ink: #8d4b08;
  --yellow: #f7c948;
  --green: #087f5b;
  --green-soft: #e9f8f2;
  --red: #be3030;
  --red-soft: #fff0f0;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 12px 32px rgba(17, 24, 39, 0.10);
  --shadow-lg: 0 24px 72px rgba(17, 24, 39, 0.16);
  --font-body: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Cascadia Mono", Consolas, ui-monospace, "SF Mono", Menlo, monospace;
  font-family: var(--font-body);
  color: var(--ink);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8eaf0;
  --ink-soft: #c6ccd8;
  --muted: #9aa2b2;
  --line: #363d4c;
  --line-strong: #485064;
  --surface: #181c24;
  --surface-soft: #20252f;
  --canvas: #12151b;
  --heading-bg: #1e232d;
  --line-soft: #262c38;
  --blue-ink: #0e1a33;
  --yellow-soft: #2e2612;
  --yellow-ink: #f2c063;
  --blue: #7ba4ff;
  --blue-dark: #9abaff;
  --blue-soft: #1e2941;
  --yellow: #f7c948;
  --green: #45d6a0;
  --green-soft: #14271f;
  --red: #ff8080;
  --red-soft: #2c1618;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 72px rgba(0, 0, 0, 0.6);
  --topbar-bg: rgba(24, 28, 36, 0.92);
}

:root {
  color: var(--ink);
  background: var(--surface-soft);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 10% 0%, color-mix(in srgb, var(--blue) 7%, transparent), transparent 27rem),
    var(--surface-soft);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 45%, transparent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--topbar-bg, rgba(255, 255, 255, 0.94));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--surface);
  background: var(--ink);
  box-shadow: 4px 4px 0 var(--yellow);
}

.brand-mark svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.topbar-actions,
.toolbar-actions,
.preview-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-button {
  width: 40px;
  height: 40px;
}

.preview-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.home-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button {
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 750;
  line-height: 1;
  transition: background 140ms ease, border-color 140ms ease;
}

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

.button-primary {
  color: var(--blue-ink);
  background: var(--blue);
}

.button-primary:hover {
  background: var(--blue-dark);
}

.button-secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.button-secondary:hover,
.button-quiet:hover {
  border-color: var(--muted);
  background: var(--surface-soft);
}

.button-quiet {
  color: var(--ink-soft);
  background: transparent;
  border-color: var(--line);
}

.button-small {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 11px;
}

main {
  width: 100%;
}

.upload-view {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(48px, 8vh, 88px) 0 64px;
}

.hero-copy {
  max-width: 720px;
  margin: 0 auto 42px;
  text-align: center;
}

.hero-copy h1 {
  max-width: 780px;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 3.6vw, 44px);
  line-height: 1.12;
  letter-spacing: -0.015em;
  font-weight: 600;
}

.hero-summary {
  max-width: 700px;
  margin: 24px 0 0;
  color: var(--ink-soft);
  font-size: clamp(16px, 1.7vw, 19px);
  line-height: 1.65;
}

.upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  max-width: 760px;
  margin: 0 auto;
  align-items: stretch;
}

.landing-history {
  max-width: 760px;
  margin: 26px auto 0;
}

.landing-history-list {
  max-height: none;
}

.dropzone {
  min-height: 410px;
  padding: clamp(30px, 6vw, 64px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 2px dashed var(--line-strong);
  border-radius: 24px;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    repeating-linear-gradient(135deg, var(--line-soft) 0 12px, var(--line) 12px 24px) border-box;
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.drop-icon {
  width: 72px;
  height: 72px;
  margin-bottom: 22px;
  display: grid;
  place-items: center;
  color: var(--blue);
  border: 1px solid color-mix(in srgb, var(--blue) 30%, transparent);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 6px 6px 0 var(--yellow);
}

.drop-icon svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dropzone h2 {
  margin: 0;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -0.035em;
}

.dropzone > p {
  margin: 8px 0 24px;
  color: var(--muted);
}

.drop-hint {
  margin-top: 20px;
  color: var(--muted);
  font-size: 11px;
}

.workspace-view {
  width: min(1720px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

.history-view {
  width: min(1080px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

.history-panel {
  min-height: 420px;
}

.history-list {
  max-height: calc(100vh - 240px);
  min-height: 200px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.history-row {
  padding: 16px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.history-row:hover {
  background: var(--surface-soft);
}

.history-main {
  min-width: 0;
}

.history-main strong,
.history-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-main strong {
  font-size: 13px;
}

.history-main span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.history-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.history-empty p {
  margin: 0 0 6px;
}

.workspace-toolbar {
  min-height: 82px;
  margin-bottom: 14px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto auto;
  align-items: center;
  gap: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--topbar-bg, rgba(255, 255, 255, 0.92));
  box-shadow: var(--shadow-sm);
}

.workspace-toolbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
}

.toolbar-settings {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-settings label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.toolbar-settings select,
.toolbar-settings input {
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-size: 11px;
  font-weight: 650;
}

.toolbar-settings select {
  min-width: 190px;
  padding: 0 28px 0 10px;
}

.toolbar-settings input {
  width: 72px;
  padding: 0 9px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 220px 410px minmax(320px, 1fr);
  gap: 14px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-heading {
  min-height: 66px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--heading-bg);
}

.panel-heading h2 {
  max-width: 320px;
  margin: 0;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--blue);
  background: var(--surface);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.heading-buttons {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.panel-expander {
  display: none;
}

.pane-toggle svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pane-toggle[aria-pressed="false"] {
  color: var(--muted);
  border-color: var(--line);
  background: var(--surface-soft);
}

.panel.is-collapsed .panel-heading,
.panel.is-collapsed .queue-list,
.panel.is-collapsed .queue-footer,
.panel.is-collapsed #editorForm {
  display: none;
}

.panel.is-collapsed .panel-expander {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 16px 0 12px;
  border: 0;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
}

.panel.is-collapsed .panel-expander:hover {
  color: var(--blue);
  background: var(--blue-soft);
}

.panel.is-collapsed .panel-expander svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel.is-collapsed .panel-expander span {
  writing-mode: vertical-rl;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.queue-panel,
.editor-panel,
.preview-panel {
  height: calc(100vh - 200px);
  min-height: 570px;
}

.queue-panel,
.editor-panel {
  position: relative;
  display: flex;
  flex-direction: column;
}

.pane-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  right: -4px;
  width: 8px;
  z-index: 5;
  cursor: col-resize;
}

.pane-resizer:hover {
  background: color-mix(in srgb, var(--blue) 25%, transparent);
}

.queue-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.queue-item {
  width: 100%;
  padding: 14px 15px;
  display: grid;
  grid-template-columns: auto 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  text-align: left;
  background: var(--surface);
  transition: background 120ms ease, box-shadow 120ms ease;
}

.queue-check {
  width: 15px;
  height: 15px;
  accent-color: var(--blue);
}

.queue-item:hover {
  background: var(--surface-soft);
}

.queue-item.is-selected {
  background: var(--blue-soft);
}

.queue-index {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 10px;
  font-weight: 800;
}

.queue-main {
  min-width: 0;
}

.queue-main strong,
.queue-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-main strong {
  font-size: 12px;
}

.queue-main span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.edited-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--yellow) 18%, transparent);
}

.queue-actions {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.queue-remove {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 18px;
  line-height: 1;
}

.queue-remove:hover {
  color: var(--red);
  background: var(--red-soft);
}

.queue-footer {
  min-height: 44px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: var(--heading-bg);
  font-size: 9px;
}

.queue-select-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.queue-select-all input {
  width: 13px;
  height: 13px;
  accent-color: var(--blue);
}

#editorForm {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#editorForm details {
  border-bottom: 1px solid var(--line);
}

#editorForm summary {
  min-height: 52px;
  padding: 0 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  user-select: none;
}

#editorForm summary::-webkit-details-marker {
  display: none;
}

#editorForm summary:hover {
  background: var(--surface-soft);
}

#editorForm summary b {
  margin-right: 8px;
  color: var(--blue);
  font-size: 9px;
}

#editorForm summary i {
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 130ms ease;
}

#editorForm details[open] summary {
  color: var(--blue-dark);
  background: var(--blue-soft);
}

#editorForm details[open] summary i {
  transform: rotate(225deg) translate(-1px, -1px);
}

.form-section {
  padding: 16px;
  display: grid;
  gap: 13px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-soft);
}

.form-section.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-section label {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.065em;
  text-transform: uppercase;
}

.form-section label small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.form-section input,
.form-section textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  outline: none;
  text-transform: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.form-section input {
  height: 38px;
  padding: 0 10px;
}

.form-section textarea {
  min-height: 66px;
  padding: 10px;
  line-height: 1.45;
  resize: vertical;
}

.form-section input:hover,
.form-section textarea:hover {
  border-color: var(--muted);
}

.form-section input:focus,
.form-section textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 22%, transparent);
}

.span-two {
  grid-column: 1 / -1;
}

.accounting-status {
  min-height: 36px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid color-mix(in srgb, var(--green) 35%, transparent);
  border-radius: 8px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 10px;
  font-weight: 700;
}

.accounting-status::before {
  content: "✓";
  font-weight: 900;
}

.accounting-status.is-warning {
  border-color: color-mix(in srgb, var(--yellow) 45%, transparent);
  color: var(--yellow-ink);
  background: var(--yellow-soft);
}

.accounting-status.is-warning::before {
  content: "!";
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  background: var(--surface-soft);
}

.preview-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
}

.preview-state.is-loading {
  color: var(--blue);
}

.preview-state.is-error {
  color: var(--red);
}

.preview-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: auto;
  background: var(--canvas);
}

#labelPreview {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 4 / 6;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-md);
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.preview-placeholder span {
  width: 36px;
  height: 54px;
  border: 2px solid var(--line-strong);
  border-radius: 3px;
  background: var(--surface);
  animation: placeholder-pulse 1.2s ease-in-out infinite;
}

.preview-placeholder p {
  margin: 0;
}

.preview-error {
  margin: 12px 14px 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--red) 35%, transparent);
  border-radius: 8px;
  color: var(--red);
  background: var(--red-soft);
  font-size: 10px;
  line-height: 1.45;
}

.preview-actions {
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  justify-content: center;
}

.processing-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 20px;
  display: grid;
  place-items: center;
  background: rgba(17, 24, 39, 0.58);
  backdrop-filter: blur(8px);
}

.processing-card {
  width: min(390px, 100%);
  padding: 32px;
  text-align: center;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.processing-card strong {
  display: block;
  margin-top: 18px;
  font-size: 17px;
}

.processing-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.spinner {
  width: 42px;
  height: 42px;
  display: inline-block;
  border: 4px solid color-mix(in srgb, var(--blue) 20%, var(--surface));
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  width: min(390px, calc(100vw - 40px));
  display: grid;
  gap: 9px;
}

.toast {
  padding: 13px 15px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--blue);
  border-radius: 10px;
  color: var(--ink-soft);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  line-height: 1.45;
  animation: toast-in 170ms ease-out;
}

.toast.is-error {
  border-left-color: var(--red);
}

.toast strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
}

.noscript {
  position: fixed;
  inset: auto 20px 20px;
  z-index: 200;
  padding: 14px;
  border-radius: 10px;
  color: #ffffff;
  background: #be3030;
  text-align: center;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes placeholder-pulse {
  50% { opacity: 0.38; transform: scale(0.97); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

@media (max-width: 1180px) {
  .workspace-toolbar {
    grid-template-columns: 1fr auto;
  }

  .toolbar-settings {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .toolbar-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .workspace-grid {
    grid-template-columns: 210px minmax(340px, 1fr);
  }

  .workspace-grid:has(.queue-panel.is-collapsed) {
    grid-template-columns: 46px minmax(340px, 1fr);
  }

  .workspace-grid:has(.editor-panel.is-collapsed) {
    grid-template-columns: 210px 46px;
  }

  .workspace-grid:has(.queue-panel.is-collapsed):has(.editor-panel.is-collapsed) {
    grid-template-columns: 46px 46px;
  }

        .preview-panel {
    grid-column: 1 / -1;
    height: 760px;
  }
}

@media (max-width: 820px) {
  .topbar {
    padding-inline: 16px;
  }

  .upload-view {
    width: min(100% - 24px, 720px);
    padding-top: 42px;
  }

  .upload-grid,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .dropzone {
    min-height: 350px;
  }

  .workspace-view {
    width: calc(100% - 20px);
  }

  .workspace-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .toolbar-settings,
  .toolbar-actions {
    grid-column: 1;
    grid-row: auto;
  }

  .toolbar-actions .button {
    flex: 1;
  }

  .queue-panel,
  .editor-panel,
  .preview-panel {
    height: auto;
    min-height: 0;
  }

  .queue-list {
    max-height: 270px;
  }

  .panel.is-collapsed .panel-expander {
    flex-direction: row;
    justify-content: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 16px;
  }

  .panel.is-collapsed .panel-expander span {
    writing-mode: horizontal-tb;
    letter-spacing: 0.1em;
  }

  #editorForm {
    max-height: 720px;
  }

  .preview-stage {
    min-height: 650px;
  }
}

@media (max-width: 540px) {
  .brand small {
    display: none;
  }

  .brand strong {
    font-size: 13px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .topbar-actions .button {
    min-height: 36px;
    padding-inline: 10px;
    font-size: 11px;
  }

  .hero-copy h1 {
    font-size: 22px;
  }

  .dropzone {
    border-radius: 18px;
  }

  .toolbar-settings {
    display: grid;
    grid-template-columns: 1fr 100px;
  }

  .toolbar-settings select,
  .toolbar-settings input {
    width: 100%;
    min-width: 0;
  }

  .form-section.two-column {
    grid-template-columns: 1fr;
  }

  .span-two {
    grid-column: auto;
  }

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

  .preview-actions .button {
    flex: 1 1 30%;
    padding-inline: 9px;
  }

  .preview-stage {
    min-height: 520px;
    padding: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
