:root {
  color-scheme: dark;
  --bg: #121832;
  --panel: rgba(31, 40, 68, 0.92);
  --panel-strong: #172139;
  --line: rgba(214, 224, 255, 0.18);
  --line-strong: rgba(244, 183, 73, 0.72);
  --text: #f7f8ff;
  --muted: #c7cede;
  --soft: #8f98ad;
  --gold: #ffc14b;
  --orange: #ff8a65;
  --input: #10172a;
  --shadow: 0 24px 80px rgba(2, 7, 20, 0.36);
  font-family: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 6%, rgba(255, 193, 75, 0.14), transparent 28%),
    linear-gradient(135deg, #101633 0%, #18213c 42%, #11192d 100%);
  color: var(--text);
}

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

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

.pdf-app {
  min-height: 100vh;
  padding: 0 44px 56px;
}

.topbar {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  font-size: 20px;
  font-weight: 900;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #151b2e;
  background: linear-gradient(135deg, var(--gold), var(--orange));
  font-size: 13px;
}

.ghost-link {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-weight: 800;
}

.workspace {
  width: min(1480px, 100%);
  margin: 46px auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(380px, 0.72fr);
  gap: 28px;
  align-items: start;
}

.left-stack {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.panel {
  background: linear-gradient(160deg, rgba(32, 42, 73, 0.96), rgba(24, 33, 58, 0.96));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 34px;
}

.result-panel {
  padding: 30px;
  position: sticky;
  top: 24px;
}

.section-head {
  margin-bottom: 28px;
}

.section-head.compact {
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(42px, 5vw, 78px);
  letter-spacing: 0;
}

h2 {
  font-size: 30px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.field.wide {
  margin-bottom: 20px;
}

.field span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 16px;
  color: var(--text);
  background: var(--input);
  outline: none;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--gold);
}

input[type="range"] {
  min-height: 50px;
  padding: 0;
  accent-color: var(--gold);
  background: transparent;
}

input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

textarea {
  min-height: 126px;
  padding: 14px 16px;
  resize: vertical;
  line-height: 1.6;
}

.option-panel {
  margin: 0 0 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 900;
}

.photo-style-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 14px;
}

.photo-style-grid .field {
  margin-bottom: 0;
}

.photo-style-grid b {
  color: var(--gold);
}

.brand-library-panel,
.style-lab-panel {
  margin: 0 0 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
}

.brand-library-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.brand-library-head h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.brand-library-head p:not(.eyebrow),
.brand-library-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.brand-library-head > span {
  flex: none;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  color: var(--gold);
  font-size: 13px;
  font-weight: 950;
}

.style-upload-zone {
  min-height: 92px;
  margin: 12px 0 14px;
  border: 1.5px dashed rgba(255, 193, 75, 0.5);
  border-radius: 16px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  color: var(--muted);
  background: rgba(16, 23, 42, 0.5);
  cursor: pointer;
  text-align: center;
}

.style-upload-zone:hover,
.style-upload-zone.dragover {
  border-color: var(--gold);
  background: rgba(255, 193, 75, 0.08);
}

.style-upload-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.style-upload-zone strong {
  color: var(--text);
  font-size: 15px;
}

.style-upload-zone small {
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.compact-field textarea {
  min-height: 86px;
}

.style-lab-actions {
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.style-analysis-card {
  margin-top: 12px;
  border: 1px solid rgba(255, 193, 75, 0.32);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 193, 75, 0.07);
}

.style-analysis-card strong,
.custom-style-card strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.style-analysis-card p,
.custom-style-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.custom-style-list {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.custom-style-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(10, 18, 34, 0.62);
}

.custom-style-card.active {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 2px rgba(255, 193, 75, 0.12);
}

.custom-style-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.custom-style-actions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.custom-style-actions button.danger {
  color: #ffd7dc;
  border-color: rgba(255, 111, 121, 0.35);
}

.brand-library-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.brand-library-filter button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.brand-library-filter button.active {
  color: #11182b;
  border-color: transparent;
  background: var(--gold);
}

.brand-asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}

