:root {
  --bg: #0c0f14;
  --surface: #151a22;
  --surface2: #1c2330;
  --border: #2a3344;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #c9a227;
  --accent2: #3d8bfd;
  --success: #3ecf8e;
  --danger: #f07178;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "DM Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.bg-pattern {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(61, 139, 253, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(201, 162, 39, 0.08), transparent);
  pointer-events: none;
  z-index: 0;
}

.header {
  position: relative;
  z-index: 1;
  padding: 2rem 1.5rem 1rem;
  max-width: 1100px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #e8c547);
  color: #1a1408;
  font-family: "Noto Serif SC", serif;
  font-size: 1.6rem;
  font-weight: 700;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.logo h1 {
  font-family: "Noto Serif SC", serif;
  font-size: 1.5rem;
  font-weight: 700;
}

.logo p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 0.15rem;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.input-panel h2 {
  font-family: "Noto Serif SC", serif;
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.example-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1.4;
  padding: 0.55rem 0.75rem;
  text-align: left;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.example-chip:hover {
  background: rgba(61, 139, 253, 0.08);
  border-color: var(--accent2);
  color: var(--text);
}

.example-chip:active {
  background: rgba(61, 139, 253, 0.14);
}

.example-chip.is-active {
  background: rgba(61, 139, 253, 0.18);
  border-color: var(--accent2);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(61, 139, 253, 0.35);
}

textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.2s;
  max-height: 100px;
  min-height: 72px;
}

textarea:focus {
  outline: none;
  border-color: var(--accent2);
}

.requirement-field {
  margin-top: 0.25rem;
}

.requirement-label {
  display: block;
  font-family: "Noto Serif SC", serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.requirement-label::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 0.85em;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  border-radius: 2px;
  margin-right: 0.45rem;
  vertical-align: -0.05em;
}

#requirement {
  background: rgba(34, 42, 56, 0.95);
  border: 2px solid rgba(201, 162, 39, 0.5);
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  min-height: 76px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 2px 10px rgba(0, 0, 0, 0.18);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

#requirement::placeholder {
  color: #9aa5b8;
  opacity: 1;
}

