:root {
  --bg1: #f3fbff;
  --bg2: #d8f1f7;
  --bg3: #b8dfeb;
  --card: rgba(255, 255, 255, 0.9);
  --card-soft: rgba(244, 251, 255, 0.98);
  --card-highlight: rgba(145, 205, 221, 0.32);
  --border: rgba(22, 84, 111, 0.12);
  --text: #12314a;
  --muted: #587287;
  --green: #4ade80;
  --amber: #fbbf24;
  --rose: #fb7185;
  --red: #ef4444;
  --blue: #0891b2;
  --gold: #facc15;
  --gold-deep: #f59e0b;
  --teal-soft: #d9f4fb;
}

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  background: #eef8fb;
  font-family: "Noto Sans Thai", system-ui, sans-serif;
}

.page-gradient {
  position: relative;
  overflow-x: hidden;
  overflow-y: visible;
  background:
    linear-gradient(135deg, rgba(250, 204, 21, 0.18), transparent 18%),
    linear-gradient(168deg, rgba(8, 145, 178, 0.08), transparent 42%),
    radial-gradient(circle at top left, rgba(250, 204, 21, 0.18), transparent 24%),
    radial-gradient(circle at top right, rgba(8, 145, 178, 0.14), transparent 26%),
    linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 48%, #edf8fb 100%);
}

.page-gradient::before,
.page-gradient::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
}

.page-gradient::before {
  top: -6rem;
  left: -8rem;
  width: 32rem;
  height: 32rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(8, 145, 178, 0.1), transparent 68%);
}

.page-gradient::after {
  right: -10rem;
  top: 12rem;
  width: 34rem;
  height: 20rem;
  transform: rotate(-14deg);
  background: linear-gradient(90deg, rgba(250, 204, 21, 0.18), rgba(245, 158, 11, 0.02));
}

.container-fluid.container-xxl {
  position: relative;
  z-index: 1;
}

.hero-card,
.app-card,
.result-panel {
  position: relative;
  overflow: hidden;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border) !important;
  border-radius: 1.5rem;
  box-shadow: 0 18px 40px rgba(34, 89, 110, 0.12);
}

.interactive-card {
  --pointer-x: 50%;
  --pointer-y: 50%;
  isolation: isolate;
  transition: transform .24s ease, box-shadow .24s ease, border-color .24s ease;
}

.interactive-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  background:
    radial-gradient(circle at var(--pointer-x) var(--pointer-y),
    rgba(255, 255, 255, 0.92),
    rgba(103, 232, 249, 0.2) 18%,
    rgba(103, 232, 249, 0.08) 32%,
    transparent 60%);
  transition: opacity .18s ease;
}

.interactive-card > * {
  position: relative;
  z-index: 1;
}

@media (hover: hover) and (pointer: fine) {
  .interactive-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 44px rgba(34, 89, 110, 0.16);
    border-color: rgba(56, 189, 248, 0.22) !important;
  }

  .interactive-card:hover::after {
    opacity: 1;
  }
}

.hero-card {
  background:
    linear-gradient(112deg, rgba(58, 157, 185, 0.84), rgba(127, 202, 218, 0.56) 48%, rgba(239, 249, 252, 0.96) 100%),
    radial-gradient(circle at top right, rgba(250, 204, 21, 0.24), transparent 28%),
    radial-gradient(circle at bottom left, rgba(8, 145, 178, 0.16), transparent 30%),
    var(--card);
  min-height: 12rem;
}

.hero-card .card-body {
  position: relative;
  z-index: 1;
}

.hero-actions {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  z-index: 2;
}

.hero-card::before,
.hero-card::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.hero-card::before {
  right: -7rem;
  top: -2rem;
  width: 22rem;
  height: 10rem;
  transform: rotate(-8deg);
  background: linear-gradient(90deg, rgba(250, 204, 21, 0.9), rgba(245, 158, 11, 0.88));
  clip-path: polygon(0 38%, 100% 0, 100% 62%, 0 100%);
  opacity: 0.95;
}

.hero-card::after {
  right: -3rem;
  bottom: -3rem;
  width: 20rem;
  height: 20rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(103, 232, 249, 0.12), transparent 66%);
}