.brand-asset-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  color: var(--muted);
  background: rgba(10, 18, 34, 0.66);
  text-align: left;
  cursor: pointer;
}

.brand-asset-card.selected {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 2px rgba(255, 193, 75, 0.14);
}

.brand-asset-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: block;
  border-radius: 10px;
  background: #fff;
}

.brand-asset-card span,
.brand-asset-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-asset-card span {
  margin-top: 8px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
}

.brand-asset-card strong {
  margin-top: 3px;
  color: var(--text);
  font-size: 12px;
}

.brand-library-note {
  margin-top: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(255, 193, 75, 0.13);
}

.upload-zone {
  min-height: 178px;
  margin: 6px 0 22px;
  border: 1.5px dashed rgba(255, 193, 75, 0.58);
  border-radius: 18px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  cursor: pointer;
  background: rgba(16, 23, 42, 0.52);
}

.upload-zone.dragover {
  border-color: var(--gold);
  background: rgba(255, 193, 75, 0.1);
}

.upload-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: #131a2d;
  background: linear-gradient(135deg, var(--gold), var(--orange));
  font-weight: 1000;
}

.upload-zone strong {
  font-size: 22px;
}

.upload-zone small {
  color: var(--soft);
  font-weight: 800;
}

.flow-line {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 18px 0 24px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.flow-line span {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
}

.flow-line i {
  width: 42px;
  height: 1px;
  background: var(--line-strong);
}

.submit-row,
.result-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.primary-btn,
.secondary-btn {
  min-height: 52px;
  border-radius: 14px;
  padding: 0 24px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 950;
  cursor: pointer;
}

.primary-btn {
  color: #11182b;
  background: linear-gradient(135deg, var(--gold), var(--orange));
  box-shadow: 0 14px 34px rgba(255, 138, 101, 0.22);
}

.secondary-btn {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

.primary-btn:disabled,
.secondary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.status-box {
  min-height: 78px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--panel-strong);
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--soft);
  flex: none;
}

.status-box.running .status-dot {
  background: var(--gold);
  box-shadow: 0 0 0 8px rgba(255, 193, 75, 0.12);
}

.status-box.success .status-dot {
  background: #7ee0a1;
}

.status-box.error .status-dot {
  background: #ff6f79;
}

.status-box strong {
  display: block;
  margin-bottom: 4px;
  font-size: 17px;
}

.status-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.debug-console {
  margin-top: 18px;
  border: 1px solid rgba(126, 224, 161, 0.22);
  border-radius: 16px;
  overflow: hidden;
  background: #07101f;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025);
}

.debug-console-head {
  min-height: 42px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #7ee0a1;
  background: rgba(126, 224, 161, 0.08);
  border-bottom: 1px solid rgba(126, 224, 161, 0.16);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.14em;
}

.debug-console-head button {
  min-height: 28px;
  border: 1px solid rgba(126, 224, 161, 0.22);
  border-radius: 8px;
  padding: 0 10px;
  color: #d9ffe6;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

.debug-log {
  height: 210px;
  overflow: auto;
  padding: 12px 14px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.debug-line {
  display: grid;
  grid-template-columns: 70px 74px minmax(0, 1fr);
  gap: 8px;
  color: #d8e5ff;
  word-break: break-word;
}

.debug-time {
  color: #7787a6;
}

.debug-level {
  font-weight: 900;
}

.debug-level.info {
  color: #9fb7ff;
}

.debug-level.run {
  color: var(--gold);
}

.debug-level.done {
  color: #7ee0a1;
}

.debug-level.err {
  color: #ff8c96;
}

.preview-frame {
  margin: 22px 0;
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #0c1324;
}

.preview-frame iframe {
  width: 100%;
  height: 620px;
  border: 0;
  background: #fff;
}

.analysis-results {
  margin: 22px 0;
  display: grid;
  gap: 18px;
}

.analysis-section {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: rgba(10, 18, 34, 0.55);
}

.analysis-section h3 {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 950;
}

.text-block-list,
.logic-list {
  display: grid;
  gap: 12px;
}

.text-block,
.logic-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.035);
}