#requirement:focus {
  border-color: var(--accent2);
  background: rgba(36, 44, 58, 0.98);
  box-shadow:
    0 0 0 3px rgba(61, 139, 253, 0.18),
    0 0 22px rgba(61, 139, 253, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.mode-selector {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.mode-label {
  color: var(--muted);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.mode-segments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.mode-segment {
  cursor: pointer;
}

.mode-segment input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-segment span {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.mode-segment input:checked + span {
  background: rgba(61, 139, 253, 0.15);
  border-color: var(--accent2);
  color: var(--text);
}

.mode-segment:hover span {
  border-color: var(--accent2);
  color: var(--text);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #dbb84a);
  color: #1a1408;
  border: none;
  padding: 0.75rem 1.8rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#submitBtn,
#paymentDoneBtn {
  width: 11.5rem;
  text-align: center;
}

.hidden { display: none !important; }

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.progress-header h3 { font-size: 1rem; }

#progressPct {
  color: var(--accent);
  font-weight: 600;
}

.progress-bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

#progressFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-msg {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.progress-log {
  list-style: none;
  margin-top: 0.75rem;
  max-height: 160px;
  overflow-y: auto;
  font-size: 0.82rem;
  color: var(--muted);
}

.progress-log li {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
}

.parsed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.parsed-item {
  background: var(--surface2);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
}

.parsed-item strong {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 0.15rem;
}

.parsed-item.editable input[data-key] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.parsed-item.editable input[data-key]:disabled {
  opacity: 0.7;
  background: var(--surface2);
}

.parsed-item-wide {
  grid-column: span 2;
}

.parsed-item-multiselect {
  position: relative;
  grid-column: span 2;
}

.ms-dropdown {
  position: relative;
  margin-top: 0.35rem;
}

.ms-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.ms-trigger:hover {
  border-color: var(--accent, #d4a017);
}

.ms-dropdown.is-open .ms-trigger {
  border-color: var(--accent, #d4a017);
  box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.15);
}

.ms-trigger-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-trigger-text.is-placeholder {
  color: var(--muted);
}

.ms-trigger-caret {
  color: var(--muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.ms-panel {
  position: absolute;
  z-index: 50;
  left: 0;
  top: calc(100% + 4px);
  width: 100%;
  min-width: 20rem;
  max-width: min(26rem, calc(100vw - 2rem));
  max-height: 280px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.ms-panel.hidden {
  display: none;
}

.ms-search {
  box-sizing: border-box;
  width: calc(100% - 1rem);
  margin: 0.5rem 0.5rem 0.25rem;
  padding: 0.35rem 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}

.ms-panel-list {
  overflow-y: auto;
  padding: 0.25rem 0.35rem 0.45rem;
}

.ms-option {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.45rem;
  border-radius: 6px;
  font-size: 0.84rem;
  line-height: 1.3;
  color: var(--text);
  cursor: pointer;
}

.ms-option:hover {
  background: var(--surface2);
}

.ms-option.hidden {
  display: none;
}

.ms-option input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.ms-option-text {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.parsed-item.editable textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.4rem;
  border-radius: 6px;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 2.5em;
  line-height: 1.45;
}

.parsed-intro {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
}

.parsed-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.parsed-pricing {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface2);
  border-radius: 10px;
  border-left: 3px solid var(--accent);
  font-size: 0.88rem;
}

.parsed-pricing h4 {
  margin: 0 0 0.5rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.parsed-pricing ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text);
}

.parsed-pricing .price-total {
  margin-top: 0.5rem;
  font-weight: 600;
  color: var(--accent);
}

.parsed-pricing.is-free {
  border-left-color: var(--success, #2d8a4e);
}

.parsed-pricing.is-free .price-total {
  color: var(--success, #2d8a4e);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface2);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.results-header {
  margin-bottom: 1rem;
}

.results-header h2 {
  font-family: "Noto Serif SC", serif;
  font-size: 1.25rem;
}

.results-warning {
  color: var(--accent);
  font-size: 0.88rem;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(201, 162, 39, 0.08);
  border-radius: 8px;
  border-left: 3px solid var(--accent2);
}

.disclaimer {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

.result-batch-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent2);
  margin-left: 0.35rem;
}

.continue-naming-wrap {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.continue-naming-hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.continue-naming-wrap .btn-secondary {
  border-color: var(--accent2);
  color: var(--accent2);
}

.continue-naming-wrap .btn-secondary:hover:not(:disabled) {
  background: rgba(201, 162, 39, 0.12);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.name-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color 0.2s, transform 0.2s;
}

.name-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.name-card.top3 {
  border-color: rgba(201, 162, 39, 0.5);
  background: linear-gradient(145deg, var(--surface), #1a1f2a);
}

.card-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--surface2);
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.name-card.top3 .card-rank {
  background: var(--accent);
  color: #1a1408;
}

.card-name {
  font-family: "Noto Serif SC", serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  margin-bottom: 0.25rem;
}

.card-score {
  display: inline-block;
  background: rgba(62, 207, 142, 0.15);
  color: var(--success);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.card-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.card-meaning {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.iching-detail {
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.iching-detail p { margin-bottom: 0.35rem; }

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  margin-right: 0.35rem;
}

.tag-ok { background: rgba(62, 207, 142, 0.15); color: var(--success); }
.tag-fail { background: rgba(240, 113, 120, 0.15); color: var(--danger); }
.tag-group { background: rgba(61, 139, 253, 0.15); color: var(--accent2); }

.excluded-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.excluded-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  font-size: 0.82rem;
}

.excluded-chip span { color: var(--danger); }

.error-panel {
  border-color: var(--danger);
  color: var(--danger);
}

.clarification-panel h3 {
  font-family: "Noto Serif SC", serif;
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}

.clarification-intro {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.clarification-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.clarification-field label {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 0.4rem;
}

.clarification-field label .required {
  color: var(--accent);
  margin-left: 0.25rem;
}

.clarification-field select,
.clarification-field input[type="text"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
}

.clarification-other {
  margin-top: 0.5rem;
}

.paid-tag {
  font-style: normal;
  font-size: 0.72rem;
  color: var(--accent);
  margin-left: 0.25rem;
}

.free-tag {
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--success);
  background: rgba(62, 207, 142, 0.12);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-left: 0.3rem;
  vertical-align: middle;
}

.char-mode-note {
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.payment-panel h3 {
  font-family: "Noto Serif SC", serif;
  margin-bottom: 0.35rem;
}

.payment-intro {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.payment-body {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}

.payment-qr-wrap {
  flex: 0 0 220px;
  background: #fff;
  border-radius: 12px;
  padding: 0.75rem;
  border: 1px solid var(--border);
}

.payment-qr {
  display: block;
  width: 200px;
  height: 200px;
  object-fit: contain;
}

.payment-meta {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.payment-amount strong {
  color: var(--accent);
  font-size: 1.4rem;
}

.payment-breakdown {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.5rem 0.65rem;
  background: var(--surface2);
  border-radius: 8px;
}

.payment-breakdown ul {
  margin: 0;
  padding-left: 1.1rem;
}

.payment-order code {
  background: var(--surface2);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.95rem;
}

.payment-status {
  color: var(--accent2);
  font-size: 0.92rem;
}

.payment-status.is-paid {
  color: var(--success);
}

.payment-hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.footer {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  position: relative;
  z-index: 1;
}

@media (max-width: 600px) {
  .examples-grid { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: 1fr; }
  .card-name { font-size: 1.6rem; }
}
