:root {
  --primary: #3b82f6;
  --primary-pressed: #2563eb;
  --secondary: #f97171;
  --tertiary: #34d399;
  --warning: #fbbf24;
  --error: #ef4444;
  --background: #ffffff;
  --surface: #f9fafb;
  --surface-strong: #f3f4f6;
  --text: #111827;
  --text-secondary: #6b7280;
  --text-soft: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --blue-soft: #eff6ff;
  --coral-soft: #fff1f2;
  --mint-soft: #ecfdf5;
  --warning-soft: #fffbeb;
  --error-soft: #fef2f2;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-subtle: 0 1px 3px rgba(17, 24, 39, 0.06);
  --shadow-medium: 0 4px 12px rgba(17, 24, 39, 0.08);
  --shadow-large: 0 8px 24px rgba(17, 24, 39, 0.12);
  --page-gutter: max(18px, env(safe-area-inset-left));
}

* {
  box-sizing: border-box;
}

[hidden],
.icon-sprite {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: "DM Sans", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

body.assessment-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.top-app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px max(24px, env(safe-area-inset-right)) 12px max(24px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.brand-lockup {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-lockup img {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
}

.brand-lockup strong {
  display: block;
  font-family: "Figtree", "Helvetica Neue", sans-serif;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand-lockup small {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
}

.brand-lockup.small img {
  width: 34px;
  height: 34px;
}

.brand-lockup.small strong {
  font-size: 18px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.touch-page {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 30px 24px 54px;
}

.intro-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-subtle);
}

.intro-copy h1,
.assessment-intro h2 {
  margin: 0;
  font-family: "Figtree", "Helvetica Neue", sans-serif;
  font-size: 32px;
  font-weight: 800;
  line-height: 40px;
  letter-spacing: 0;
}

.intro-copy p,
.workspace-head p,
.result-header p,
.card-heading p,
.assessment-intro p,
.result-empty p {
  margin: 8px 0 0;
  color: var(--text-secondary);
}

.intro-copy p {
  max-width: 640px;
  font-size: 17px;
  line-height: 26px;
}

.status-stack {
  display: grid;
  gap: 12px;
}

.model-state,
.mini-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 12px 18px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
}

.model-state {
  color: #047857;
  font-weight: 700;
}

.model-state .icon {
  color: var(--tertiary);
}

.mini-card {
  display: grid;
  gap: 2px;
}

.mini-card span,
.result-label,
.metrics-list span,
.model-footnote {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
}

.mini-card strong {
  font-size: 15px;
  font-weight: 700;
}

.prediction-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 24px;
  align-items: start;
}

.workspace-card,
.result-shell,
.assessment-card {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-medium);
}

.workspace-card {
  overflow: hidden;
}

.workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 18px 0;
}

.workspace-head h2,
.result-header h2,
.card-heading h3,
.result-block h3,
.result-empty h3,
.quiz-head h3 {
  margin: 0;
  font-family: "Figtree", "Helvetica Neue", sans-serif;
  font-weight: 700;
  letter-spacing: 0;
}

.workspace-head h2,
.result-header h2,
.assessment-card h3 {
  font-size: 24px;
  line-height: 32px;
}

.segmented-control {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  background: var(--surface-strong);
  border-radius: var(--radius-lg);
}

.mode-option,
.bottom-nav-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  padding: 0 14px;
}

.mode-option.is-active,
.bottom-nav-button.is-active {
  color: var(--primary);
  background: #fff;
  box-shadow: var(--shadow-subtle);
}

.mode-view {
  display: none;
}

.mode-view.is-active {
  display: block;
}

.direct-form {
  padding: 18px;
}

.form-card {
  padding: 18px;
  margin-bottom: 18px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
}

.form-card:last-of-type {
  margin-bottom: 0;
}

.card-heading,
.result-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.result-header {
  justify-content: space-between;
  margin-bottom: 0;
}

.card-heading h3 {
  font-size: 20px;
  line-height: 28px;
}

.touch-icon,
.empty-symbol,
.item-icon {
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
}

.touch-icon {
  width: 42px;
  height: 42px;
}

.touch-icon.blue {
  color: var(--primary);
  background: var(--blue-soft);
}

.touch-icon.coral {
  color: var(--secondary);
  background: var(--coral-soft);
}