@media (min-width: 768px) and (max-width: 1199.98px) {
  .hero-card .card-body {
    padding-right: 11rem !important;
  }

  .hero-card::before {
    width: 12rem;
    height: 5.75rem;
    top: -.9rem;
    right: -4.25rem;
    opacity: .68;
  }

  .hero-card::after {
    right: -6rem;
    bottom: -5.5rem;
    width: 14rem;
    height: 14rem;
    opacity: .3;
  }

  .hero-copy h1 {
    max-width: 100%;
  }
}

.app-card::before,
.result-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, rgba(250, 204, 21, 0.9), rgba(103, 232, 249, 0.22), transparent 85%);
}

.hero-badge {
  display: inline-flex;
  width: fit-content;
  padding: .48rem .95rem;
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: .02em;
  color: #0f516c;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(15, 81, 108, 0.12);
  backdrop-filter: blur(10px);
}

.hero-title-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: .35rem;
}

.hero-copy {
  min-width: 0;
}

.hero-copy h1 {
  line-height: 1.02;
}

.hero-logo {
  width: 7rem;
  height: 7rem;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 10px 20px rgba(16, 63, 84, 0.18));
}

.hero-subtitle {
  margin-top: .4rem;
  font-family: "Prompt", "Noto Sans Thai", sans-serif;
  line-height: 1.18;
}

.hero-subtitle #heroSubtitleLine1 {
  font-size: clamp(1.3rem, 1.7vw, 1.6rem);
  font-weight: 800;
  letter-spacing: .03em;
  color: #0e4f6b;
  text-shadow: 0 8px 18px rgba(255, 255, 255, 0.18);
}

.hero-subtitle #heroSubtitleLine2 {
  margin-top: .12rem;
  font-size: clamp(.95rem, 1.12vw, 1.08rem);
  font-weight: 600;
  color: rgba(14, 79, 107, 0.9);
  text-shadow: 0 8px 18px rgba(255, 255, 255, 0.14);
}

.text-secondary-light,
.text-muted-custom,
.form-text {
  color: var(--muted) !important;
}

.hero-card .text-white,
.hero-card .text-secondary-light {
  color: #ffffff !important;
}

.hero-card .text-secondary-light {
  color: rgba(255, 255, 255, 0.86) !important;
}

.app-card .text-white,
.result-panel .text-white {
  color: var(--text) !important;
}

h1, h2, h3, .result-score, .status-pill, .btn, .hero-badge {
  font-family: "Prompt", "Noto Sans Thai", sans-serif;
}

.custom-control {
  background: var(--card-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 1rem;
}

.custom-control.field-invalid {
  border-color: rgba(239, 68, 68, 0.48);
  box-shadow: 0 0 0 .24rem rgba(239, 68, 68, 0.14);
}

.custom-control:focus,
.form-select:focus,
.form-control:focus {
  background: var(--card-soft);
  color: var(--text);
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 .25rem rgba(56, 189, 248, 0.15);
}

.form-control::placeholder {
  color: #7a92a3;
}

.metric-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(240, 249, 252, 0.92));
  border: 1px solid rgba(22, 84, 111, 0.1);
  border-radius: 1.2rem;
  padding: 1.2rem;
  box-shadow: 0 10px 28px rgba(62, 125, 145, 0.08);
}

.metric-header {
  display: flex;
  align-items: center;
  gap: .85rem;
  margin-bottom: .85rem;
}

.metric-header h3 {
  margin: 0;
  font-size: 1.26rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}

.example-note {
  font-size: .82em;
  font-weight: 500;
  opacity: .8;
}

.form-label {
  font-size: 1.3rem;
  font-weight: 600;
}

.metric-number {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.18), rgba(29, 78, 216, 0.14));
  color: #14516b;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 8px 18px rgba(34, 89, 110, 0.1);
}

.location-button-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
}

.location-option {
  min-height: 3.5rem;
  background: linear-gradient(180deg, rgba(250, 253, 255, 0.96), rgba(236, 247, 251, 0.98));
  border: 1px solid rgba(22, 84, 111, 0.1);
  border-radius: 1rem;
  color: var(--text);
  font-size: 1.28rem;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(62, 125, 145, 0.05);
}

.location-option:hover,
.location-option:focus-visible {
  background: rgba(8, 145, 178, 0.08);
  border-color: rgba(8, 145, 178, 0.3);
  color: #114861;
}

.location-option.active {
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.34), rgba(14, 116, 144, 0.5));
  border-color: rgba(12, 74, 110, 0.78);
  color: #083344;
  box-shadow: 0 0 0 .24rem rgba(8, 145, 178, 0.18), 0 12px 26px rgba(14, 116, 144, 0.16);
}

