:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #66716a;
  --line: #dfe5e0;
  --soft: #f6f8f6;
  --panel: #fbfcfb;
  --green: #2f6c21;
  --green-dark: #214e17;
  --amber: #f3a712;
  --danger: #a63f35;
  --white: #ffffff;
  --shadow: 0 18px 44px #16251b12;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #f8faf8 0%, #eef3ef 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.app-header {
  min-height: 72px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #ffffffd9;
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.app-header h1, .app-header p, h2 { margin: 0; }
.app-header h1 { font-size: 20px; font-weight: 750; }
.app-header p { margin-top: 3px; color: var(--muted); font-size: 12px; }
h2 { font-size: 15px; font-weight: 760; }

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.file-button, .ghost-button {
  position: relative;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.ghost-button:hover, .file-button:hover { border-color: var(--green); color: var(--green); }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.global-status {
  position: fixed;
  z-index: 20;
  top: 84px;
  left: 50%;
  max-width: min(520px, calc(100vw - 28px));
  padding: 10px 14px;
  border: 1px solid #bfd7b7;
  border-radius: 8px;
  background: #f1f8ef;
  color: #264d1f;
  box-shadow: 0 12px 30px #17201b18;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}
.global-status.error {
  border-color: #e2bbb5;
  background: #fff3f1;
  color: var(--danger);
}

.workspace {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(380px, 452px) minmax(0, 1fr);
}

.control-panel {
  overflow-y: auto;
  background: #ffffffee;
  border-right: 1px solid var(--line);
}

.control-section { padding: 20px 24px; border-bottom: 1px solid var(--line); }
.control-section h2 { margin-bottom: 12px; }

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  height: 42px;
  margin-bottom: 16px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3ef;
}
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.segmented input:checked + span { background: var(--green); color: var(--white); box-shadow: 0 5px 14px #2f6c2126; }

.field-label, .inline-fields label > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

textarea, input[type="text"], input[type="tel"], input[type="email"], select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
  color: var(--ink);
  outline: none;
}
textarea { resize: vertical; min-height: 128px; padding: 12px; line-height: 1.58; }
input[type="text"], input[type="tel"], input[type="email"], select { height: 42px; padding: 0 11px; }
textarea:focus, input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 2px #2f6c211c; }

.inline-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  margin-top: 12px;
}

.primary-button, .generate-button {
  width: 100%;
  height: 44px;
  margin-top: 14px;
  border: 0;
  border-radius: 7px;
  color: var(--white);
  font-weight: 700;
}
.primary-button { background: var(--green); }
.primary-button:hover { background: var(--green-dark); }
.generate-button { background: #17201b; color: var(--white); }
.generate-button:hover { background: #2f6c21; }
.generate-button:disabled { cursor: not-allowed; background: #d9ddd9; color: #8b938d; }

.status-line { min-height: 18px; margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.status-line.error { color: var(--danger); }

.section-heading { display: flex; align-items: center; justify-content: space-between; }
.section-heading span { color: var(--muted); font-size: 12px; }
.section-note { margin: -4px 0 10px; color: var(--muted); font-size: 12px; line-height: 1.45; }

.selection-list { display: grid; gap: 8px; min-height: 32px; }
.poster-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 30px 30px 30px;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  overflow: hidden;
  box-shadow: 0 1px 0 #17201b0a;
}
.poster-code { align-self: stretch; display: grid; place-items: center; background: var(--soft); color: var(--green-dark); font-weight: 800; }
.poster-copy { min-width: 0; padding: 7px 9px; }
.poster-copy strong, .poster-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poster-copy strong { font-size: 12px; }
.poster-copy small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.icon-button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}
.icon-button:hover { color: var(--green); background: var(--soft); }
.icon-button.remove:hover { color: var(--danger); }

.add-row { display: grid; grid-template-columns: minmax(0, 1fr) 38px; gap: 6px; margin-top: 10px; }
.add-row .icon-button { width: 38px; height: 38px; border: 1px solid var(--line); background: var(--soft); }

.clarification {
  padding: 10px;
  margin-top: 8px;
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  background: #fff9eb;
}
.clarification p { margin: 0 0 8px; font-size: 12px; line-height: 1.45; }
.clarification-options { display: flex; flex-wrap: wrap; gap: 6px; }
.clarification-options button { border: 1px solid #e6c36f; border-radius: 5px; background: var(--white); padding: 6px 8px; font-size: 11px; }
.clarification-options button.selected { border-color: var(--green); background: var(--green); color: var(--white); }
.clarification-options button.selected::after { content: "  ✓"; font-weight: 800; }

.contact-fields { display: grid; gap: 10px; }
.contact-fields label > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
.qr-update-row {
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
}
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #aab1ac; }
.status-dot.ready { background: var(--green); }
.secondary-button { height: 32px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); color: var(--ink); font-size: 12px; font-weight: 600; }
.secondary-button:hover { border-color: var(--green); color: var(--green); }

.preview-panel { min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: #f5f8f5; }
.preview-toolbar {
  min-height: 72px;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffffd9;
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.preview-toolbar h2 { margin-bottom: 4px; }
.preview-toolbar p { margin: 0; color: var(--muted); font-size: 12px; }
.preview-tabs { display: flex; gap: 6px; }
.preview-tabs button { border: 1px solid var(--line); border-radius: 6px; background: var(--white); padding: 7px 11px; font-size: 12px; }
.preview-tabs button.active { border-color: var(--green); background: var(--green); color: var(--white); }

.preview-empty, .preview-stage { flex: 1; overflow: auto; }
.preview-empty { display: grid; place-items: center; color: #8a938d; font-size: 14px; }
.preview-stage { padding: 28px; text-align: center; }
.preview-stage img { display: block; width: min(100%, 1080px); height: auto; margin: 0 auto; border-radius: 2px; box-shadow: var(--shadow); background: var(--white); }
.hidden { display: none !important; }

@media (max-width: 860px) {
  .app-header { height: auto; min-height: 68px; }
  .workspace { height: auto; min-height: calc(100vh - 72px); grid-template-columns: 1fr; }
  .control-panel { overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .preview-panel { min-height: 70vh; }
}

@media (max-width: 480px) {
  .app-header { padding: 10px 12px; }
  .app-header h1 { font-size: 17px; }
  .header-actions { gap: 6px; }
  .file-button, .ghost-button { padding: 7px 9px; font-size: 12px; }
  .global-status { top: 78px; }
  .control-section { padding: 16px 14px; }
  .preview-stage { padding: 10px; }
  .poster-row { grid-template-columns: 30px minmax(0, 1fr) 28px 28px 28px; }
}
