* {
  box-sizing: border-box;
}

/* Global font stack: Inter for Latin, Noto Sans Thai for Thai glyphs */
:root {
  --bg: #f6f7fb;
  --card-bg: #ffffff;
  --border: #e0e4ef;
  --text: #1b2430;
  --muted: #5c6170;
  --accent: #00c300;
  --accent-dark: #00a500;
  --warning: #d73a49;
  --info: #0066cc;
  /* Survey design tokens from Figma */
  --survey-green: #34C759;
  --survey-black: #000000;
  --survey-content-primary: #09090b;
  --survey-content-inverse: #ffffff;
  --survey-bg-primary: #ffffff;
  --survey-border-primary: #e4e4e7;
  --survey-radius-lg: 8px;
  --survey-spacing-1: 4px;
  --survey-spacing-2: 8px;
  --survey-spacing-3: 12px;
  --survey-padding-base: 6px;
  --survey-padding-lg: 8px;
  --survey-padding-2xl: 12px;
  --survey-padding-4xl: 16px;
  --slider-bar-height: 6px;
  --slider-bar-radius: 999px;
  --slider-thumb-size: 20px;
  --slider-thumb-shadow: 0 0 0 4px #fff;
  font-family: "Mulish", "Prompt", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  color: var(--text);
  background-color: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Mulish", "Prompt", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

/* Ensure variable font activates where supported */
/* Variable font support not required for Mulish/Prompt here */

/* Force Thai glyphs to use Noto Sans Thai first for consistent metrics */
:lang(th), [lang="th"] {
  font-family: "Prompt", "Mulish", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-feature-settings: normal;
}

/* Diagnostic utility (removable): apply .font-test class to verify font rendering */
.font-test { font-family: "Mulish", "Prompt"; font-weight: 600; letter-spacing: .5px; }

main.line-dashboard {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 96px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  margin: 0 0 6px;
  color: var(--muted);
}

.page-header h1 {
  margin: 0;
  font-size: 2.5rem;
}

.lede {
  color: var(--muted);
  margin: 8px 0 0;
  line-height: 1.5;
}

.status-chips {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.status-chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  color: var(--muted);
}

.status-chip.is-ready {
  border-color: rgba(0, 195, 0, 0.25);
  background: rgba(0, 195, 0, 0.08);
  color: var(--accent-dark);
}

.status-chip.is-missing {
  border-color: rgba(215, 58, 73, 0.25);
  background: rgba(215, 58, 73, 0.08);
  color: var(--warning);
}

.flash {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.95rem;
}

.flash.is-success {
  background: rgba(0, 195, 0, 0.12);
  color: var(--accent-dark);
}

.flash.is-error {
  background: rgba(215, 58, 73, 0.12);
  color: var(--warning);
}

.card {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

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

.card header h2 {
  margin: 0;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 4px 0 0;
}

.responsive-table {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 12px 8px;
}

th {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 6px;
}

.status-dot.is-ready {
  background: var(--accent);
}

.status-dot.is-missing {
  background: var(--warning);
}

.wysiwyg {
  border: 1px solid #d1d5db;
  border-radius: 0.75rem;
  padding: 0.75rem;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wysiwyg-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.wysiwyg-toolbar button {
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  background: #f8fafc;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  color: #1f2937;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.wysiwyg-toolbar button:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.wysiwyg-editor {
  min-height: 160px;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #111827;
  background: #fff;
  overflow-y: auto;
  position: relative;
}

.wysiwyg-editor:focus {
  outline: 2px solid #93c5fd;
  border-color: #93c5fd;
}

.wysiwyg-editor--empty::before {
  content: attr(data-placeholder);
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  color: #9ca3af;
  pointer-events: none;
}

.wysiwyg-editor ul,
.wysiwyg-editor ol {
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}

.wysiwyg-editor a {
  color: #2563eb;
  text-decoration: underline;
}

.rich-text {
  line-height: 1.6;
  word-break: break-word;
}

.rich-text p {
  margin: 0 0 0.75rem;
}

.rich-text p:last-child {
  margin-bottom: 0;
}

.rich-text ul,
.rich-text ol {
  padding-left: 1.25rem;
  margin: 0 0 0.75rem;
}

.rich-text a {
  color: #2563eb;
  text-decoration: underline;
}

.credential-value.is-missing {
  color: var(--warning);
  font-weight: 600;
}

code {
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  font-size: 0.9rem;
  background: rgba(15, 23, 42, 0.04);
  padding: 2px 6px;
  border-radius: 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin-top: 8px;
}

.btn.secondary {
  background: var(--info);
}

.btn:hover {
  background: var(--accent-dark);
}

.btn.secondary:hover {
  background: #0055a3;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-weight: 600;
}

.field input,
.field textarea {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

.field textarea {
  min-height: 120px;
}

dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 0;
}

dl div {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

dt {
  font-weight: 600;
  color: var(--muted);
}

dd {
  margin: 0;
}

@media (min-width: 720px) {
  .page-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* --- Survey / Figma index page styles --- */
.survey-root {
  max-width: 402px;
  margin: 0 auto 64px;
  padding: 0 0 32px;
  background: #ffffff;
  font-size: 14px;
  position: relative;
}
.survey-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 32px;
  backdrop-filter: blur(20px);
  font-family: "Inter", sans-serif;
  font-size: 15px;
}
.survey-status-bar .time { font-weight: 600; }
.survey-status-bar .close-btn {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #71717a;
}
.logo { text-align: center; }
.logo img { height: 44px; width: auto; }
.survey-form { display: flex; flex-direction: column; gap: 24px; padding: var(--survey-padding-2xl) var(--survey-padding-4xl); }
.group { display: flex; flex-direction: column; gap: 8px; margin: 0; border: 0; padding: 0; }
.group-label { font-weight: 500; color: var(--survey-black); letter-spacing: -0.3px; }
.input-box { background: var(--survey-bg-primary); border: 1px solid var(--survey-border-primary); border-radius: var(--survey-radius-lg); height: 40px; display:flex; align-items:center; padding: var(--survey-padding-base) var(--survey-padding-2xl); }
.input-box input { width: 100%; border: 0; outline: none; font-size: 16px; }
.radio-option { display: flex; align-items: center; gap: var(--survey-spacing-3); font-size: 16px; }
.radio-option input { width:16px; height:16px; border:1px solid var(--survey-border-primary); border-radius:var(--survey-radius-lg); appearance:none; position:relative; background:#fff; }
.radio-option input:checked { background: var(--survey-green); }
.radio-option input:checked::after { content:""; position:absolute; inset:4px; background:#fff; border-radius:4px; }
.scale-labels { display: flex; justify-content: space-between; font-weight:600; }
.scale { display:flex; justify-content:space-between; padding:0 20px; }
.radio-scale { width:16px; height:20px; display:flex; align-items:center; }
.radio-scale input { width:16px; height:16px; border:1px solid var(--survey-border-primary); border-radius:var(--survey-radius-lg); appearance:none; background:#fff; }
.radio-scale input:checked { background: var(--survey-green); }
.mood-group .mood-slider { margin-top: 8px; }
.mood-labels { display:flex; justify-content:space-between; font-weight:600; margin-bottom:4px; }
.mood-slider input[type=range] { width:100%; -webkit-appearance:none; appearance:none; height:var(--slider-bar-height); border-radius:var(--slider-bar-radius); background:#e5e7eb; outline:none; }
.mood-slider input[type=range]::-webkit-slider-thumb { -webkit-appearance:none; width:var(--slider-thumb-size); height:var(--slider-thumb-size); border-radius:50%; background:var(--survey-green); box-shadow:var(--slider-thumb-shadow); border:1px solid var(--survey-green); cursor:pointer; }
.actions { padding: 0 16px; }
.submit-btn { width:100%; background:var(--survey-green); color:var(--survey-content-inverse); border:none; border-radius:var(--survey-radius-lg); padding:12px 16px; font-size:16px; font-weight:600; cursor:pointer; box-shadow: inset 0 2px 0 rgba(255,255,255,0.15); transition: background .15s ease; }
.submit-btn:hover { background:#28a94a; }
.legacy-link { text-align:center; margin: 24px 0; }