.location-button-grid.field-invalid {
  padding: .35rem;
  border-radius: 1.2rem;
  background: rgba(239, 68, 68, 0.07);
  box-shadow: 0 0 0 .14rem rgba(239, 68, 68, 0.18);
}

.metric-progress-wrap {
  padding: .95rem 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(22, 84, 111, 0.08);
  background: linear-gradient(180deg, rgba(252, 254, 255, 0.84), rgba(241, 249, 252, 0.96));
}

.metric-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .55rem;
}

.metric-progress-text {
  font-family: "Prompt", "Noto Sans Thai", sans-serif;
  font-size: 1.02rem;
  font-weight: 700;
  color: #0f4f69;
}

.metric-progress-track {
  width: 100%;
  height: .65rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.18);
}

.metric-progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(8, 145, 178, 0.82), rgba(34, 197, 94, 0.78));
  transition: width .24s ease;
}

.metric-option-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.metric-option-grid-compact {
  justify-content: center;
}

.metric-option-grid-wide .metric-option-button {
  min-width: 15rem;
}

.metric-option-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  min-height: 3.4rem;
  min-width: 7rem;
  padding: .8rem 1rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(239, 247, 251, 1));
  border: 1px solid rgba(22, 84, 111, 0.1);
  border-radius: 1rem;
  color: var(--text);
  font-weight: 600;
  transition: .2s ease;
  box-shadow: 0 8px 20px rgba(62, 125, 145, 0.05);
}

.metric-option-button:hover,
.metric-option-button:focus-visible {
  background: rgba(8, 145, 178, 0.08);
  border-color: rgba(8, 145, 178, 0.26);
  color: #114861;
}

.metric-option-button.active {
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.3), rgba(14, 116, 144, 0.46));
  border-color: rgba(12, 74, 110, 0.76);
  color: #083344;
  box-shadow: 0 0 0 .22rem rgba(8, 145, 178, 0.16), 0 12px 24px rgba(14, 116, 144, 0.14);
}

.metric-option-text {
  white-space: nowrap;
  font-size: 1.26rem;
}

.metric-option-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: .15rem .45rem;
  border-radius: 999px;
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: .01em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.18);
}

.metric-option-score.score-0 {
  background: rgba(34, 197, 94, 0.18);
  color: #166534;
}

.metric-option-score.score-1 {
  background: rgba(250, 204, 21, 0.18);
  color: #854d0e;
}

.metric-option-score.score-2 {
  background: rgba(249, 115, 22, 0.16);
  color: #9a3412;
}

.metric-option-score.score-3 {
  background: rgba(244, 63, 94, 0.16);
  color: #9f1239;
}

.metric-scale-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.metric-scale-btn {
  border: 1px solid rgba(22, 84, 111, 0.12);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(239, 247, 251, 1));
  color: var(--text);
  font-weight: 700;
  font-size: 1.18rem;
  padding: .55rem 1rem;
}

.metric-scale-btn:hover,
.scale-group .btn-check:checked + .metric-scale-btn {
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.28), rgba(37, 99, 235, 0.28));
  border-color: rgba(12, 74, 110, 0.72);
  color: #083344;
  box-shadow: 0 0 0 .2rem rgba(37, 99, 235, 0.12), 0 10px 22px rgba(14, 116, 144, 0.12);
}

.metric-scale-panel {
  display: grid;
  gap: .9rem;
  padding: 1rem;
  border-radius: 1.15rem;
  background: linear-gradient(180deg, rgba(249, 252, 255, 0.92), rgba(238, 247, 251, 0.98));
  border: 1px solid rgba(22, 84, 111, 0.1);
}

.metric-scale-label {
  color: var(--muted);
  font-weight: 600;
  font-size: 1.16rem;
}

.metric-scale-btn .example-note,
.metric-scale-label .example-note {
  font-weight: 500;
  opacity: .78;
}

.result-panel,
.advice-card {
  --severity-border: rgba(22, 84, 111, 0.14);
  --severity-fill-strong: rgba(8, 145, 178, 0.14);
  --severity-fill-soft: rgba(231, 246, 251, 0.98);
  --severity-text: #0f4f69;
  --severity-shadow: rgba(62, 125, 145, 0.08);
}

.severity-theme-normal {
  --severity-border: rgba(22, 163, 74, 0.42);
  --severity-fill-strong: rgba(34, 197, 94, 0.18);
  --severity-fill-soft: rgba(240, 253, 244, 0.98);
  --severity-text: #166534;
  --severity-shadow: rgba(34, 197, 94, 0.12);
}

