/* Converter UI: shared controls, pixel console, then responsive overrides.
 * Rule order preserves the existing cascade; interaction states stay explicit.
 */
:root {
  color-scheme: light;
  font-family: "Microsoft JhengHei", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.panel {
  background: var(--panel);
  padding: 20px;
}

.pipeline {
  --pipe-x: 265px;
  --factory-col: 360px;
  --panel-col: 430px;
  --panel-left: 458px;
  grid-template-columns: var(--factory-col) var(--panel-col);
  grid-auto-rows: 190px;
  row-gap: 8px;
  align-items: center;
}

.pipeline-card {
  z-index: 2;
  grid-column: 1 / -1;
  grid-template-columns: var(--factory-col) var(--panel-col);
  grid-template-rows: 30px 160px;
  align-items: center;
}

.pipeline-card:hover,
.pipeline-card:focus-within {
  z-index: 80;
}

.step-body {
  left: var(--panel-left);
  right: auto;
  top: 50%;
  z-index: 100;
}

.step-body::before {
  display: none;
}

.pipeline-card:hover .step-body,
.pipeline-card:focus-within .step-body {
  opacity: 1;
  pointer-events: auto;
}

.step-actions {
  display: flex;
}

.step-number {
  left: calc(var(--pipe-x) - 18px);
  top: calc(50% + 54px);
  z-index: 4;
  display: grid;
  place-items: center;
}

.station-copy {
  z-index: 4;
  grid-column: 1;
  grid-row: 1;
  justify-items: end;
  align-self: end;
  gap: 4px;
}

.input-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 16px;
  align-items: stretch;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
}

h2,
h3,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 20px;
}

h3 {
  margin-bottom: 4px;
  font-size: 17px;
}

.subhead,
.status,
#fileStats,
#chapterStats,
#formatStats,
#coverStats,
#metadataStats {
  color: var(--muted);
}

.pipeline-hero .subhead {
  margin-bottom: 0;
}

.file-drop {
  cursor: pointer;
  flex-direction: column;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.file-drop input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.file-drop-large {
  min-height: 230px;
}

textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  font: inherit;
  line-height: 1.6;
  padding: 10px;
}

.toolbar {
  display: grid;
  margin-top: 0;
}

.cover-grid {
  display: grid;
  margin-top: 16px;
  align-items: stretch;
}

.cover-drop {
  cursor: pointer;
  flex-direction: column;
  text-align: center;
}

.cover-drop input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.cover-preview {
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  text-align: center;
}

.cover-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f0ede6;
}

.cover-info-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
}

.cover-info-panel h3 {
  margin-bottom: 0;
}

.cover-info-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 7px 10px;
  margin: 0;
  font-size: 13px;
}

.cover-info-list dt {
  font-weight: 800;
}

.cover-info-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.cover-resize-option {
  align-items: flex-start;
  color: var(--text);
  font-size: 14px;
}

.cover-resize-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.format-grid {
  display: grid;
  margin-top: 16px;
}

.rules-fieldset {
  margin-top: 16px;
}

.rules-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.rules-preset {
  flex: 1 1 260px;
  min-width: 0;
}

.rules-preset-row {
  display: flex;
  gap: 8px;
}

.rules-preset-row select {
  flex: 1 1 auto;
  min-width: 0;
}

.rules-preset-row button {
  flex: 0 0 auto;
}

.rule-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rule-row {
  display: grid;
  grid-template-columns: auto minmax(150px, 1.3fr) minmax(150px, 1.3fr) auto auto minmax(72px, auto) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 3px solid #6e4a2e;
  background: rgba(255, 250, 240, 0.72);
}

.rule-row.is-disabled {
  opacity: 0.6;
}

.rule-row .check-row,
.rule-row .rule-hits {
  align-self: center;
  padding-bottom: 2px;
}

.rule-row .rule-field span {
  font-size: 13px;
}

