:root {
  --bg: #0f1724;
  --bg_soft: #151f30;
  --text: #eef4fb;
  --muted: #9fb0c7;
  --border: #2a3a52;
  /* Warm accent (public-facing) */
  --accent: #E59A62;
  --accent_dark: #C67F4B;
  --accent_glow: rgba(229, 154, 98, 0.22);
  --accent_outline: rgba(229, 154, 98, 0.68);
  --ok: #5fd4a4;
  --bad: #ff8a8a;
  --card_bg: var(--bg_soft);
  --tap: 48px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}

.app_shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app_header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: 16px 20px 14px;
  display: grid;
  gap: 14px;
}

.brand_link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0.02em;
  font-size: 15px;
}

.progress_steps {
  display: flex;
  gap: 6px;
}

.progress_step {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.progress_step.done {
  background: var(--accent);
  opacity: 0.55;
}

.progress_step.current {
  background: var(--accent);
}

.app_main {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 20px 32px;
}

.question_list {
  display: grid;
  gap: 28px;
}

.q_block {
  display: grid;
  gap: 10px;
}

.q_label {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.35;
}

.req_mark {
  color: var(--accent);
}

.q_input {
  width: 100%;
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg_soft);
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px;
}

.q_textarea {
  width: 100%;
  min-height: 160px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg_soft);
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px;
  line-height: 1.55;
  resize: vertical;
  font-family: inherit;
}

.q_input_number,
.q_select {
  width: 100%;
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg_soft);
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.q_select {
  padding-right: 40px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239fb0c7' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.q_input_number:focus,
.q_select:focus,
.q_textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent_glow);
  outline: none;
}

.q_range:focus,
.q_input:focus:not(.q_input_number),
.check_chip input:focus,
.check_tile input:focus {
  outline: 2px solid var(--accent_outline);
  outline-offset: 2px;
}

.q_hint {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.range_wrap {
  display: grid;
  gap: 8px;
}

.q_range {
  width: 100%;
  accent-color: var(--accent);
}

.range_marks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.range_value {
  font-size: 14px;
  color: var(--muted);
}

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

.checkbox_group.checkbox_group_grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.check_chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg_soft);
  cursor: pointer;
  user-select: none;
  font-size: 14px;
}

.check_tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 36px;
  padding: 6px 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg_soft);
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  line-height: 1.15;
  text-align: center;
  hyphens: auto;
  overflow-wrap: anywhere;
}

.check_chip input,
.check_tile input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.check_chip:has(input:checked),
.check_tile:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent_glow);
}

.check_chip.disabled,
.check_tile.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.nav_bar {
  display: flex;
  gap: 10px;
  margin-top: 36px;
  padding-top: 20px;
}

.nav_spacer {
  flex: 1;
}

.btn {
  min-height: var(--tap);
  padding: 12px 18px;
  border-radius: 12px;
  border: 0;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn_primary {
  flex: 1;
  background: linear-gradient(180deg, var(--accent), var(--accent_dark));
  color: #1a1208;
}

.btn_secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  min-width: 96px;
}

.notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.notice.ok {
  border-color: rgba(95, 212, 164, 0.45);
  background: rgba(95, 212, 164, 0.1);
  color: #c8f5e3;
}

.notice.bad {
  border-color: rgba(255, 138, 138, 0.45);
  background: rgba(255, 138, 138, 0.1);
  color: #ffd0d0;
}

.landing_intro {
  margin-bottom: 28px;
}

.landing_intro h1 {
  margin: 0 0 10px;
  font-size: 28px;
}

.landing_intro p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.landing_section {
  margin-bottom: 28px;
}

.landing_section h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.landing_section p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
}

.landing_section.disabled {
  opacity: 0.5;
}

.menu_grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.menu_card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card_bg);
  padding: 14px;
}

.menu_card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--text);
}

.menu_card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.menu_actions {
  display: grid;
  gap: 10px;
}

.data_pre {
  margin: 14px 0 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card_bg);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.matches_title {
  margin: 0 0 10px;
  font-size: 18px;
}

.matches_list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.match_card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card_bg);
  padding: 14px;
}

.match_head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.match_id {
  font-size: 13px;
  color: var(--muted);
}

