:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #5c6670;
  --line: #d9e0e7;
  --soft: #f3f7f9;
  --paper: #ffffff;
  --brand: #0b3d66;
  --brand-strong: #082f4f;
  --accent: #1f7a5b;
  --warn: #b25c10;
  --danger: #b3261e;
  --shadow: 0 10px 30px rgba(18, 32, 46, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: #eef3f6;
  color: var(--ink);
  font-family:
    "Noto Sans TC",
    "Microsoft JhengHei",
    system-ui,
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 22px;
  background: var(--paper);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand-logo {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0 auto 22px;
}

.form-switch {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.switch-button,
.submit-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 44px;
  font-weight: 700;
}

.switch-button.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.meta-panel,
.status-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
  margin-bottom: 16px;
}

.meta-panel h1 {
  margin: 0 0 2px;
  font-size: 22px;
  line-height: 1.3;
  color: var(--brand-strong);
}

label {
  display: grid;
  gap: 6px;
}

label span,
.field-label,
.group-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid #c7d1db;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
  outline: none;
}

textarea {
  min-height: 78px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(11, 61, 102, 0.13);
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dde7ec;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.search-box {
  margin-top: 2px;
}

.submit-button {
  width: 100%;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  min-height: 50px;
  font-size: 17px;
}

.submit-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.status-message {
  min-height: 22px;
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.status-message.error {
  color: var(--danger);
}

.status-message.success {
  color: var(--accent);
}

.questions-pane {
  padding: 24px;
}

.questions {
  display: grid;
  gap: 12px;
  max-width: 980px;
  margin: 0 auto;
}

.bottom-actions {
  max-width: 980px;
  margin: 18px auto 36px;
}

.question {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 4px 16px rgba(24, 40, 56, 0.04);
}

.question[hidden] {
  display: none;
}

.question summary {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 13px 16px;
  list-style: none;
  cursor: pointer;
}

.question summary::-webkit-details-marker {
  display: none;
}

.question-number {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--brand);
  font-weight: 800;
}

.question-title {
  min-width: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.45;
}

.question-state {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.question-body {
  display: grid;
  gap: 14px;
  padding: 0 16px 16px 74px;
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid #cad6df;
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  color: var(--ink);
  font-weight: 700;
}

.choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  border: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.choice span {
  color: inherit;
  font-size: 14px;
}

.choice:has(input:checked) {
  border-color: var(--brand);
  background: #e9f2f8;
  color: var(--brand-strong);
}

.detail-panel {
  display: none;
  gap: 12px;
  padding: 12px;
  border-left: 3px solid var(--accent);
  background: #f7faf8;
}

.hierarchy-root {
  display: grid;
  gap: 14px;
}

.option-block,
.hierarchy-section {
  display: grid;
  gap: 8px;
}

.section-body {
  display: grid;
  gap: 8px;
}

.option-block[data-depth="1"],
.hierarchy-section[data-depth="1"],
.option-block[data-depth="2"],
.hierarchy-section[data-depth="2"] {
  padding-left: 14px;
  border-left: 3px solid var(--accent);
}

.choice-wrap {
  display: grid;
  gap: 8px;
}

.child-panel {
  display: grid;
  gap: 12px;
  margin: 0 0 4px 18px;
  padding: 12px;
  border-left: 3px solid var(--accent);
  background: #f7faf8;
}

.child-panel[hidden],
.attachment-note[hidden] {
  display: none;
}

.attachment-note {
  margin: 0 0 0 18px;
  color: var(--warn);
  font-size: 13px;
  font-weight: 800;
}

.field-control {
  display: grid;
  gap: 6px;
  min-width: min(100%, 220px);
}

.field-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.field-input-wrap textarea {
  grid-column: 1 / -1;
}

.field-suffix {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.question.expanded .detail-panel,
.question.no-choices .detail-panel {
  display: grid;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.field-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

[data-question-id="q046"] .hierarchy-section[data-depth="1"] {
  padding: 14px 16px;
  border: 1px solid #d9e2e8;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: #f7fafc;
}

[data-question-id="q046"] .hierarchy-section[data-depth="1"] > .group-label {
  font-size: 14px;
  font-weight: 800;
}

[data-question-id="q046"] .hierarchy-section[data-section-id="parking_size"] {
  padding-left: 0;
  border-left: 0;
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.empty-state {
  padding: 36px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .questions-pane {
    padding: 14px;
  }

  .question summary {
    grid-template-columns: 38px 1fr;
  }

  .question-state {
    grid-column: 2;
  }

  .question-body {
    padding: 0 14px 14px;
  }

  .choice {
    width: 100%;
    justify-content: center;
  }
}
