:root {
  color-scheme: dark;
  --bg: #090d12;
  --surface: #111922;
  --surface-2: #172231;
  --surface-3: #202b38;
  --line: #304052;
  --line-soft: #263443;
  --text: #f2f7fb;
  --muted: #9fb0c4;
  --blue: #3d84f6;
  --blue-2: #74a8ff;
  --green: #48d19a;
  --amber: #f3b454;
  --red: #f06b6b;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1820px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 86px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #101720;
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.topbar h1,
.panel h2,
.task-card h3 {
  margin: 0;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue-2);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: #162131;
  color: var(--muted);
  white-space: nowrap;
}

.status-pill.ok {
  color: var(--green);
}

.status-pill.fail {
  color: var(--red);
}

.pulse {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 16%, transparent);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 0.75fr) minmax(480px, 1.1fr) minmax(420px, 0.95fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.panel,
.log-panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  min-height: 520px;
  padding: 16px;
}

.panel-heading,
.task-card-head,
.log-head,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel h2 {
  font-size: 19px;
  line-height: 1.2;
}

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

.field span,
.toggle-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #334253;
  border-radius: 7px;
  background: #202020;
  color: var(--text);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input,
select {
  min-height: 43px;
  padding: 0 12px;
}

textarea {
  min-height: 306px;
  resize: vertical;
  padding: 12px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(61, 132, 246, 0.2);
  background: #242424;
}

.articles-field {
  margin-top: 14px;
}

.primary-button,
.secondary-button,
.ghost-button {
  border: 0;
  border-radius: 7px;
  min-height: 40px;
  padding: 0 14px;
  color: var(--text);
  transition: transform 0.14s ease, background 0.14s ease, opacity 0.14s ease;
}

.primary-button {
  flex: 1;
  background: var(--blue);
  font-weight: 800;
}

.secondary-button {
  background: #1b2635;
  border: 1px solid var(--line-soft);
}

.ghost-button {
  background: #202020;
  border: 1px solid var(--line-soft);
  color: #d4deea;
}

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

.danger-button {
  color: #ffb8b8;
}

.danger-button:hover {
  background: rgba(240, 107, 107, 0.14);
}

.danger-button:disabled {
  cursor: wait;
  opacity: 0.6;
  transform: none;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.action-row {
  margin-top: 16px;
}

.task-card {
  margin-top: 16px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.task-card.empty {
  background: #131a22;
}

.task-id {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
}

.task-card h3 {
  font-size: 22px;
}

.task-badge {
  min-width: 86px;
  text-align: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: #243246;
  color: var(--blue-2);
  font-size: 12px;
  font-weight: 800;
}

.task-badge.ready {
  background: rgba(72, 209, 154, 0.12);
  color: var(--green);
}

.task-badge.failed {
  background: rgba(240, 107, 107, 0.13);
  color: var(--red);
}

.task-badge.review {
  background: rgba(243, 180, 84, 0.14);
  color: var(--amber);
}

.task-message {
  min-height: 42px;
  margin: 14px 0;
  color: var(--muted);
  line-height: 1.45;
}

.progress-line {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #0b1118;
}

.progress-line span {
  display: block;
  width: 6%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 0.22s ease, background 0.22s ease;
}

.result-list,
.article-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

body.review-modal-open,
body.pdf-preview-open {
  overflow: hidden;
}

.review-modal-overlay,
.pdf-preview-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  width: 100vw;
  height: 100vh;
  padding: 14px;
  z-index: 1000;
  background: rgba(4, 8, 13, 0.78);
  backdrop-filter: blur(2px);
}

.review-modal-overlay[hidden],
.pdf-preview-overlay[hidden] {
  display: none;
}

.review-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(116, 168, 255, 0.3);
  border-radius: var(--radius);
  background: #111922;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.58);
  overflow: hidden;
}

.review-modal-header,
.review-slot-title,
.review-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.review-modal-header {
  min-height: 76px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: #101720;
}

.review-modal-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

.review-subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.review-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.review-summary span,
.review-chip {
  border-radius: 999px;
  padding: 5px 8px;
  background: #26364b;
  color: var(--blue-2);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.review-modal-scroll {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow-y: auto;
  padding: 14px 18px 20px;
  background: #0d141c;
}

.review-row {
  display: grid;
  gap: 9px;
}

.review-row h3 {
  margin: 0;
  color: #dbe8f7;
  font-size: 15px;
}

.review-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 9px;
}

.review-slots.mimaki {
  direction: rtl;
}

.review-slots.tdesk {
  direction: ltr;
}

.review-slot-card {
  direction: ltr;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 8px;
  min-height: 245px;
  padding: 11px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #151f2a;
}

.review-slot-card.empty {
  opacity: 0.58;
}

.review-slot-card.invalid {
  border-color: rgba(240, 107, 107, 0.78);
  background: #25171a;
}

.review-slot-title strong {
  color: var(--text);
}

.review-info-grid,
.review-edit-grid {
  display: grid;
  gap: 7px;
}

.review-info-field,
.review-edit-field {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 24px;
}

.review-info-field span,
.review-edit-field span {
  color: var(--muted);
  font-size: 12px;
}

.review-info-field strong {
  min-width: 0;
  color: #eef6ff;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.review-field-input {
  min-height: 30px;
  padding: 0 9px;
  border-radius: 6px;
  background: #202020;
}

.review-field-input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.review-field-input[aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(240, 107, 107, 0.16);
}

.review-slot-error {
  min-height: 18px;
  margin: 0;
  color: #ffb8b8;
  font-size: 12px;
}

.review-slot-error[hidden] {
  visibility: hidden;
  display: block;
}

.review-copy-analog {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
}