.severity-theme-low {
  --severity-border: rgba(217, 119, 6, 0.46);
  --severity-fill-strong: rgba(250, 204, 21, 0.2);
  --severity-fill-soft: rgba(255, 251, 235, 0.98);
  --severity-text: #92400e;
  --severity-shadow: rgba(245, 158, 11, 0.14);
}

.severity-theme-urgent {
  --severity-border: rgba(234, 88, 12, 0.5);
  --severity-fill-strong: rgba(251, 146, 60, 0.2);
  --severity-fill-soft: rgba(255, 247, 237, 0.98);
  --severity-text: #9a3412;
  --severity-shadow: rgba(249, 115, 22, 0.15);
}

.severity-theme-emergent,
.severity-theme-red {
  --severity-border: rgba(185, 28, 28, 0.52);
  --severity-fill-strong: rgba(248, 113, 113, 0.2);
  --severity-fill-soft: rgba(254, 242, 242, 0.98);
  --severity-text: #991b1b;
  --severity-shadow: rgba(239, 68, 68, 0.16);
}

.result-score-card {
  background:
    linear-gradient(135deg, var(--severity-fill-strong), rgba(255, 255, 255, 0.32)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), var(--severity-fill-soft));
  border: 2px solid var(--severity-border);
  border-radius: 1.25rem;
  padding: 1.15rem 1.2rem;
  box-shadow: 0 10px 28px var(--severity-shadow);
}

@keyframes warningPulse {
  0%, 100% {
    box-shadow: 0 10px 28px rgba(62, 125, 145, 0.06);
    transform: translateY(0);
  }
  50% {
    box-shadow: 0 16px 34px rgba(245, 158, 11, 0.22);
    transform: translateY(-1px);
  }
}

@keyframes dangerPulse {
  0%, 100% {
    box-shadow: 0 10px 28px rgba(62, 125, 145, 0.06);
    transform: translateY(0);
  }
  50% {
    box-shadow: 0 18px 36px rgba(239, 68, 68, 0.24);
    transform: translateY(-2px);
  }
}

@keyframes warningHalo {
  0%, 100% {
    filter: saturate(1);
  }
  50% {
    filter: saturate(1.08);
  }
}

.result-panel.panel-warning .result-score-card {
  animation: warningPulse 1.9s ease-in-out infinite;
  border-color: rgba(234, 88, 12, 0.46);
}

.result-panel.panel-warning #urgencyLabel,
.result-panel.panel-warning #scoreStateTag {
  animation: warningHalo 1.9s ease-in-out infinite;
}

.result-panel.panel-danger .result-score-card {
  animation: dangerPulse 1.35s ease-in-out infinite;
  border-color: rgba(185, 28, 28, 0.52);
}

.result-panel.panel-danger #urgencyLabel,
.result-panel.panel-danger #redFlag,
.result-panel.panel-danger #scoreStateTag {
  animation: warningHalo 1.25s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .interactive-card,
  .interactive-card::after,
  .result-panel.panel-warning .result-score-card,
  .result-panel.panel-warning #urgencyLabel,
  .result-panel.panel-warning #scoreStateTag,
  .result-panel.panel-danger .result-score-card,
  .result-panel.panel-danger #urgencyLabel,
  .result-panel.panel-danger #redFlag,
  .result-panel.panel-danger #scoreStateTag {
    animation: none !important;
    transition: none !important;
  }
}

.result-score {
  font-size: clamp(3.5rem, 8vw, 5.4rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -.04em;
  color: var(--severity-text);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: .65rem 1rem;
  border: 2px solid transparent;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.28rem;
  width: fit-content;
}

.status-pill.low {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(22, 163, 74, 0.42);
  color: #166534;
}

.status-pill.mid {
  background: rgba(250, 204, 21, 0.16);
  border-color: rgba(217, 119, 6, 0.44);
  color: #854d0e;
}

.status-pill.high {
  background: rgba(251, 146, 60, 0.16);
  border-color: rgba(234, 88, 12, 0.46);
  color: #9a3412;
}

.status-pill.critical {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(185, 28, 28, 0.5);
  color: #991b1b;
}

.status-pill.neutral {
  background: rgba(148, 163, 184, 0.15);
  border-color: rgba(100, 116, 139, 0.36);
  color: #475569;
}

.status-pill.danger {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(185, 28, 28, 0.5);
  color: #991b1b;
}

.score-state-tag {
  border: 2px solid transparent;
  color: #fff;
}

.score-state-tag.ready {
  background: rgba(100, 116, 139, 0.92);
  border-color: rgba(71, 85, 105, 0.98);
}

.score-state-tag.active {
  background: rgba(14, 116, 144, 0.92);
  border-color: rgba(22, 78, 99, 0.98);
}

.score-state-tag.watch {
  background: rgba(220, 38, 38, 0.92);
  border-color: rgba(153, 27, 27, 0.98);
}

.btn-soft {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  color: var(--text);
}

#resetBtnTop {
  display: none !important;
}