.touch-icon.mint {
  color: #059669;
  background: var(--mint-soft);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

input:hover,
select:hover {
  border-color: var(--border-strong);
}

input:focus,
select:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.chip-grid legend {
  width: 100%;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.chip-grid label {
  display: inline-flex;
  min-height: 44px;
  cursor: pointer;
}

.chip-grid input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  opacity: 0;
}

.chip-grid span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 9999px;
  color: var(--primary);
  background: var(--blue-soft);
  font-size: 13px;
  font-weight: 700;
}

.chip-grid label:has(input:checked) span {
  color: #fff;
  background: var(--primary);
}

.form-actions,
.assessment-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.form-actions {
  padding-top: 18px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-md);
  padding: 0 18px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.primary-button {
  color: #fff;
  background: var(--primary);
}

.primary-button:active {
  background: var(--primary-pressed);
}

.secondary-button {
  color: var(--primary);
  background: var(--surface-strong);
}

.secondary-button:active,
.ghost-button:active {
  background: var(--border);
}

.ghost-button {
  color: var(--text-secondary);
  background: transparent;
}

.icon-button {
  width: 48px;
  padding: 0;
  color: var(--text-secondary);
  background: var(--surface-strong);
}

.compact {
  min-height: 44px;
  padding-inline: 14px;
  font-size: 14px;
}

.result-panel {
  position: sticky;
  top: 96px;
  scroll-margin-top: 96px;
}

.result-shell {
  padding: 18px;
}

.result-empty {
  min-height: 320px;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 18px;
  text-align: center;
}

.empty-symbol {
  width: 58px;
  height: 58px;
  color: var(--primary);
  background: var(--blue-soft);
  border-radius: var(--radius-lg);
}

.empty-symbol .icon {
  width: 26px;
  height: 26px;
}

.result-empty h3 {
  margin-top: 18px;
  font-size: 20px;
  line-height: 28px;
}

.severity-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 18px;
  background: var(--surface);
  border-radius: var(--radius-lg);
}

#severity-value {
  display: block;
  margin-top: 4px;
  font-family: "Figtree", "Helvetica Neue", sans-serif;
  font-size: 32px;
  font-weight: 800;
  line-height: 40px;
}

#severity-label {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

.risk-band {
  align-self: flex-start;
  max-width: 150px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  padding: 6px 14px;
  color: var(--primary);
  background: var(--blue-soft);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.risk-band[data-tone="critical"] {
  color: #b91c1c;
  background: var(--error-soft);
}

.risk-band[data-tone="high"],
.risk-band[data-tone="elevated"] {
  color: #92400e;
  background: var(--warning-soft);
}

.risk-band[data-tone="low"] {
  color: #047857;
  background: var(--mint-soft);
}

.metrics-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.metrics-list div {
  min-width: 0;
  padding: 12px;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-subtle);
}

.metrics-list strong {
  display: block;
  margin-top: 2px;
  font-family: "Figtree", "Helvetica Neue", sans-serif;
  font-size: 20px;
  line-height: 28px;
}

.result-block {
  margin-top: 24px;
}

.result-block h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  line-height: 28px;
}

.result-block h3 .icon {
  color: var(--primary);
}

.probability-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 46px;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.probability-track,
.driver-track {
  height: 8px;
  overflow: hidden;
  border-radius: 9999px;
  background: var(--surface-strong);
}

.probability-fill,
.driver-fill {
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.driver-item,
.recommendation-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  min-height: 52px;
  margin-top: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
}

.recommendation-item {
  background: var(--mint-soft);
}

.item-icon {
  width: 38px;
  height: 38px;
  color: var(--primary);
  background: var(--blue-soft);
}

.recommendation-item .item-icon {
  color: #059669;
  background: #d1fae5;
}

.driver-item strong,
.recommendation-item strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
}

.driver-item p,
.recommendation-item p {
  margin: 3px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 20px;
}

.driver-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.driver-fill[data-level="high"] {
  background: var(--secondary);
}

.driver-fill[data-level="medium"] {
  background: var(--warning);
}

.driver-fill[data-level="low"] {
  background: var(--tertiary);
}

.model-footnote {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.bottom-nav {
  display: none;
}

.assessment-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  min-width: 320px;
  background: var(--background);
}

.assessment-screen.is-active {
  display: flex;
  flex-direction: column;
}

