:root {
  --paper: #f7f5ef;
  --card: #fffefb;
  --ink: #17211f;
  --muted: #69726f;
  --line: #dedfd9;
  --accent: #cc5a3d;
  --accent-dark: #9f3e29;
  --green: #2d6a57;
  --green-soft: #e7f1ec;
  --amber-soft: #f6eddc;
  --shadow: 0 20px 70px rgba(23, 33, 31, 0.08);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 90% 4%, rgba(204, 90, 61, 0.08), transparent 30%),
    var(--paper);
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.studio {
  width: min(1380px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 60px;
}
.topbar { display: flex; align-items: center; justify-content: space-between; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--ink);
  border-radius: 10px;
  font-family: "Songti SC", STSong, serif;
  font-size: 17px;
}

.text-button, .link-button, .replace-button, .close-button {
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.text-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}
.migration-banner {
  margin-top: 22px;
  padding: 15px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: #74422f;
  border: 1px solid #e5c7b9;
  border-radius: 14px;
  background: #fff3ed;
  font-size: 12px;
  line-height: 1.6;
}
.migration-banner strong { white-space: nowrap; }
.migration-banner span { color: #80665b; }

.hero {
  padding: clamp(70px, 9vw, 118px) 0 clamp(44px, 6vw, 72px);
  display: grid;
  grid-template-columns: minmax(520px, 1.25fr) minmax(280px, 0.75fr);
  align-items: end;
  gap: 70px;
}
.eyebrow, .step-kicker {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
}
h1 {
  margin: 0;
  font-family: "Songti SC", STSong, serif;
  font-size: clamp(58px, 7.8vw, 106px);
  font-weight: 500;
  line-height: 0.94;
  letter-spacing: -0.06em;
}
.hero-copy {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.85;
}

.batch-toolbar {
  margin-bottom: 18px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
}
.batch-toolbar > div { display: grid; gap: 4px; }
.batch-toolbar strong { font-size: 14px; }
.batch-toolbar span { color: var(--muted); font-size: 12px; }
.toolbar-actions { display: flex !important; align-items: center; gap: 8px; }
.toolbar-actions .secondary-button { min-height: 44px; font-size: 11px; white-space: nowrap; }

.primary-button, .secondary-button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 800;
}
.primary-button {
  width: 100%;
  color: white;
  background: var(--ink);
  border: 1px solid var(--ink);
}
.primary-button:hover:not(:disabled) { background: var(--green); border-color: var(--green); }
.primary-button:disabled { cursor: not-allowed; opacity: 0.4; }
.secondary-button { color: var(--ink); background: white; border: 1px solid var(--line); }
.toolbar-button { width: auto; min-width: 230px; }