.btn-soft:hover {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text);
}

.lang-toggle .btn {
  border-color: var(--border);
  color: var(--text);
  background: rgba(255, 255, 255, 0.76);
}

.lang-toggle .btn.active {
  background: rgba(8, 145, 178, 0.14);
  border-color: rgba(8, 145, 178, 0.28);
  color: #0f4f69;
}

.btn-outline-light {
  color: var(--text);
  border-color: rgba(22, 84, 111, 0.18);
  background: rgba(255, 255, 255, 0.78);
}

.btn-outline-light:hover,
.btn-outline-light:focus,
.btn-outline-light:active {
  color: #0f4f69;
  border-color: rgba(8, 145, 178, 0.24);
  background: rgba(8, 145, 178, 0.08);
}

.advice-box {
  display: grid;
  gap: .85rem;
}

.advice-card {
  background:
    linear-gradient(135deg, var(--severity-fill-strong), rgba(255, 255, 255, 0.28)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), var(--severity-fill-soft));
  border: 2px solid var(--severity-border);
  border-radius: 1.2rem;
  padding: 1rem;
  box-shadow: 0 10px 24px var(--severity-shadow);
}

.advice-card h3 {
  font-size: 1.34rem;
  margin: 0 0 .45rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  color: var(--severity-text);
  font-weight: 800;
}

.advice-card ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 1.18rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.advice-card .advice-emergency-item {
  color: #b91c1c;
  font-weight: 800;
}

.history-table-wrap {
  border: 1px solid var(--border);
  border-radius: 1rem;
  overflow: hidden;
}

.custom-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: rgba(22, 84, 111, 0.08);
}

.table-dark.custom-table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: transparent;
  --bs-table-active-bg: rgba(8, 145, 178, 0.04);
  --bs-table-hover-bg: rgba(8, 145, 178, 0.04);
  color: var(--text);
}

.custom-table thead th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  font-size: 1.14rem;
}

.custom-table td,
.custom-table th {
  padding: .9rem 1rem;
  vertical-align: middle;
  font-size: 1.16rem;
}

.save-status {
  min-height: 1.5rem;
  font-size: 1.16rem;
}