.review-copy-analog:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.review-modal-footer {
  position: sticky;
  bottom: 0;
  justify-content: center;
  padding: 14px 18px;
  border-top: 1px solid var(--line-soft);
  background: #101720;
}

.review-modal-footer button {
  min-width: 138px;
}

.pdf-preview-overlay {
  z-index: 1100;
}

.pdf-preview-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(116, 168, 255, 0.3);
  border-radius: var(--radius);
  background: #0c121a;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.58);
  overflow: hidden;
}

.pdf-preview-header,
.pdf-preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  background: #101720;
}

.pdf-preview-header {
  min-height: 76px;
  border-bottom: 1px solid var(--line-soft);
}

.pdf-preview-header h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

.pdf-preview-switcher {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.pdf-preview-chip {
  border-radius: 999px;
  padding: 5px 9px;
  background: #26364b;
  color: var(--blue-2);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.pdf-preview-chip.active {
  background: rgba(72, 209, 154, 0.16);
  color: var(--green);
}

.pdf-preview-stage {
  display: grid;
  position: relative;
  min-height: 0;
  padding: 14px 18px;
  background: #111;
}

.pdf-preview-viewport {
  grid-area: 1 / 1;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 7px;
  background: #747474;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.pdf-preview-viewport.dragging {
  cursor: grabbing;
}

.pdf-preview-page {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  will-change: transform;
}

.pdf-preview-page.active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.pdf-preview-canvas {
  display: block;
  background: #fff;
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.42);
  image-rendering: auto;
}

.pdf-preview-empty {
  display: grid;
  grid-area: 1 / 1;
  place-items: center;
  min-height: 320px;
  z-index: 2;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #151f2a;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.pdf-preview-footer {
  justify-content: center;
  border-top: 1px solid var(--line-soft);
}

.pdf-preview-footer button {
  min-width: 180px;
}

.result-link,
.article-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #141d27;
  color: var(--text);
  text-decoration: none;
}

.article-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.article-row.removable {
  grid-template-columns: minmax(0, 1fr) auto 34px;
}

.result-kind,
.article-status {
  border-radius: 999px;
  padding: 5px 8px;
  background: #26364b;
  color: var(--blue-2);
  font-size: 11px;
  font-weight: 800;
}

.result-name,
.article-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.article-remove-button {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(240, 107, 107, 0.45);
  border-radius: 7px;
  background: rgba(240, 107, 107, 0.11);
  color: #ffb8b8;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  transition: background 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
}

.article-remove-button:hover {
  border-color: rgba(240, 107, 107, 0.8);
  background: rgba(240, 107, 107, 0.2);
}

.article-remove-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

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

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 12px;
}

.settings-grid .field:not(.compact),
.toggle-field,
.limits-box {
  grid-column: 1 / -1;
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  margin-top: 14px;
}

.toggle-field input {
  width: 22px;
  min-height: 22px;
  accent-color: var(--blue);
}

.limits-box {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding: 13px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #0e151d;
  color: var(--muted);
  font-size: 13px;
}

.pdf-folder-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  padding: 13px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #0e151d;
}

.pdf-folder-box > div,
.pdf-folder-box p {
  grid-column: 1 / -1;
}

.pdf-folder-box h3 {
  margin: 0;
  font-size: 16px;
}

.pdf-folder-box p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.pdf-folder-box.ready {
  border-color: rgba(72, 209, 154, 0.55);
}

.pdf-folder-box.blocked {
  border-color: rgba(243, 180, 84, 0.55);
}

.pdf-folder-box button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.log-panel {
  margin-top: 14px;
}

.log-head {
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-weight: 750;
}

.log-stream {
  min-height: 138px;
  max-height: 210px;
  overflow: auto;
  padding: 12px 14px;
  background: #05090d;
  color: #c9d6e6;
  font: 13px/1.5 Consolas, "Cascadia Mono", monospace;
}

.log-entry {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 10px;
  padding: 3px 0;
}

.log-time {
  color: #66788e;
}

.log-entry.error {
  color: #ff9b9b;
}

.log-entry.ok {
  color: #91f0c5;
}

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

  .composer {
    grid-column: 1 / -1;
    min-height: auto;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 18px, 720px);
    padding-top: 9px;
  }

  .topbar,
  .workspace,
  .panel-heading,
  .action-row {
    display: grid;
  }

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

  .topbar {
    min-height: auto;
  }

  .panel {
    min-height: auto;
  }

  textarea {
    min-height: 220px;
  }

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

  .result-link,
  .article-row {
    grid-template-columns: 1fr;
  }

  .article-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .article-row.removable {
    grid-template-columns: minmax(0, 1fr) auto 34px;
  }

  .review-modal-overlay {
    padding: 8px;
  }

  .pdf-preview-overlay {
    padding: 8px;
  }

  .review-modal-header,
  .review-modal-footer,
  .pdf-preview-header,
  .pdf-preview-footer {
    display: grid;
    justify-content: stretch;
  }

  .review-summary,
  .pdf-preview-switcher {
    justify-content: flex-start;
  }

  .review-slots {
    grid-template-columns: 1fr;
    direction: ltr;
  }

  .review-modal-footer button {
    width: 100%;
  }

  .pdf-preview-stage {
    padding: 8px;
  }

  .pdf-preview-footer button {
    width: 100%;
  }
}
.task-notices {
  display: grid;
  gap: 6px;
  margin: 10px 0 4px;
  padding: 10px 12px;
  border: 1px solid rgba(245, 158, 11, 0.38);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.08);
  color: #fed7aa;
  font-size: 13px;
  line-height: 1.35;
}

.task-notices[hidden] {
  display: none;
}