.rule-hits {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.rule-remove {
  min-height: 42px;
}

.rule-empty,
.rules-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

@media (max-width: 1080px) {
  .rule-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rule-row .rule-field {
    grid-column: 1 / -1;
  }
}

.is-hidden {
  display: none !important;
}

.chapter-warning {
  margin: 12px 0 0;
  padding: 8px 10px;
  border: 2px solid var(--danger);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.6;
}

.chapter-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.chapter-search {
  flex: 1 1 260px;
  min-width: 0;
}

.chapter-search-results,
.chapter-editor {
  list-style: none;
  padding-left: 0;
}

.chapter-search-results {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  padding: 0;
}

.chapter-search-results:empty {
  display: none;
}

.chapter-search-row,
.chapter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.chapter-search-text {
  flex: 1 1 200px;
  min-width: 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.chapter-editor {
  max-height: 420px;
}

.chapter-row .chapter-title,
.chapter-row .chapter-title:hover:not(:disabled) {
  flex: 1 1 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
  min-height: 0;
  box-shadow: none;
  text-shadow: none;
  transform: none;
}

.chapter-row .chapter-title:hover:not(:disabled),
.chapter-row .chapter-title:focus-visible {
  color: var(--accent-dark);
  text-decoration: underline;
}

.chapter-row.is-active {
  background: rgba(8, 126, 118, 0.1);
}

.chapter-row.is-volume .chapter-title,
.chapter-list li.is-volume .chapter-title {
  color: var(--accent-dark);
}

.chapter-editor .chapter-row:not(.is-volume) {
  padding-left: 14px;
}

.chapter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.chapter-action {
  min-height: 30px;
  padding: 2px 10px;
  font-size: 13px;
}

.chapter-rename {
  flex: 1 1 100%;
}

.chapter-empty {
  color: var(--muted);
  font-size: 13px;
}

.cover-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.cover-size-options {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.cover-color input {
  width: 64px;
  height: 36px;
  padding: 2px;
}

.cover-crop-preview p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.crop-frame {
  position: relative;
  width: 120px;
  border: 2px dashed var(--muted);
  background: rgba(0, 0, 0, 0.08);
}

.crop-keep {
  position: absolute;
  border: 3px solid var(--accent);
  background: rgba(255, 255, 255, 0.55);
}

.epub-options {
  margin-bottom: 16px;
}

fieldset {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 14px;
}

legend {
  padding: 0 6px;
  font-weight: 800;
}

label {
  display: grid;
  gap: 7px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.check-row input {
  inline-size: 18px;
  block-size: 18px;
}

select,
input[type="text"] {
  width: 100%;
  min-height: 42px;
  font: inherit;
  padding: 8px 10px;
}

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

.actions {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

button {
  min-height: 46px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 10px 14px;
}

.secondary-button {
  min-height: 38px;
  border: 1px solid #bfd8d3;
}

button:disabled {
  cursor: not-allowed;
}

.status {
  min-height: 24px;
  margin-bottom: 0;
}

.metadata-grid {
  display: grid;
  margin-top: 14px;
}

.metadata-grid textarea {
  min-height: 86px;
}

.metadata-summary {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 12px;
  margin: 14px 0 0;
  font-size: 13px;
}

.metadata-summary dt {
  font-weight: 800;
}

.metadata-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.output-grid {
  display: grid;
  margin-top: 18px;
}

.process-preview-grid {
  margin-top: 20px;
}

.output-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.final-preview-grid {
  display: grid;
  margin-top: 18px;
}

.final-metadata-panel,
.final-cover-panel,
.final-chapter-panel,
.final-text-panel {
  align-self: start;
}

.final-metadata-panel h3,
.final-cover-panel h3 {
  margin-bottom: 10px;
}

.output-metadata-summary {
  margin-top: 0;
}

.output-cover-preview {
  display: grid;
  min-height: 260px;
  place-items: center;
  gap: 8px;
  overflow: hidden;
  color: var(--muted);
  text-align: center;
}

.output-cover-preview img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
}

.output-cover-preview span {
  padding: 0 8px 10px;
  font-size: 13px;
}

.mini-panel {
  min-width: 0;
}

.mini-panel > summary {
  list-style: none;
}

.mini-panel > summary::-webkit-details-marker {
  display: none;
}

.mini-summary {
  cursor: pointer;
}

.mini-summary h3,
.mini-summary p {
  margin-bottom: 0;
}

.mini-summary::after {
  content: "展開";
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 800;
}

.mini-panel[open] .mini-summary::after {
  content: "收起";
}

.status.error {
  color: var(--danger);
}

.chapter-list {
  display: grid;
  max-height: 340px;
  gap: 8px;
  overflow: auto;
  margin: 14px 0 0;
  padding-left: 22px;
}

.chapter-list li {
  padding: 8px 0;
  border-bottom: 1px solid #eee8dc;
}

.chapter-title {
  display: block;
  font-weight: 800;
}

.chapter-size {
  font-size: 13px;
}

pre {
  max-height: 380px;
  overflow: auto;
  margin: 14px 0 0;
  padding: 18px;
  font-family: "Microsoft JhengHei", "Microsoft YaHei", ui-monospace, monospace;
  line-height: 1.7;
  white-space: pre-wrap;
}

@media (max-width: 1120px) {
  .pipeline {
    --panel-col: 360px;
    --panel-left: 438px;
  }

  .step-body {
    left: var(--panel-left);
  }
}

@media (max-width: 880px) {
  .pipeline {
    --pipe-x: 210px;
    --factory-col: 260px;
    --panel-col: 300px;
    --panel-left: 296px;
    grid-template-columns: var(--factory-col) var(--panel-col);
    grid-auto-rows: 170px;
  }

  .pipeline-card {
    grid-template-columns: var(--factory-col) var(--panel-col);
    grid-template-rows: 28px 142px;
  }

  .step-number {
    left: calc(var(--pipe-x) - 16px);
    top: calc(50% + 46px);
  }

  .step-body {
    left: var(--panel-left);
    top: 50%;
  }

  .input-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(37, 34, 53, 0.08);
}

.eyebrow {
  color: var(--accent-dark);
  text-shadow: none;
}

.pipeline-hero .subhead {
  text-shadow: none;
}

.tab-bar {
  flex-wrap: wrap;
}

.tab-button {
  font: inherit;
  cursor: pointer;
}

.step-actions {
  justify-content: flex-start;
}

.toolbar {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.output-grid {
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
}

@media (max-width: 760px) {
  .tab-button {
    flex: 1 1 calc(50% - 8px);
  }

  .toolbar,
  .output-grid {
    grid-template-columns: 1fr;
  }
}

.pipeline-hero {
  gap: 10px;
}

.pipeline-hero .eyebrow {
  width: max-content;
  align-items: center;
}

.tab-button:active,
button:active,
.file-drop:active,
.cover-drop:active {
  transform: translateY(1px);
}

.step-actions {
  margin-bottom: 16px;
}

button {
  transition: transform 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

button:focus-visible,
.tab-button:focus-visible,
select:focus-visible,
input[type="text"]:focus-visible,
textarea:focus-visible,
.file-drop:focus-within,
.cover-drop:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.secondary-button {
  border-color: #c8ddd7;
  box-shadow: none;
}

.secondary-button:hover:not(:disabled) {
  box-shadow: none;
}

select,
input[type="text"],
textarea {
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

select:hover,
input[type="text"]:hover,
textarea:hover {
  border-color: #b6d1ca;
}

select:focus,
input[type="text"]:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus);
}

label {
  color: #2a3633;
  font-size: 14px;
  font-weight: 750;
}

.metadata-summary dt,
.cover-info-list dt {
  color: var(--accent-dark);
}

.file-drop:hover,
.cover-drop:hover,
.file-drop.drag-over {
  border-color: var(--accent);
  background: #e5f5f1;
  transform: translateY(-1px);
}

.metadata-summary,
.cover-info-list {
  color: var(--muted);
}

.mini-panel {
  padding: 16px;
}

.mini-summary {
  display: grid;
  gap: 3px;
}

.mini-summary h3,
.final-metadata-panel h3,
.final-cover-panel h3 {
  letter-spacing: -0.01em;
}

.chapter-list li {
  border-bottom-color: #e3ebe7;
}

.chapter-size {
  color: var(--muted);
}

.output-note {
  padding: 13px 14px;
}

@media (max-width: 820px) {
  .tab-button {
    flex: auto;
  }
}

/* Shared pixel palette and control decoration. */
:root {
  --panel: #fff2d5;
  --text: #241713;
  --muted: #6a5142;
  --line: #553522;
  --accent: #087e76;
  --accent-dark: #055b55;
  --danger: #b94222;
  --pixel-ink: #211715;
  --pixel-blue: #202486;
  --focus: rgba(8, 126, 118, 0.28);
}

body {
  color: var(--text);
  image-rendering: pixelated;
}

.pipeline-hero {
  z-index: 1;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
  align-items: center;
  max-width: none;
  border-radius: 0;
}

.pipeline-hero::before {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  top: 14px;
  height: 10px;
  border-top: 3px solid rgba(104, 55, 31, 0.42);
  border-bottom: 3px solid rgba(255, 255, 255, 0.55);
}

.pipeline-hero::after {
  content: "";
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 12px;
  height: 12px;
  background: repeating-linear-gradient(90deg, #2b2a96 0 20px, #15154e 20px 28px, #bd6c39 28px 34px);
  border: 3px solid var(--pixel-ink);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.18);
}

.hero-copy {
  position: relative;
  z-index: 2;
  padding-left: 18px;
}

.pipeline-hero .eyebrow {
  display: inline-flex;
  margin-bottom: 14px;
  border: 3px solid #0b6963;
  border-radius: 0;
  background: #e9f5da;
  color: #055b55;
  padding: 7px 12px;
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 4px 4px 0 rgba(5, 91, 85, 0.22);
}

h1 {
  max-width: none;
  margin: 0 0 16px;
  color: #221313;
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-size: clamp(34px, 3.6vw, 54px);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 0.98;
  text-shadow: 3px 0 0 rgba(255, 255, 255, 0.65),
    0 4px 0 rgba(103, 58, 38, 0.16);
}

h1 .brand-token {
  color: var(--pixel-blue);
}

.pipeline-hero .subhead {
  max-width: 720px;
  color: #5f4231;
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-size: clamp(20px, 2vw, 28px);
  font-weight: 700;
  line-height: 1.35;
}

.hero-machine-art {
  position: relative;
  z-index: 2;
  align-self: end;
  justify-self: end;
  margin: -18px 8px -4px 0;
}

.hero-machine-art img {
  display: block;
  width: min(300px, 24vw);
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(10px 12px 0 rgba(50, 26, 22, 0.22));
}

.tab-bar {
  max-width: none;
}

.tab-button {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s steps(2, jump-none), filter 0.16s ease;
}

.tab-index {
  display: inline-grid;
  place-items: center;
  text-shadow: none;
}

.global-status {
  max-width: none;
}

.global-status::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.file-drop,
.cover-drop {
  position: relative;
}

.file-drop::before {
  content: "TXT";
  display: grid;
  place-items: end center;
  background: linear-gradient(135deg, transparent 0 72%, #cde7db 72% 100%),
    #fff8e8;
  color: #0b6963;
  font-family: "Courier New", monospace;
  font-weight: 900;
  box-shadow: 5px 5px 0 rgba(33, 23, 21, 0.16);
}

.cover-drop::before {
  display: grid;
  place-items: end center;
  background: linear-gradient(135deg, transparent 0 72%, #cde7db 72% 100%),
    #fff8e8;
  color: #0b6963;
  font-family: "Courier New", monospace;
  font-weight: 900;
  box-shadow: 5px 5px 0 rgba(33, 23, 21, 0.16);
}

.cover-drop::before {
  content: "IMG";
}

legend {
  border: 3px solid #6e4a2e;
  background: #fff4d6;
  color: #06635d;
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-size: 16px;
}

label,
.check-row,
.metadata-summary,
.cover-info-list,
.chapter-size,
.output-note,
.mini-summary p {
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
}

select,
input[type="text"],
textarea {
  border: 3px solid #6e4a2e;
  background: #fffaf0;
  color: var(--text);
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-weight: 700;
  box-shadow: inset 3px 3px 0 rgba(105, 66, 37, 0.12);
}

button {
  border: 4px solid var(--pixel-ink);
  background: linear-gradient(180deg, #0d958b, #06635d);
  color: #fff8df;
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.18),
    4px 5px 0 rgba(52, 28, 24, 0.34);
}

button:hover:not(:disabled) {
  background: linear-gradient(180deg, #10a79b, #075d57);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.2),
    4px 5px 0 rgba(52, 28, 24, 0.34);
}

.secondary-button {
  background: linear-gradient(180deg, #fff7e2, #ecc17c);
  color: #06635d;
}

.secondary-button:hover:not(:disabled) {
  background: linear-gradient(180deg, #fffbe8, #f2cc90);
}

button:disabled {
  border-color: #877263;
  background: linear-gradient(180deg, #c8b7a1, #a18e7b);
  color: #fff2d8;
  box-shadow: none;
}

.cover-preview,
.output-cover-preview {
  border: 3px solid #6e4a2e;
  background: #fffaf0;
  box-shadow: inset 0 0 0 3px rgba(105, 66, 37, 0.1);
}

pre {
  border: 3px solid #6e4a2e;
  box-shadow: inset 0 0 0 3px rgba(105, 66, 37, 0.1);
}

pre {
  background: #1d1715;
  color: #fff2d5;
}

.mini-summary h3,
.final-metadata-panel h3,
.final-cover-panel h3,
.cover-info-panel h3 {
  color: #221313;
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-size: 22px;
  font-weight: 900;
}

.mini-summary::after {
  color: #06635d;
  font-family: "Courier New", monospace;
}

.chapter-title {
  color: #241713;
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
}

.cover-preview img,
.output-cover-preview img {
  image-rendering: auto;
}

@media (max-width: 1080px) {
  .pipeline-hero {
    grid-template-columns: 1fr;
  }

  .hero-machine-art {
    display: none;
  }
}

/* Console backdrop and the five-step workspace. */
body {
  min-height: 100dvh;
  background: linear-gradient(45deg, rgba(119, 75, 37, 0.08) 25%, transparent 25%) 0 0 / 8px 8px,
    linear-gradient(-45deg, rgba(119, 75, 37, 0.06) 25%, transparent 25%) 0 0 / 8px 8px,
    #ead3aa;
}

.app {
  position: relative;
  width: min(1672px, 100%);
  max-width: calc(100vw - 18px);
  min-height: min(941px, calc((100vw - 10px) * 0.563));
  margin: 0 auto;
  padding: 0 7.72% 4.1%;
  border: 0;
  border-radius: 0;
  background: url("圖片/控制台背景.webp") top center / 100% auto no-repeat;
  box-shadow: none;
  overflow: visible;
}

.app::before,
.app::after {
  display: none;
}

.pipeline-hero {
  display: block;
  position: relative;
  height: clamp(176px, 17.72vw, 296px);
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.pipeline-hero * {
  visibility: hidden;
}

.tab-bar {
  position: relative;
  top: auto;
  z-index: 12;
  display: grid;
  grid-template-columns: 1.11fr 1fr 1fr 1fr 1fr;
  gap: clamp(6px, 0.72vw, 12px);
  height: clamp(48px, 4.25vw, 71px);
  margin: 0;
  padding: clamp(5px, 0.52vw, 9px) clamp(4px, 0.48vw, 8px);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.tab-button {
  min-height: 0;
  height: 100%;
  gap: clamp(7px, 0.84vw, 14px);
  border: clamp(3px, 0.24vw, 4px) solid #211715;
  border-radius: 3px;
  background: linear-gradient(180deg, #fff5db 0%, #ffe4b3 45%, #efbd75 100%);
  color: #2a1711;
  padding: 0 clamp(8px, 0.9vw, 15px);
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-size: clamp(15px, 1.52vw, 26px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.46),
    4px 4px 0 rgba(54, 29, 22, 0.34);
}

.tab-button:hover {
  border-color: #211715;
  background: linear-gradient(180deg, #fff9e8 0%, #ffe9bf 48%, #f3c682 100%);
  color: #2a1711;
  filter: brightness(1.03);
}

.tab-button.is-active {
  border-color: #211715;
  background: linear-gradient(180deg, #07978c 0%, #087a73 52%, #04534f 100%);
  color: #fff9e5;
  text-shadow: 2px 2px 0 #043d3a;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.22),
    4px 4px 0 rgba(54, 29, 22, 0.36);
}

.tab-index {
  width: clamp(26px, 2.1vw, 35px);
  height: clamp(26px, 2.1vw, 35px);
  border: 3px solid currentColor;
  background: #fff8e5;
  color: #7a512f;
  font-size: clamp(15px, 1.45vw, 24px);
  line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(233, 177, 98, 0.34);
}

.tab-button.is-active .tab-index {
  color: #0b766f;
  text-shadow: none;
}

.global-status {
  position: relative;
  z-index: 10;
  min-height: clamp(43px, 4.2vw, 70px);
  margin: clamp(7px, 0.82vw, 14px) 1.7% clamp(8px, 1.02vw, 17px);
  border: clamp(3px, 0.24vw, 4px) solid #211715;
  border-radius: 3px;
  background: linear-gradient(180deg, #fff9e7 0%, #fff0c6 100%);
  color: #086d66;
  padding: clamp(11px, 1.16vw, 19px) clamp(80px, 7.2vw, 120px) clamp(10px, 1vw, 17px) clamp(22px, 2.28vw, 38px);
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-size: clamp(16px, 1.58vw, 26px);
  font-weight: 900;
  line-height: 1.1;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.7),
    0 5px 0 rgba(111, 65, 35, 0.42);
}

.global-status::after {
  right: clamp(22px, 2.15vw, 36px);
  width: clamp(11px, 0.96vw, 16px);
  height: clamp(11px, 0.96vw, 16px);
  border: 2px solid #211715;
  background: #2a3dd5;
  box-shadow: clamp(21px, 1.98vw, 33px) 0 0 #f6be24,
    clamp(21px, 1.98vw, 33px) 0 0 2px #211715,
    clamp(42px, 3.94vw, 66px) 0 0 #e63e24,
    clamp(42px, 3.94vw, 66px) 0 0 2px #211715;
}

.pipeline {
  position: relative;
  z-index: 8;
  display: block;
  max-width: none;
  min-width: 0;
  min-height: 0;
  margin: 0 1.7%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.pipeline::before,
.pipeline::after {
  display: none;
}

.pipeline-card {
  display: none;
  position: relative;
  min-width: 0;
}

.pipeline-card.is-active {
  display: block;
}

.pipeline-card.panel {
  height: clamp(330px, 25vw, 418px);
  overflow: auto;
  border: clamp(3px, 0.3vw, 5px) solid #211715;
  border-radius: 3px;
  background: linear-gradient(180deg, #fff9e7, #fff0cb);
  padding: clamp(28px, 2.7vw, 45px) clamp(38px, 3.55vw, 60px) clamp(32px, 3.1vw, 52px);
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.62),
    0 7px 0 rgba(91, 51, 32, 0.36);
}

.step-heading {
  display: flex;
  align-items: flex-start;
  gap: clamp(15px, 1.38vw, 23px);
  margin: 0 0 clamp(14px, 1.3vw, 22px);
  padding: 0;
  border: 0;
}

.step-number {
  position: static;
  flex: 0 0 auto;
  width: clamp(51px, 4.25vw, 71px);
  height: clamp(51px, 4.25vw, 71px);
  border: clamp(3px, 0.3vw, 5px) solid #211715;
  border-radius: 3px;
  background: linear-gradient(180deg, #0c978d 0%, #076d66 60%, #044b48 100%);
  color: #fff7df;
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-size: clamp(27px, 2.45vw, 41px);
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.24),
    5px 5px 0 rgba(55, 30, 22, 0.24);
}

.station-copy {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  padding: 0;
  text-align: left;
}

.station-copy h2 {
  display: block;
  width: 100%;
  margin: 0 0 clamp(8px, 0.72vw, 12px);
  border: 0;
  background: transparent;
  color: #21130f;
  padding: 0;
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-size: clamp(31px, 3vw, 50px);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 0.95;
  text-shadow: none;
  box-shadow: none;
}

.station-copy p {
  display: block;
  width: 100%;
  margin: 0;
  color: #654837;
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-size: clamp(18px, 1.7vw, 28px);
  font-weight: 700;
  line-height: 1.2;
}

.station-tooltip {
  display: none;
}

.step-body {
  position: static;
  width: auto;
  max-height: none;
  overflow: visible;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  opacity: 1;
  pointer-events: auto;
  transform: none;
  transition: none;
}

.pipeline-card:hover .step-body,
.pipeline-card:focus-within .step-body {
  transform: none;
}

.file-drop {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-content: center;
  align-items: center;
  justify-content: center;
  min-height: clamp(172px, 13.55vw, 226px);
  column-gap: clamp(20px, 2.4vw, 40px);
  border: clamp(3px, 0.3vw, 5px) dashed #08766e;
  border-radius: 4px;
  background: linear-gradient(180deg, #e9f6ef, #f2faf4);
  padding: clamp(26px, 2.4vw, 40px);
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.62),
    6px 7px 0 rgba(82, 50, 32, 0.22);
}

.cover-drop {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-content: center;
  align-items: center;
  justify-content: center;
  column-gap: clamp(20px, 2.4vw, 40px);
  border: clamp(3px, 0.3vw, 5px) dashed #08766e;
  border-radius: 4px;
  background: linear-gradient(180deg, #e9f6ef, #f2faf4);
  padding: clamp(26px, 2.4vw, 40px);
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.62),
    6px 7px 0 rgba(82, 50, 32, 0.22);
}

.file-drop::before,
.cover-drop::before {
  grid-column: 1;
  grid-row: 1 / span 2;
  width: clamp(52px, 4.8vw, 80px);
  height: clamp(62px, 5.75vw, 96px);
  margin: 0;
  border: clamp(3px, 0.3vw, 5px) solid #0b6963;
  font-size: clamp(19px, 1.8vw, 30px);
  padding-bottom: clamp(6px, 0.6vw, 10px);
}

.file-drop-title {
  grid-column: 2;
  grid-row: 1;
  color: #076d66;
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-size: clamp(25px, 3vw, 50px);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.1;
}

.file-drop-meta {
  grid-column: 2;
  grid-row: 2;
  margin-top: clamp(7px, 0.72vw, 12px);
  color: #5f4b42;
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-size: clamp(15px, 1.45vw, 24px);
  font-weight: 700;
}

.toolbar,
.format-grid,
.metadata-grid,
.cover-grid,
.output-grid,
.final-preview-grid {
  gap: clamp(14px, 1.35vw, 22px);
}

.format-grid,
.metadata-grid,
.final-preview-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide-field,
.final-text-panel {
  grid-column: 1 / -1;
}

.cover-grid {
  grid-template-columns: minmax(280px, 1fr) minmax(190px, 0.34fr) minmax(260px, 0.45fr);
}

.cover-drop,
.cover-preview,
.cover-info-panel {
  min-height: clamp(210px, 18vw, 300px);
}

.actions {
  grid-template-columns: repeat(2, minmax(210px, 1fr));
  margin-top: 0;
}

fieldset,
.mini-panel,
.cover-info-panel,
.output-note {
  border: 3px solid #6e4a2e;
  border-radius: 3px;
  background: linear-gradient(180deg, #fff8e8, #fbe3ba);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.54),
    4px 5px 0 rgba(85, 53, 34, 0.17);
}

button,
select,
input[type="text"],
textarea,
.cover-preview,
.output-cover-preview,
pre {
  border-radius: 3px;
}

@media (max-width: 1080px) {
  .app {
    width: min(100vw - 8px, 1672px);
    padding-right: 6.6%;
    padding-left: 6.6%;
    background-size: 1120px auto;
  }

  .pipeline-hero {
    height: clamp(172px, 21.5vw, 232px);
  }

  .tab-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
  }

  .tab-button {
    min-height: 48px;
  }

  .format-grid,
  .metadata-grid,
  .cover-grid,
  .final-preview-grid,
  .actions {
    grid-template-columns: 1fr;
  }

  .wide-field,
  .final-text-panel {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .app {
    padding: 0 12px 26px;
    background-image: none;
    background-color: #f4c989;
  }

  .pipeline-hero {
    visibility: visible;
    height: auto;
    margin-bottom: 10px;
    border: 4px solid #211715;
    background: #fff2d5;
    padding: 18px;
    pointer-events: auto;
  }

  .pipeline-hero * {
    visibility: visible;
  }

  .hero-machine-art {
    display: none;
  }

  h1 {
    font-size: clamp(34px, 10vw, 48px);
  }

  .pipeline-hero .eyebrow {
    font-size: 14px;
  }

  .pipeline-hero .subhead {
    font-size: 17px;
  }

  .global-status,
  .pipeline {
    margin-right: 0;
    margin-left: 0;
  }

  .pipeline-card.panel {
    padding: 22px;
  }

  .step-heading {
    gap: 12px;
  }

  .station-copy h2 {
    font-size: 30px;
  }

  .station-copy p {
    font-size: 17px;
  }
}

/* Desktop workspace: keep controls and previews inside the console. */
@media (min-width: 1081px) {
  .app {
    padding-right: min(7.72vw, 129px);
    padding-left: min(7.72vw, 129px);
  }

  .tab-bar {
    gap: clamp(8px, 0.66vw, 11px);
    padding-right: 5px;
    padding-left: 5px;
  }

  .global-status,
  .pipeline {
    margin-right: 0.85%;
    margin-left: 0.85%;
  }

  .step-one.pipeline-card.panel {
    overflow: hidden;
    padding-top: clamp(20px, 1.45vw, 24px);
    padding-bottom: clamp(20px, 1.45vw, 24px);
  }

  .step-one .step-heading {
    margin-bottom: clamp(9px, 0.72vw, 12px);
  }

  .step-five.pipeline-card.panel {
    overflow: hidden;
    padding: clamp(14px, 1.08vw, 18px) clamp(20px, 1.55vw, 26px);
  }

  .step-five .step-heading {
    align-items: center;
    gap: clamp(10px, 0.84vw, 14px);
    min-height: clamp(45px, 3.35vw, 56px);
    margin-bottom: clamp(6px, 0.48vw, 8px);
  }

  .step-five .step-number {
    width: clamp(43px, 3.23vw, 54px);
    height: clamp(43px, 3.23vw, 54px);
    font-size: clamp(23px, 1.92vw, 32px);
  }

  .step-five .station-copy h2 {
    margin-bottom: 3px;
    font-size: clamp(27px, 2.15vw, 36px);
    line-height: 1;
  }

  .step-five .station-copy p {
    font-size: clamp(14px, 1.08vw, 18px);
    line-height: 1.1;
  }

  .step-five .step-body {
    display: grid;
    height: calc(100% - clamp(51px, 3.83vw, 64px));
    min-height: 0;
    grid-template-rows: auto clamp(34px, 2.45vw, 41px) clamp(30px, 2.28vw, 38px) minmax(0, 1fr);
    gap: clamp(6px, 0.48vw, 8px);
  }

  .step-five .epub-options {
    grid-template-columns: minmax(0, 1.3fr) auto;
    align-items: end;
    gap: clamp(8px, 0.72vw, 12px);
    margin-bottom: 0;
  }

  .step-five .epub-options label {
    gap: 3px;
    font-size: clamp(12px, 0.9vw, 14px);
  }

  .step-five .epub-options select {
    min-height: clamp(30px, 2.28vw, 36px);
    padding: 2px 8px;
    font-size: clamp(12px, 0.9vw, 14px);
  }

  .step-five .epub-options .check-row {
    padding-bottom: 6px;
  }

  .step-five .actions {
    gap: clamp(8px, 0.72vw, 12px);
    min-height: 0;
    height: 100%;
    align-self: stretch;
  }

  .step-five .actions button {
    min-height: 0;
    height: 100%;
    padding: 4px 12px;
    font-size: clamp(13px, 1.02vw, 17px);
  }

  .step-five .output-note {
    display: flex;
    align-items: center;
    min-height: 0;
    overflow: hidden;
    padding: 5px 10px;
    font-size: clamp(11px, 0.84vw, 14px);
    line-height: 1.25;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .step-five .final-preview-grid {
    display: grid;
    min-height: 0;
    height: 100%;
    grid-template-columns: 1.18fr 0.82fr 1fr 1.2fr;
    gap: clamp(7px, 0.6vw, 10px);
    margin-top: 0;
  }

  .step-five .final-metadata-panel,
  .step-five .final-cover-panel,
  .step-five .final-chapter-panel,
  .step-five .final-text-panel {
    min-height: 0;
    height: 100%;
    grid-column: auto;
    align-self: stretch;
    overflow: auto;
    padding: clamp(7px, 0.6vw, 10px);
  }

  .step-five .mini-summary {
    display: block;
  }

  .step-five .mini-summary::after {
    margin-top: 2px;
    font-size: 10px;
  }

  .step-five .mini-summary h3,
  .step-five .final-metadata-panel h3,
  .step-five .final-cover-panel h3 {
    margin: 0 0 3px;
    font-size: clamp(14px, 1.08vw, 18px);
    line-height: 1.1;
  }

  .step-five .mini-summary p {
    font-size: clamp(10px, 0.72vw, 12px);
    line-height: 1.15;
  }

  .step-five .metadata-summary {
    gap: 2px 7px;
    margin-top: 4px;
    font-size: clamp(10px, 0.72vw, 12px);
    line-height: 1.18;
  }

  .step-five .output-cover-preview {
    min-height: 0;
    height: calc(100% - 24px);
  }

  .step-five .output-cover-preview img {
    max-height: 100%;
  }

  .step-five .output-cover-preview span {
    padding: 4px;
    font-size: 10px;
  }

  .step-five .chapter-list,
  .step-five pre {
    max-height: calc(100% - 36px);
    margin-top: 5px;
    padding: 6px 8px;
    font-size: clamp(10px, 0.72vw, 12px);
    line-height: 1.35;
  }

  .step-five .chapter-list {
    padding-left: 21px;
  }

  .step-five .chapter-list li {
    padding: 3px 0;
  }
}

@media (min-width: 1081px) and (max-height: 850px) and (min-aspect-ratio: 2 / 1) {
  .app {
    zoom: 0.84;
  }
}

@media (min-width: 1081px) and (max-height: 760px) and (min-aspect-ratio: 2 / 1) {
  .app {
    zoom: 0.725;
  }
}

@media (max-width: 1080px) {
  .pipeline-card.panel {
    height: auto;
    min-height: 330px;
    overflow: visible;
  }
}

.input-source-grid {
  align-items: stretch;
  margin: 0;
}

.paste-input-panel {
  display: grid;
  grid-template-rows: auto minmax(72px, 1fr) auto;
  gap: clamp(8px, 0.72vw, 12px);
  min-width: 0;
  min-height: clamp(172px, 13.55vw, 226px);
  border: clamp(3px, 0.3vw, 5px) solid #6e4a2e;
  border-radius: 4px;
  background: linear-gradient(180deg, #fff8e8 0%, #fbe3ba 100%);
  padding: clamp(14px, 1.35vw, 22px);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.56),
    6px 7px 0 rgba(82, 50, 32, 0.2);
}

.paste-panel-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.paste-panel-heading > span:last-child {
  min-width: 0;
}

.paste-panel-heading h3,
.paste-panel-heading p {
  margin: 0;
}

.paste-panel-heading h3 {
  color: #076d66;
  font-family: "Courier New", "Microsoft JhengHei", "Microsoft YaHei", monospace;
  font-size: clamp(16px, 1.42vw, 23px);
  font-weight: 900;
  line-height: 1.1;
}

.paste-panel-heading p {
  margin-top: 3px;
  color: #6a5142;
  font-size: clamp(10px, 0.78vw, 13px);
  line-height: 1.3;
}

.paste-panel-icon {
  display: grid;
  flex: 0 0 auto;
  width: clamp(38px, 3.2vw, 54px);
  height: clamp(38px, 3.2vw, 54px);
  place-items: center;
  border: 3px solid #086d66;
  background: #fff6df;
  color: #08766e;
  font-family: "Courier New", monospace;
  font-size: clamp(11px, 0.9vw, 15px);
  font-weight: 900;
  box-shadow: 3px 3px 0 rgba(55, 30, 22, 0.18);
}

#pasteText {
  width: 100%;
  min-height: 0;
  height: 100%;
  resize: none;
  border: 3px solid #6e4a2e;
  background: #fffaf0;
  padding: 9px 10px;
  font-family: "Microsoft JhengHei", "Microsoft YaHei", ui-monospace, monospace;
  font-size: clamp(12px, 0.9vw, 15px);
  line-height: 1.45;
  box-shadow: inset 0 0 0 2px rgba(105, 66, 37, 0.08);
}

.paste-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.paste-stats {
  min-width: 0;
  overflow: hidden;
  color: #6a5142;
  font-size: clamp(10px, 0.78vw, 13px);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#processPastedText {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 6px 13px;
  font-size: clamp(12px, 0.9vw, 15px);
}

/* Portrait phones and tablets use a vertically flowing workspace. */
@media (orientation: portrait) and (max-width: 900px) {
  html {
    scroll-padding-top: 76px;
  }

  body {
    min-height: 100dvh;
    background: linear-gradient(rgba(104, 67, 34, 0.055) 1px, transparent 1px),
      linear-gradient(90deg, rgba(104, 67, 34, 0.055) 1px, transparent 1px),
      #f1d39a;
    background-size: 12px 12px;
  }

  .app {
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    margin: 0;
    padding: 0 12px 30px;
    background: none;
    overflow: visible;
    zoom: 1;
  }

  .pipeline-hero {
    visibility: visible;
    display: block;
    height: auto;
    min-height: 0;
    margin: 0 -12px;
    padding: 16px 18px 15px;
    border: 0;
    border-bottom: 4px solid #211715;
    background: linear-gradient(90deg, rgba(210, 139, 66, 0.18) 1px, transparent 1px) 0 0 / 8px 8px,
      linear-gradient(180deg, #fff4d6 0%, #f9ddb0 100%);
    box-shadow: inset 0 -6px 0 rgba(182, 104, 46, 0.22),
      0 4px 0 rgba(83, 45, 29, 0.3);
    pointer-events: auto;
  }

  .pipeline-hero * {
    visibility: visible;
  }

  .hero-copy {
    display: block;
    max-width: none;
  }

  .pipeline-hero .eyebrow {
    display: inline-block;
    margin: 0 0 7px;
    border: 2px solid #08766e;
    background: #fff3cf;
    padding: 3px 7px;
    color: #08655f;
    font-size: 10px;
    line-height: 1.2;
    box-shadow: 2px 2px 0 rgba(48, 31, 24, 0.18);
  }

  h1 {
    max-width: 340px;
    margin: 0;
    color: #241713;
    font-size: clamp(27px, 8.4vw, 38px);
    letter-spacing: -0.04em;
    line-height: 1.02;
    text-wrap: balance;
  }

  .pipeline-hero .subhead {
    margin: 8px 0 0;
    color: #684a38;
    font-size: 12px;
    line-height: 1.35;
  }

  .hero-machine-art {
    display: none;
  }

  .tab-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    width: auto;
    height: auto;
    margin: 0 -4px;
    padding: 7px 5px 8px;
    border: 0;
    border-bottom: 4px solid #211715;
    background: linear-gradient(180deg, #c8793c 0%, #9f552f 100%);
    box-shadow: inset 0 3px 0 rgba(255, 235, 190, 0.38),
      0 4px 0 rgba(79, 42, 28, 0.28);
  }

  .tab-button {
    display: grid;
    grid-template-rows: 23px auto;
    place-items: center;
    min-width: 0;
    min-height: 56px;
    height: 56px;
    gap: 2px;
    border-width: 3px;
    padding: 4px 2px 3px;
    font-size: clamp(9px, 2.55vw, 12px);
    line-height: 1.05;
    text-align: center;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.42),
      2px 3px 0 rgba(54, 29, 22, 0.32);
  }

  .tab-button > span:last-child {
    display: -webkit-box;
    min-width: 0;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
    text-wrap: balance;
  }

  .tab-index {
    width: 23px;
    height: 23px;
    border-width: 2px;
    font-size: 13px;
    box-shadow: inset 0 0 0 1px rgba(233, 177, 98, 0.34);
  }

  .global-status {
    display: flex;
    align-items: center;
    min-height: 46px;
    margin: 9px 0 10px;
    border-width: 3px;
    padding: 8px 62px 8px 11px;
    font-size: 12px;
    line-height: 1.3;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.68),
      0 3px 0 rgba(111, 65, 35, 0.34);
  }

  .global-status::after {
    right: 12px;
    width: 9px;
    height: 9px;
    box-shadow: 16px 0 0 #f6be24,
      16px 0 0 2px #211715,
      32px 0 0 #e63e24,
      32px 0 0 2px #211715;
  }

  .pipeline {
    margin: 0;
    scroll-margin-top: 76px;
  }

  .pipeline-card.panel {
    height: auto;
    min-height: 0;
    overflow: visible;
    border-width: 3px;
    padding: 17px 14px 21px;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.62),
      4px 5px 0 rgba(91, 51, 32, 0.3);
  }

  .step-heading {
    align-items: center;
    gap: 11px;
    margin-bottom: 14px;
  }

  .step-number {
    width: 44px;
    height: 44px;
    border-width: 3px;
    font-size: 24px;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.24),
      3px 3px 0 rgba(55, 30, 22, 0.22);
  }

  .station-copy h2 {
    margin-bottom: 4px;
    font-size: clamp(24px, 7vw, 30px);
    letter-spacing: -0.04em;
    line-height: 1;
  }

  .station-copy p {
    font-size: 13px;
    line-height: 1.35;
  }

  .toolbar,
  .input-source-grid,
  .format-grid,
  .metadata-grid,
  .output-grid,
  .process-preview-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .paste-input-panel {
    grid-template-rows: auto minmax(150px, 1fr) auto;
    min-height: 260px;
    gap: 10px;
    border-width: 3px;
    padding: 14px;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.56),
      4px 5px 0 rgba(82, 50, 32, 0.18);
  }

  .paste-panel-heading h3 {
    font-size: 19px;
  }

  .paste-panel-heading p,
  .paste-stats {
    font-size: 11px;
  }

  .paste-panel-icon {
    width: 43px;
    height: 43px;
    font-size: 12px;
  }

  #pasteText {
    min-height: 150px;
    resize: vertical;
    font-size: 16px;
  }

  .paste-actions {
    align-items: stretch;
  }

  #processPastedText {
    min-height: 46px;
    font-size: 14px;
  }

  .file-drop,
  .cover-drop {
    grid-template-columns: auto minmax(0, 1fr);
    min-height: 164px;
    column-gap: 14px;
    border-width: 3px;
    padding: 18px 13px;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.62),
      4px 5px 0 rgba(82, 50, 32, 0.18);
  }

  .file-drop::before,
  .cover-drop::before {
    width: 48px;
    height: 58px;
    border-width: 3px;
    font-size: 17px;
  }

  .file-drop-title {
    font-size: clamp(19px, 5.4vw, 24px);
    letter-spacing: 0.02em;
    line-height: 1.15;
  }

  .file-drop-meta {
    margin-top: 5px;
    font-size: 12px;
    line-height: 1.3;
  }

  fieldset,
  .mini-panel {
    min-width: 0;
    border-width: 2px;
    padding: 12px;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5),
      3px 3px 0 rgba(85, 53, 34, 0.14);
  }

  .cover-info-panel,
  .output-note {
    min-width: 0;
    border-width: 2px;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5),
      3px 3px 0 rgba(85, 53, 34, 0.14);
  }

  legend,
  .cover-info-panel h3 {
    font-size: 14px;
  }

  label,
  .check-row {
    font-size: 14px;
    line-height: 1.4;
  }

  select,
  input[type="text"],
  textarea,
  button {
    min-height: 46px;
    font-size: 16px;
  }

  .check-row {
    min-height: 44px;
  }

  .check-row input[type="checkbox"] {
    width: 23px;
    height: 23px;
  }

  .cover-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
  }

  .cover-drop {
    grid-column: 1 / -1;
  }

  .cover-preview,
  .cover-info-panel {
    min-height: 215px;
  }

  .cover-info-panel {
    gap: 8px;
    padding: 10px;
    font-size: 11px;
  }

  .cover-info-list {
    gap: 4px 6px;
    font-size: 11px;
  }

  .cover-resize-note {
    font-size: 10px;
    line-height: 1.35;
  }

  .actions {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .output-note {
    margin-top: 11px;
    padding: 10px;
    font-size: 12px;
    line-height: 1.45;
    white-space: normal;
  }

  .final-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 11px;
  }

  .final-metadata-panel,
  .final-cover-panel {
    min-height: 0;
    height: auto;
    grid-column: auto;
    overflow: visible;
  }

  .final-chapter-panel,
  .final-text-panel {
    min-height: 0;
    height: auto;
    overflow: visible;
  }

  .final-chapter-panel,
  .final-text-panel {
    grid-column: 1 / -1;
  }

  .metadata-summary {
    gap: 4px 7px;
    font-size: 11px;
  }

  .output-cover-preview {
    min-height: 190px;
  }

  .chapter-list,
  pre {
    max-height: 240px;
    font-size: 12px;
    line-height: 1.55;
  }
}

@media (orientation: portrait) and (max-width: 420px) {
  .pipeline-hero {
    padding-right: 15px;
    padding-left: 15px;
  }

  .tab-button {
    font-size: 9px;
  }

  .pipeline-card.panel {
    padding-right: 12px;
    padding-left: 12px;
  }
}

@media (orientation: portrait) and (min-width: 600px) and (max-width: 900px) {
  .pipeline-hero {
    position: relative;
    min-height: 170px;
    padding-right: 225px;
  }

  .hero-machine-art {
    position: absolute;
    right: 28px;
    bottom: -2px;
    display: block;
    width: 178px;
    height: 164px;
    overflow: hidden;
  }

  .hero-machine-art img {
    width: 178px;
    height: 164px;
    object-fit: contain;
    image-rendering: pixelated;
    filter: drop-shadow(5px 6px 0 rgba(55, 30, 22, 0.2));
  }
}

.cover-drop.drag-over {
  border-color: #f0a925;
  background: linear-gradient(180deg, #fff4c9 0%, #f9df9e 100%);
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.62),
    0 0 0 3px #08766e,
    6px 8px 0 rgba(82, 50, 32, 0.24);
}