.save-status.success { color: #86efac; }
.save-status.error { color: #fda4af; }
.save-status.info { color: #dbeafe; }

.mobile-save-bar {
  display: none;
}

.sidebar-column {
  align-self: flex-start;
  position: relative;
}

.sticky-panel {
  width: 100%;
}

@media (min-width: 992px) {
  .metric-progress-wrap {
    display: none;
  }

  .sidebar-column {
    min-height: auto;
  }

  .sticky-panel {
    position: fixed;
    top: 1rem;
    left: 0;
    width: 100%;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    overflow-x: visible;
    padding-right: .35rem;
    scrollbar-gutter: stable;
  }
}

@media (max-width: 991.98px) {
  .sidebar-column {
    align-self: auto;
    min-height: auto;
  }

  .sticky-panel {
    position: static !important;
    width: 100%;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 767.98px) {
  .page-gradient {
    padding-bottom: 6.75rem;
  }

  .metric-progress-wrap {
    display: none;
  }

  .container-fluid.container-xxl {
    padding-left: .85rem;
    padding-right: .85rem;
  }

  .hero-card {
    min-height: auto;
    background:
      linear-gradient(150deg, rgba(58, 157, 185, 0.88), rgba(157, 222, 235, 0.72) 56%, rgba(245, 251, 253, 0.98) 100%),
      radial-gradient(circle at top left, rgba(255, 255, 255, 0.26), transparent 38%),
      var(--card);
  }

  .hero-card::before {
    width: 8.5rem;
    height: 4.25rem;
    top: -.45rem;
    right: -2.8rem;
    opacity: .48;
  }

  .hero-card::after {
    right: -5rem;
    bottom: -5rem;
    width: 12rem;
    height: 12rem;
    opacity: .42;
  }

  .location-button-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-card .card-body,
  .app-card .card-body,
  .result-panel .card-body {
    padding: 1rem !important;
  }

  .hero-card .card-body {
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
  }

  .hero-card .row {
    order: 1;
  }

  .hero-actions {
    position: static;
    order: 2;
    margin-top: .9rem;
    margin-bottom: 0;
    display: flex;
    justify-content: center;
  }

  .hero-actions > div {
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: .55rem;
  }

  .lang-toggle {
    display: inline-flex;
    width: auto;
    border-radius: 999px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(34, 89, 110, 0.08);
  }

  .lang-toggle .btn,
  #resetBtnTop {
    min-height: 2.35rem;
    padding: .42rem .95rem;
    font-size: .92rem;
    font-weight: 700;
    border-radius: 999px;
  }

  #resetBtnTop {
    width: auto;
    background: rgba(255, 255, 255, 0.76);
    backdrop-filter: blur(12px);
  }

  .hero-title-wrap {
    display: grid;
    grid-template-columns: 4.75rem minmax(0, 1fr);
    align-items: center;
    gap: .85rem;
    margin-bottom: 0;
  }

  .hero-logo {
    width: 4.75rem;
    height: 4.75rem;
  }

  .hero-copy h1 {
    font-size: clamp(2.15rem, 8vw, 2.75rem);
    line-height: .98;
    margin-bottom: .45rem !important;
  }

  .hero-subtitle {
    margin-top: .3rem;
  }

  .hero-subtitle #heroSubtitleLine1 {
    font-size: 1.2rem;
  }

  .hero-subtitle #heroSubtitleLine2 {
    font-size: .92rem;
  }

  .metric-card {
    padding: .9rem;
  }

  .metric-option-grid {
    gap: .6rem;
  }

  .metric-option-button,
  .metric-option-grid-wide .metric-option-button {
    width: 100%;
    min-width: 0;
    align-items: flex-start;
    padding: .85rem .95rem;
  }

  .metric-option-text {
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.25;
    flex: 1 1 auto;
    min-width: 0;
  }

  .metric-option-score {
    flex-shrink: 0;
    align-self: flex-start;
  }

  .form-label {
    font-size: 1.16rem;
  }

  .metric-header h3,
  .metric-option-text,
  .location-option,
  .status-pill,
  .advice-card h3,
  .advice-card ul,
  .custom-table td,
  .custom-table th {
    font-size: 1.08rem;
  }

  .custom-table td,
  .custom-table th {
    padding: .75rem .7rem;
  }

  .metric-progress-wrap {
    padding: .85rem .9rem;
  }

  .metric-progress-text {
    font-size: .98rem;
  }

  .mobile-save-bar {
    position: fixed;
    left: .85rem;
    right: .85rem;
    bottom: .85rem;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    padding: .8rem .9rem;
    border-radius: 1.2rem;
    border: 1px solid rgba(22, 84, 111, 0.12);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 18px 36px rgba(34, 89, 110, 0.16);
    backdrop-filter: blur(14px);
  }

  .mobile-save-bar.is-complete {
    border-color: rgba(34, 197, 94, 0.24);
    box-shadow: 0 18px 36px rgba(34, 197, 94, 0.12);
  }

  .mobile-save-meta {
    min-width: 0;
    flex: 1 1 auto;
  }

  .mobile-save-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
  }

  .mobile-save-hint {
    font-size: .82rem;
    font-weight: 600;
    color: var(--muted);
  }

  .mobile-save-summary {
    display: flex;
    align-items: center;
    gap: .38rem;
    margin-top: .08rem;
    font-family: "Prompt", "Noto Sans Thai", sans-serif;
    font-weight: 700;
    color: var(--text);
  }

  .mobile-save-progress,
  .mobile-save-score {
    font-size: 1rem;
  }

  .mobile-save-divider {
    color: #7a92a3;
  }

  .mobile-reset-btn,
  .mobile-save-btn {
    flex-shrink: 0;
    min-height: 2.8rem;
    padding: .6rem .95rem;
    border-radius: 999px;
    font-size: .98rem;
    font-weight: 700;
  }

  .mobile-reset-btn {
    background: rgba(255, 255, 255, 0.82);
  }
}