.match_score {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.match_sub {
  margin-top: 8px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.match_tags {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.match_actions {
  margin-top: 12px;
}

.match_form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.match_form .btn_primary {
  flex: 1;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.tag_ok {
  border-color: var(--accent_outline);
  background: var(--accent_glow);
}

.tag_warn {
  border-color: rgba(255, 138, 138, 0.45);
  background: rgba(255, 138, 138, 0.1);
}

.tag_block {
  border-color: rgba(255, 90, 90, 0.85);
  background: rgba(255, 90, 90, 0.22);
  color: #ffd4d4;
  font-weight: 600;
}

.match_near {
  border-color: rgba(255, 138, 138, 0.35);
}

.match_near_label {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ff9a9a;
  margin-bottom: 6px;
}

.match_blockers {
  margin-top: 10px;
}

.weight_block {
  margin-top: 4px;
  padding-top: 2px;
}

.weight_label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.check_row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 14px;
}

.check_row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.done_screen_actions {
  margin-top: 28px;
}

.done_screen_register {
  margin-top: 28px;
  padding: 18px 20px;
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg_soft);
}

.done_screen_register_title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.done_screen_register_body {
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--muted);
}

.done_screen_register_actions {
  display: grid;
  gap: 10px;
}

.guest_register_hint {
  margin-bottom: 4px;
}

.app_shell_done,
.app_shell_welcome {
  justify-content: center;
}

.welcome_screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 24px;
}

.welcome_content {
  max-width: 520px;
  text-align: center;
}

.welcome_title {
  margin: 0 0 18px;
  font-size: clamp(1.65rem, 4vw, 2.1rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.welcome_brand {
  margin: 0 0 20px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.welcome_lead {
  margin: 0 0 14px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--muted);
}

.welcome_body {
  margin: 0 0 14px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--muted);
}

.welcome_question {
  margin: 22px 0 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
}

.welcome_actions {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.welcome_actions .btn_primary {
  width: 100%;
}

.done_screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 24px;
  text-align: center;
}

.done_screen_text {
  margin: 0;
  max-width: 420px;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
}

.portrait_wrap {
  display: grid;
  gap: 10px;
}

.portrait_sublabel {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.portrait_file_input {
  width: 100%;
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--bg_soft);
  color: var(--text);
  padding: 12px 14px;
  font-size: 15px;
}

.portrait_preview_wrap {
  margin-top: 4px;
}

.portrait_preview {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg_soft);
}

@media (min-width: 720px) {
  .app_main {
    padding: 12px 24px 48px;
  }

  .app_header {
    padding-left: 24px;
    padding-right: 24px;
  }
}

/* Utility classes (avoid inline styles in PHP/HTML views) */
.u_mb_16 {
  margin-bottom: 16px;
}

.u_mt_12 {
  margin-top: 12px;
}

.u_title_sm {
  font-size: 1rem;
  margin: 12px 0 6px;
}

.u_title_md {
  font-size: 1.05rem;
}

.match_score_inline {
  display: inline-block;
  margin-right: 12px;
}

.match_tags_center {
  justify-content: center;
  margin-top: 10px;
}

.notice_mt {
  margin: 12px 0 0;
}

.pre_wrap {
  white-space: pre-wrap;
}

.access_page {
  font-family: system-ui, sans-serif;
  padding: 24px;
  line-height: 1.5;
}

.export_failed_page {
  font-family: system-ui, sans-serif;
  padding: 24px;
}

/* Match cards: two portraits side by side */
.match_pair_card > .match_compare_row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}

.match_pair_card .match_compare_side {
  flex: 1 1 0;
  min-width: 0;
  max-width: calc(50% - 18px);
}

.match_pair_card .match_compare_label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin-bottom: 8px;
}

.match_pair_card .match_compare_mid {
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  color: #7eb8ff;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.match_pair_card .match_person_portrait {
  flex: none;
  max-width: 100%;
  width: 100%;
}

.match_person_iq_line {
  margin-top: 4px;
  font-size: 0.86rem;
  color: #9ec5ff;
  line-height: 1.35;
}

.match_pair_card {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
}

.match_pair_card > .match_pair_meta {
  width: 100%;
  margin-top: 12px;
  flex: 0 0 auto;
}

/* Near-match card accent */
.match_pair_card.match_near {
  border-color: rgba(255, 138, 138, 0.35);
}