.task-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.task-card {
  min-width: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 254, 251, 0.94);
  box-shadow: var(--shadow);
}
.task-card.busy { opacity: 0.78; }
.task-heading {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.task-heading > div { display: flex; align-items: center; gap: 10px; }
.task-index {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: white;
  border-radius: 50%;
  background: var(--ink);
  font-size: 12px;
  font-weight: 800;
}
.task-title { margin: 0; font-family: "Songti SC", STSong, serif; font-size: 24px; }
.task-badge {
  padding: 6px 9px;
  color: #7b6848;
  border-radius: 999px;
  background: var(--amber-soft);
  font-size: 10px;
  white-space: nowrap;
}
.task-badge.ready, .task-badge.published { color: var(--green); background: var(--green-soft); }

.task-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.section-title {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
}
.section-title span {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  border-radius: 50%;
  background: #f7e7e1;
  font-size: 10px;
}
.qr-row { display: grid; grid-template-columns: 132px minmax(0, 1fr); align-items: center; gap: 16px; }
.qr-preview {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}
.small-qr { width: 132px; }
.qr-preview canvas { width: 100%; height: 100%; }
.qr-placeholder {
  width: 62%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22%;
  opacity: 0.12;
}
.qr-placeholder i { border: 8px solid var(--ink); background: white; }
.qr-placeholder i:nth-child(4) { width: 18px; height: 18px; align-self: end; justify-self: end; border: 0; background: var(--ink); }
.qr-copy { min-width: 0; }
.qr-copy p { margin: 0 0 12px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.qr-actions { display: flex; align-items: center; gap: 10px; }
.qr-actions .secondary-button { flex: 1; padding: 0 10px; font-size: 11px; }
.reset-task-button { color: var(--accent-dark); font-size: 11px; }

.final-section { flex: 1; }
.drop-zone {
  width: 100%;
  min-height: 180px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink);
  border: 1px dashed #b9bdb7;
  border-radius: 14px;
  background: #faf9f5;
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragging { border-color: var(--accent); background: #fff8f4; }
.drop-icon { font-family: Arial, sans-serif; font-size: 28px; font-weight: 200; }
.drop-title { font-size: 13px; font-weight: 800; text-align: center; word-break: break-all; }
.drop-subtitle { color: var(--muted); font-size: 10px; text-align: center; }
.image-preview-wrap {
  min-height: 180px;
  padding: 10px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #eeeae2;
}
.image-preview { max-width: 100%; max-height: 260px; display: block; object-fit: contain; }
.replace-button {
  min-height: 32px;
  padding: 0 10px;
  position: absolute;
  top: 9px;
  right: 9px;
  color: white;
  border-radius: 8px;
  background: rgba(23, 33, 31, 0.8);
  text-decoration: none;
  font-size: 10px;
}
.publish-button { margin-top: auto; }
.task-status, .task-error {
  margin: 12px 0 0;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.6;
}
.task-status { color: var(--green); background: var(--green-soft); }
.task-error { color: #983b2a; background: #f9e8e3; }
.download-bin-button { margin-top: 10px; color: var(--accent-dark); font-size: 11px; }

.privacy-strip {
  margin-top: 18px;
  padding: 24px 28px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 30px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
}
.privacy-strip div { display: grid; gap: 6px; }
.privacy-strip strong { font-size: 12px; }
.privacy-strip span { color: var(--muted); font-size: 11px; line-height: 1.65; }

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  overflow: auto;
  background: rgba(12, 17, 16, 0.62);
  backdrop-filter: blur(8px);
}
.settings-dialog {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  padding: clamp(24px, 5vw, 44px);
  overflow: auto;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.3);
}
.settings-heading { margin-bottom: 30px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.settings-heading .step-kicker { margin-bottom: 5px; }
.settings-heading h2 { margin: 0; font-family: "Songti SC", STSong, serif; font-size: 31px; }
.close-button { font-size: 32px; line-height: 1; text-decoration: none; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { margin-bottom: 18px; display: grid; gap: 8px; }
.field > span:first-child { font-size: 12px; font-weight: 800; }
.field input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: white;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(204, 90, 61, 0.11); }
.field small { color: var(--muted); font-size: 11px; line-height: 1.6; }
.token-row { display: flex; gap: 8px; }
.token-row .secondary-button { min-height: 46px; flex: none; }
.remember-row { margin: -4px 0 18px; display: flex; align-items: flex-start; gap: 9px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.remember-row input { margin-top: 2px; accent-color: var(--green); }
.settings-help { padding: 14px 16px; display: grid; gap: 5px; border-radius: 12px; background: #f0eee8; font-size: 12px; line-height: 1.6; }
.settings-help a { color: var(--accent-dark); font-weight: 800; }
.settings-help span { color: var(--muted); }
.settings-message { margin: 14px 0 0; color: var(--green); font-size: 12px; }
.settings-actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 10px; }
.compact-button { width: auto; }

body.viewer-active { background: white; }
.viewer { min-height: 100vh; width: 100%; display: grid; place-items: center; background: white; }
.viewer-image { max-width: 100%; height: auto; display: block; margin: auto; }
.viewer-error { max-width: 420px; margin: 24px; color: #777; font-size: 14px; line-height: 1.7; text-align: center; }

@media (max-width: 1160px) {
  .task-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-card:last-child { grid-column: 1 / -1; width: calc(50% - 8px); justify-self: center; }
}
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; align-items: start; gap: 28px; }
  .hero-copy { max-width: 620px; }
  .task-grid { grid-template-columns: 1fr; }
  .task-card:last-child { grid-column: auto; width: auto; }
  .privacy-strip { grid-template-columns: 1fr; gap: 20px; }
}
@media (max-width: 560px) {
  .studio { width: min(100% - 24px, 1380px); padding-top: 16px; }
  .hero { padding: 66px 6px 42px; }
  .migration-banner { align-items: flex-start; flex-direction: column; gap: 4px; }
  .hero-copy { font-size: 14px; }
  .batch-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { align-items: stretch; flex-direction: column; }
  .toolbar-actions .secondary-button { width: 100%; }
  .toolbar-button { width: 100%; }
  .task-card { padding: 20px 16px; border-radius: 18px; }
  .qr-row { grid-template-columns: 116px minmax(0, 1fr); }
  .small-qr { width: 116px; }
  .modal-backdrop { padding: 10px; align-items: end; }
  .settings-dialog { max-height: calc(100vh - 20px); padding: 26px 18px; border-radius: 22px 22px 10px 10px; }
  .field-grid { grid-template-columns: 1fr; gap: 0; }
  .settings-actions { flex-direction: column-reverse; }
  .settings-actions button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
