@font-face {
  font-family: "Noto Sans Thai";
  src: url("../../assets/fonts/NotoSansThai-Regular.ttf") format("truetype");
  font-weight: 400;
}

@font-face {
  font-family: "Noto Sans Thai";
  src: url("../../assets/fonts/NotoSansThai-SemiBold.ttf") format("truetype");
  font-weight: 600;
}

@font-face {
  font-family: "Noto Sans Thai";
  src: url("../../assets/fonts/NotoSansThai-Bold.ttf") format("truetype");
  font-weight: 700;
}

:root {
  --bg: #fbfbff;
  --surface: #ffffff;
  --surface-soft: #f8f9ff;
  --surface-strong: #eef3ff;
  --border: #e0e5ef;
  --border-strong: #c7d0df;
  --text: #172033;
  --muted: #667085;
  --accent: #25324a;
  --accent-soft: #eef4ff;
  --rainbow: linear-gradient(90deg, #ff5d7d 0%, #ff9d42 18%, #ffd84d 35%, #3fd17f 52%, #37b7ff 69%, #7a6cff 84%, #d85cff 100%);
  --rainbow-soft: linear-gradient(135deg, rgba(255, 93, 125, 0.14), rgba(255, 216, 77, 0.13), rgba(63, 209, 127, 0.13), rgba(55, 183, 255, 0.14), rgba(216, 92, 255, 0.14));
  --rainbow-border: linear-gradient(#ffffff, #ffffff) padding-box, var(--rainbow) border-box;
  --good: #15815f;
  --danger: #a23b3b;
  --warning: #9a6a19;
  --shadow: 0 18px 46px rgba(39, 48, 72, 0.1);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans Thai", system-ui, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(251, 251, 255, 0.96)),
    linear-gradient(120deg, rgba(255, 93, 125, 0.12), rgba(255, 216, 77, 0.1) 30%, rgba(55, 183, 255, 0.12) 66%, rgba(216, 92, 255, 0.1)),
    var(--bg);
}

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

h1,
h2,
p {
  margin-top: 0;
}

.app-shell {
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 18px;
  align-items: stretch;
  overflow: hidden;
  padding: 24px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--rainbow-border);
  box-shadow: var(--shadow);
}

.hero::before {
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: var(--rainbow);
  content: "";
}

.hero-copy {
  display: grid;
  align-content: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: #59657a;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 8px;
  color: #111827;
  font-size: clamp(2rem, 4vw, 4.1rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 3px;
  font-size: 1.05rem;
  line-height: 1.35;
}

.lead {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.status-panel {
  display: grid;
  gap: 14px;
  align-content: center;
  padding: 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--rainbow-border);
}

.status-panel div {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.status-panel strong {
  color: #172033;
  font-size: 2rem;
  line-height: 1;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #3fd17f;
  box-shadow: 0 0 0 5px rgba(63, 209, 127, 0.16);
}

.quick-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.quick-steps article {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--rainbow-border);
}

.quick-steps strong,
.step-label {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--rainbow);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(91, 105, 255, 0.22);
}

.quick-steps span {
  color: var(--accent);
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.builder,
.preview,
.runner-notes {
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--rainbow-border);
  box-shadow: var(--shadow);
}

.builder {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.preview {
  position: sticky;
  top: 16px;
  padding: 16px;
}

.setup-panel {
  padding: 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: linear-gradient(#fbfcff, #fbfcff) padding-box, var(--rainbow) border-box;
}

.section-title {
  display: flex;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

.section-title p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.inline-title {
  justify-content: space-between;
}

.inline-title > div {
  display: grid;
  grid-template-columns: 30px 1fr;
  column-gap: 12px;
  align-items: start;
}

.inline-title > div h2,
.inline-title > div p {
  grid-column: 2;
}

.inline-title .step-label {
  grid-row: 1 / span 2;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field span,
.consent {
  color: var(--accent);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 11px 12px;
  line-height: 1.65;
}

input::placeholder,
textarea::placeholder {
  color: #98a2b3;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #7a6cff;
  box-shadow: 0 0 0 3px rgba(122, 108, 255, 0.16);
}

.grid-2,
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.consent {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  margin: 2px 0 18px;
  color: var(--muted);
  line-height: 1.65;
}

.consent input {
  width: 18px;
  min-height: 18px;
  margin-top: 5px;
  accent-color: var(--accent);
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.actions.compact {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  align-items: stretch;
  margin-bottom: 10px;
}

.actions.stacked {
  flex-direction: column;
}

button,
.link-button {
  display: inline-grid;
  min-height: 44px;
  place-items: center;
  border-radius: 8px;
  text-decoration: none;
}

button {
  padding: 0 16px;
  border: 0;
  background: var(--rainbow);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(91, 105, 255, 0.18);
}

button.secondary,
.link-button {
  border: 1px solid transparent;
  background: linear-gradient(#ffffff, #ffffff) padding-box, var(--rainbow) border-box;
  color: var(--accent);
  font-weight: 700;
  box-shadow: none;
}

button.danger {
  background: linear-gradient(90deg, #f04438, #ff8a4c);
}

button:hover:not(:disabled),
.link-button:hover {
  filter: brightness(0.98);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.question-mapper {
  margin: 0;
}

.question-list {
  display: grid;
  gap: 12px;
}

.question-empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 24px;
  border: 1px dashed #b8c3d5;
  border-radius: var(--radius);
  background: var(--rainbow-soft);
  color: var(--muted);
  text-align: center;
}

.question-empty-state strong {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 1rem;
}

.question-card {
  padding: 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--rainbow-border);
}

.question-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.question-card header strong {
  color: var(--accent);
}

.icon-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #ffd0d0;
  border-radius: 8px;
  background: #fff5f5;
  color: var(--danger);
  font-size: 0.88rem;
}

.answer-choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.answer-choice {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent);
  font-weight: 600;
}

.answer-choice:has(input:checked) {
  border-color: transparent;
  background: linear-gradient(#ffffff, #ffffff) padding-box, var(--rainbow) border-box;
  box-shadow: 0 6px 18px rgba(91, 105, 255, 0.14);
}

.answer-choice input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.choice-empty {
  width: 100%;
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.assist-toggle {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: linear-gradient(#fbfcff, #fbfcff) padding-box, var(--rainbow) border-box;
  color: var(--accent);
}

.assist-toggle[hidden] {
  display: none;
}

.assist-toggle input {
  width: 18px;
  min-height: 18px;
  margin-top: 3px;
  accent-color: var(--accent);
}

.assist-toggle span {
  display: grid;
  gap: 2px;
}

.assist-toggle strong {
  font-size: 0.92rem;
}

.assist-toggle small {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.extract-status {
  min-height: 26px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.extract-status[data-state="success"] {
  color: var(--good);
  font-weight: 700;
}

.extract-status[data-state="error"] {
  color: var(--danger);
  font-weight: 700;
}

.extract-status[data-state="loading"] {
  color: var(--accent);
  font-weight: 700;
}

.metric {
  display: grid;
  gap: 6px;
  min-height: 76px;
  padding: 13px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: linear-gradient(#fbfcff, #fbfcff) padding-box, var(--rainbow) border-box;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
}

.metric strong {
  color: var(--accent);
  font-size: 1rem;
  line-height: 1.35;
}

.plan-list {
  display: grid;
  gap: 10px;
  max-height: 430px;
  min-height: 188px;
  margin: 14px 0;
  overflow: auto;
  padding-right: 3px;
}

.empty-state,
.plan-item {
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--rainbow-border);
}

.empty-state {
  display: grid;
  min-height: 188px;
  place-items: center;
  color: var(--muted);
}

.plan-item {
  padding: 12px;
}

.plan-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.plan-item strong {
  color: var(--accent);
}

.plan-item header span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.plan-item p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.plan-item p + p {
  margin-top: 7px;
}

.run-output,
.advanced-tools {
  margin-top: 14px;
  padding: 13px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: linear-gradient(#fbfcff, #fbfcff) padding-box, var(--rainbow) border-box;
}

.run-output-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.run-output-title span {
  color: var(--muted);
  font-size: 0.88rem;
}

.run-log {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  color: var(--muted);
  line-height: 1.55;
}

.run-result-item {
  padding: 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--rainbow-border);
}

.run-result-item header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.run-result-item span {
  color: var(--good);
  font-size: 0.84rem;
  font-weight: 700;
}

.run-result-item p {
  margin: 0;
}

.advanced-tools summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.advanced-tools .actions {
  margin-top: 12px;
}

.runner-notes {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 18px;
  align-items: center;
  margin-top: 18px;
  padding: 20px;
}

.runner-notes p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.75;
}

.note-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.note-grid span {
  padding: 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: linear-gradient(#fbfcff, #fbfcff) padding-box, var(--rainbow) border-box;
  color: var(--accent);
  font-weight: 700;
  text-align: center;
}

@media (max-width: 980px) {
  .hero,
  .workspace,
  .runner-notes,
  .quick-steps {
    grid-template-columns: 1fr;
  }

  .app-shell {
    width: min(100% - 20px, 760px);
    padding: 12px 0 22px;
  }

  .preview {
    position: static;
  }

  .hero,
  .setup-panel,
  .preview,
  .runner-notes {
    padding: 16px;
  }

  .actions.compact {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 14px, 560px);
  }

  .builder {
    padding: 10px;
    gap: 10px;
  }

  .grid-2,
  .cards,
  .note-grid {
    grid-template-columns: 1fr;
  }

  .section-title,
  .inline-title {
    gap: 10px;
  }

  .inline-title {
    flex-direction: column;
  }

  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  button,
  .link-button {
    width: 100%;
  }

  h1 {
    font-size: 2.35rem;
  }
}