.text-block strong,
.logic-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--gold);
  font-size: 14px;
}

.text-block p,
.logic-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  white-space: pre-wrap;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.asset-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.035);
}

.asset-card a {
  display: block;
}

.asset-card .asset-download {
  min-height: 34px;
  margin: 0 10px 10px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 12px;
}

.asset-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  display: block;
  background: #fff;
}

.asset-meta {
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.asset-meta b {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.empty-preview {
  min-height: 620px;
  display: grid;
  place-items: center;
  color: var(--soft);
  font-size: 24px;
  font-weight: 900;
}

.analysis-section .empty-preview {
  min-height: 88px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  font-size: 16px;
}

.result-actions[hidden] {
  display: none;
}

.workflow-panel,
.previewer-panel,
.history-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  background: rgba(10, 18, 34, 0.68);
}

.workflow-panel[hidden],
.previewer-panel[hidden],
.history-panel[hidden] {
  display: none;
}

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

.workflow-head h3 {
  margin: 0;
  font-size: 20px;
}

.workflow-head > span {
  flex: none;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-weight: 900;
  font-size: 13px;
}

.workflow-meter {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.workflow-meter span {
  width: 0%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--orange));
  transition: width 0.35s ease;
}

.workflow-steps {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.workflow-step {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.workflow-step strong {
  color: var(--gold);
  font-size: 12px;
}

.shared-job-head {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.shared-job-head strong {
  font-size: 15px;
}

.shared-job-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.shared-job-list {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.shared-job-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  background: rgba(255, 255, 255, 0.035);
}

.shared-job-card.active {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 2px rgba(255, 193, 75, 0.12);
}

.shared-job-thumb {
  min-height: 124px;
  border: 0;
  padding: 0;
  display: grid;
  place-items: center;
  color: #11182b;
  background: #fff;
  cursor: pointer;
  font-weight: 950;
}

.shared-job-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.shared-job-body {
  min-width: 0;
  padding: 12px;
  display: grid;
  gap: 7px;
}

.shared-job-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.shared-job-title strong {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.shared-job-title span {
  flex: none;
  border-radius: 999px;
  padding: 2px 8px;
  color: #11182b;
  background: var(--soft);
  font-size: 11px;
  font-weight: 950;
}

.shared-job-title span.run {
  background: var(--gold);
}

.shared-job-title span.ok {
  background: #7ee0a1;
}

.shared-job-title span.err {
  background: #ff8c96;
}

.shared-job-body p,
.shared-job-body small {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.previewer-main {
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #080f1d;
}

.previewer-main img {
  width: 100%;
  max-height: 920px;
  object-fit: contain;
  display: block;
  background: #fff;
}

.previewer-toolbar {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.previewer-toolbar a {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.previewer-thumbs {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}

.previewer-thumb {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  text-align: left;
}

.previewer-thumb.active {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 2px rgba(255, 193, 75, 0.12);
}

.previewer-thumb img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  border-radius: 7px;
  background: #fff;
}

.previewer-thumb span {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 900;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.history-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.035);
}

.history-preview {
  width: 100%;
  border: 0;
  padding: 0;
  background: #fff;
  cursor: pointer;
}

.history-preview img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  display: block;
}

.history-card-body {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.history-card-body strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.history-card-body span,
.empty-history {
  color: var(--muted);
  font-size: 12px;
}

.empty-history {
  min-height: 82px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  display: grid;
  place-items: center;
  text-align: center;
}

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

.history-actions a,
.history-actions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

@media (max-width: 1100px) {
  .pdf-app {
    padding: 0 20px 36px;
  }

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

  .result-panel {
    position: static;
  }

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

@media (max-width: 640px) {
  .topbar {
    height: 74px;
  }

  .workspace {
    margin-top: 24px;
  }

  .control-panel,
  .result-panel {
    padding: 22px;
    border-radius: 18px;
  }

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

  .flow-line {
    flex-wrap: wrap;
  }

  .flow-line i {
    display: none;
  }

  .submit-row,
  .result-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