.assessment-bar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 12px max(24px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--border);
}

.assessment-content {
  flex: 1;
  overflow: auto;
  padding: 30px 24px 108px;
}

.assessment-intro {
  width: min(100%, 980px);
  margin: 0 auto 24px;
}

.assessment-intro p {
  max-width: 660px;
  font-size: 17px;
  line-height: 26px;
}

.assessment-card {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 24px;
  background: var(--surface);
}

.quiz-head {
  margin-bottom: 18px;
}

.quiz-head p {
  margin: 4px 0 0;
  color: var(--text-secondary);
}

.quiz-progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  margin-top: 18px;
  border-radius: 9999px;
  background: #dbeafe;
}

.quiz-progress span {
  display: block;
  width: 20%;
  height: 100%;
  background: var(--primary);
}

.quiz-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.quiz-fields .full {
  grid-column: 1 / -1;
}

.quiz-check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.quiz-check {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9999px;
  color: var(--primary);
  background: var(--blue-soft);
  font-size: 13px;
  font-weight: 700;
}

.quiz-check input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.quiz-check:has(input:checked) {
  color: #fff;
  background: var(--primary);
}

.assessment-actions {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 18px max(24px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

@media (max-width: 1080px) {
  .intro-panel,
  .prediction-layout {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }

  .result-shell {
    background: var(--surface);
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: 76px;
  }

  .top-app-bar {
    min-height: 64px;
    padding: 10px var(--page-gutter);
  }

  .brand-lockup img {
    width: 36px;
    height: 36px;
  }

  .brand-lockup strong {
    font-size: 18px;
  }

  .brand-lockup small,
  .top-actions .secondary-button,
  .top-actions .primary-button {
    display: none;
  }

  .touch-page {
    padding: 18px var(--page-gutter) 30px;
  }

  .intro-panel {
    gap: 18px;
    padding: 18px;
    border-radius: var(--radius-lg);
  }

  .intro-copy h1,
  .assessment-intro h2 {
    font-size: 28px;
    line-height: 36px;
  }

  .intro-copy p,
  .assessment-intro p {
    font-size: 15px;
    line-height: 24px;
  }

  .workspace-card,
  .result-shell,
  .assessment-card {
    border-radius: var(--radius-lg);
  }

  .workspace-head {
    display: grid;
    gap: 14px;
    padding: 18px;
  }

  .segmented-control,
  .mode-option {
    width: 100%;
  }

  .direct-form {
    padding: 0 18px 18px;
  }

  .field-grid,
  .field-grid.short,
  .quiz-fields,
  .metrics-list {
    grid-template-columns: 1fr;
  }

  .form-actions {
    position: sticky;
    bottom: 84px;
    z-index: 10;
    margin: 18px -18px 0;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(16px);
  }

  .form-actions .primary-button,
  .form-actions .secondary-button,
  .assessment-actions .primary-button,
  .assessment-actions .secondary-button {
    flex: 1;
  }

  .severity-card {
    display: grid;
  }

  .risk-band {
    max-width: none;
  }

  .probability-row {
    grid-template-columns: 76px minmax(0, 1fr) 42px;
  }

  .bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 8px var(--page-gutter) calc(8px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(16px);
  }

  .bottom-nav-button {
    min-height: 54px;
    flex-direction: column;
    gap: 3px;
    padding: 6px 8px;
    font-size: 12px;
  }

  .bottom-nav-button .icon {
    width: 20px;
    height: 20px;
  }

  .assessment-bar {
    padding: calc(10px + env(safe-area-inset-top)) var(--page-gutter) 10px;
  }

  .assessment-content {
    padding: 18px var(--page-gutter) 108px;
  }

  .assessment-card {
    padding: 18px;
  }

  .assessment-actions {
    padding: 12px var(--page-gutter) calc(12px + env(safe-area-inset-bottom));
  }

  .assessment-actions .ghost-button {
    display: none;
  }
}

@media (max-width: 430px) {
  .workspace-head h2,
  .result-header h2,
  .assessment-card h3 {
    font-size: 22px;
    line-height: 30px;
  }

  .form-card,
  .result-shell {
    padding: 16px;
  }

  .chip-grid,
  .quiz-check-grid {
    gap: 8px;
  }

  .chip-grid span,
  .quiz-check {
    padding-inline: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
