:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #142033;
  --muted: #657489;
  --line: #d9e2ec;
  --navy: #1f3d5a;
  --teal: #2d7f78;
  --red: #c02f35;
  --shadow: 0 18px 45px rgba(20, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Noto Sans CJK KR", "NanumGothic", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 1440px;
  margin: 0 auto 18px;
}

.brand {
  color: var(--navy);
  font-weight: 900;
  font-size: 13px;
}

h1 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.2;
}

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

.ghost-button,
.mini-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 0 12px;
  text-decoration: none;
  cursor: pointer;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.4fr) minmax(300px, 0.8fr);
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
}

.panel-title span {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--navy);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
}

.panel-title h2,
.variant-head h3 {
  margin: 0;
  font-size: 17px;
}

.drop-zone {
  min-height: 220px;
  border: 1.5px dashed #9bb2c8;
  background: #f8fbfd;
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  padding: 24px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.drop-zone.active {
  border-color: var(--teal);
  background: #f0fbf8;
}

.drop-zone input {
  display: none;
}

.drop-zone svg {
  width: 48px;
  height: 48px;
  color: var(--navy);
}

.drop-zone strong {
  display: block;
  font-size: 18px;
}

.drop-zone small,
.file-card span,
.route-card span,
.jobMessage {
  color: var(--muted);
}

.file-card {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.file-card > div {
  min-width: 0;
}

.file-card b,
.file-card span {
  display: block;
  overflow-wrap: anywhere;
}

#fileMeta {
  white-space: pre-line;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  white-space: nowrap;
}

.status-pill.ok {
  border-color: #aad0c1;
  color: #176c5e;
  background: #f2fbf7;
}

.text-field {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: #344356;
  font-size: 13px;
  font-weight: 700;
}

.text-field input,
.text-field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

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

.module-card {
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-content: start;
  gap: 6px 8px;
  cursor: pointer;
}

.module-card:has(input:checked) {
  border-color: var(--teal);
  background: #f4fbfa;
  box-shadow: inset 4px 0 0 var(--teal);
}

.module-card input {
  margin-top: 2px;
}

.module-card b,
.module-card small {
  grid-column: 2;
}

.module-card small {
  color: var(--muted);
  line-height: 1.4;
}

.preview-button {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
  border: 1px solid #b8d7d2;
  background: #fff;
  color: #176c5e;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.preview-button:hover {
  background: #f2fbf7;
}

.preview-button.mini {
  grid-column: auto;
  grid-row: auto;
  padding: 4px 7px;
  font-size: 11px;
}

.variant-box {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.variant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.mini-actions {
  display: flex;
  gap: 6px;
}

.mini-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

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

.variant-grid label,
.toggle-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  min-height: 40px;
}

.variant-grid label span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.logo-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdff;
}

.logo-toggle {
  border: 0;
  padding: 0;
  min-height: 28px;
  font-weight: 800;
}

.logo-row {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.logo-preview {
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
  color: var(--navy);
  font-weight: 900;
  font-size: 12px;
  overflow: hidden;
}

.logo-preview.disabled {
  opacity: 0.4;
}

.logo-preview img {
  max-width: 100px;
  max-height: 42px;
  object-fit: contain;
}

.logo-actions {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.logo-actions small {
  color: var(--muted);
}

.render-logo-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  width: 100%;
}

.render-logo-row input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 9px;
  color: var(--ink);
}

.variant-box.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.run-panel {
  position: sticky;
  top: 16px;
}

.route-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.quality-grid {
  display: grid;
  gap: 10px;
}

.quality-button {
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  appearance: none;
}

.quality-button.active {
  border-color: var(--teal);
  background: #f3fbf8;
  box-shadow: inset 4px 0 0 var(--teal);
}

.quality-button.active b {
  color: #176c5e;
}

.difficulty-section {
  margin-top: 12px;
}

.difficulty-title {
  color: #344356;
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 7px;
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.difficulty-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.difficulty-button.active {
  border-color: var(--teal);
  background: #176c5e;
  color: #fff;
}

.route-card b,
.route-card span {
  display: block;
}

code {
  color: var(--navy);
  background: #f4f7fb;
  border-radius: 6px;
  padding: 4px 6px;
  word-break: break-word;
  font-size: 12px;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.preview-dialog {
  position: relative;
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.26);
  padding: 22px;
}

.preview-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.preview-kicker {
  color: var(--teal);
  font-weight: 900;
  font-size: 12px;
}

.preview-dialog h2 {
  margin: 4px 42px 6px 0;
  font-size: 22px;
}

.preview-dialog p {
  margin: 0;
}

.preview-dialog #previewDesc {
  color: var(--muted);
  margin-bottom: 14px;
}

.preview-paper {
  border: 1px solid #111827;
  background: #fff;
  padding: 16px;
  color: #111827;
  font-size: 13px;
  line-height: 1.45;
}

.preview-paper .preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid #1f3d5a;
  padding-bottom: 8px;
  margin-bottom: 10px;
  gap: 12px;
}

.preview-paper .preview-brand {
  color: #1f3d5a;
  font-weight: 900;
}

.preview-paper h3 {
  margin: 12px 0 6px;
  color: #1f3d5a;
  font-size: 15px;
}

.preview-paper .preview-box {
  border: 1px solid #d7e1ea;
  background: #f8fbfd;
  padding: 9px;
  margin: 7px 0;
}

.preview-paper .preview-emphasis {
  border-color: #c02f35;
  box-shadow: inset 4px 0 0 #c02f35;
}

.preview-paper .preview-choice {
  margin: 5px 0;
  padding-left: 0;
  list-style: none;
}

.preview-paper .preview-choice li {
  margin: 3px 0;
}

.preview-paper table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.preview-paper th,
.preview-paper td {
  border: 1px solid #111827;
  padding: 6px;
}

.preview-paper th {
  background: #e7edf4;
}

.run-button {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  margin: 14px 0;
}

.run-button svg {
  width: 19px;
  height: 19px;
}

.run-button:disabled {
  cursor: not-allowed;
  background: #9aa7b5;
}

.progress-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.progress-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.progress-top span {
  color: var(--muted);
  font-size: 12px;
}

.bar {
  height: 8px;
  background: #edf2f7;
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0;
}

.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--teal);
  transition: width 0.25s ease;
}

#jobMessage {
  color: var(--muted);
  min-height: 40px;
  margin: 0 0 10px;
}

.progress-details {
  border: 1px solid var(--line);
  background: #fbfdff;
  border-radius: 8px;
  padding: 9px;
  color: #344356;
  font-size: 12px;
  line-height: 1.45;
  margin-bottom: 10px;
}

.download-link {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 38px;
  border: 1px solid #b8d7d2;
  color: #176c5e;
  background: #f2fbf7;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 900;
}

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

  .run-panel {
    grid-column: 1 / -1;
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .app-header,
  .workspace {
    grid-template-columns: 1fr;
    display: grid;
  }

  .header-actions {
    justify-content: stretch;
  }

  .module-grid,
  .variant-grid {
    grid-template-columns: 1fr;
  }

  .logo-row,
  .render-logo-row {
    grid-template-columns: 1fr;
  }

  .difficulty-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
