/* ═══════════════════════════════════════════════════════════
   Next Move — warm "estate-agent board" feel: terracotta brick on
   chalky paper, slate ink, with a calm blue/green/gold for the other
   options' lines. Isolated to #module-nextmove (+ nxm-modal-* sheets
   appended to <body>) — no shared selectors with other modules.
   ═══════════════════════════════════════════════════════════ */
:root {
  --nxm-bg:        #F3EFE8;
  --nxm-card:      #FFFFFF;
  --nxm-ink:       #23303A;
  --nxm-dim:       #6D7780;
  --nxm-line:      #E3DCD0;
  --nxm-field:     #F6F2EC;
  --nxm-brick:     #C4553B;
  --nxm-brick-dark:#A3432C;
  --nxm-brick-soft:#F8E3DB;
  --nxm-up:        #2E7D4F;
  --nxm-down:      #B23A2B;
  --nxm-gap:       #FBE7B5;
  --nxm-s0:        #7A858F;   /* baseline: stay put */
  --nxm-s1:        #C4553B;
  --nxm-s2:        #2F6F9F;
  --nxm-s3:        #3E8A57;
  --nxm-s4:        #C0901F;
  --nxm-shadow:    0 1px 2px rgba(35,48,58,0.05), 0 4px 16px rgba(35,48,58,0.07);
}

/* Scoped to body.dark (not #module-nextmove) so it reaches the modals too. */
body.dark {
  --nxm-bg:        #15191D;
  --nxm-card:      #1F252B;
  --nxm-ink:       #ECE7DF;
  --nxm-dim:       #9AA3AB;
  --nxm-line:      #323A42;
  --nxm-field:     #2A3138;
  --nxm-brick:     #E0765B;
  --nxm-brick-dark:#C8614A;
  --nxm-brick-soft:#3A2722;
  --nxm-up:        #6CC48F;
  --nxm-down:      #F08A7A;
  --nxm-gap:       #4A3D17;
  --nxm-s0:        #8E99A3;
  --nxm-s1:        #E0765B;
  --nxm-s2:        #5FA3D6;
  --nxm-s3:        #6CC48F;
  --nxm-s4:        #E3B84E;
  --nxm-shadow:    0 1px 2px rgba(0,0,0,0.35), 0 4px 16px rgba(0,0,0,0.45);
}

#module-nextmove {
  background: var(--nxm-bg);
  color: var(--nxm-ink);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  border-radius: var(--r-xl);
}

/* ── Header ───────────────────────────────────────────────── */
.nxm-header {
  background: linear-gradient(135deg, #CF6247 0%, #9C3F2A 100%);
  border-radius: var(--r-xl);
  flex-shrink: 0;
  --mod-header-accent: rgba(255,255,255,0.55);
}
.nxm-header .mod-header-title { font-family: var(--font-ui); font-weight: 800; color: #fff; letter-spacing: -0.01em; }
.nxm-header .mod-header-status { color: rgba(255,255,255,0.75); font-weight: 600; }
.nxm-header .home-btn, .nxm-header .settings-btn { color: #fff; opacity: 0.95; }

/* ── Toolbar: tabs + Tough/Central/Kind ─────────────────────── */
.nxm-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: var(--s3) 0 var(--s2);
  flex-wrap: wrap;
}
.nxm-tabs, .nxm-preset {
  display: flex;
  background: var(--nxm-card);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--nxm-shadow);
}
.nxm-tab, .nxm-preset-btn {
  border: none;
  background: none;
  color: var(--nxm-dim);
  font: 700 14px var(--font-ui);
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.nxm-preset-btn { font-size: 12px; padding: 6px 8px; }
.nxm-tab--on { background: var(--nxm-brick); color: #fff; }
.nxm-preset-btn--on { background: var(--nxm-ink); color: var(--nxm-bg); }

.nxm-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--s1) 0 var(--s6);
  -webkit-overflow-scrolling: touch;
}

/* ── Setup banner ─────────────────────────────────────────── */
.nxm-banner {
  display: block;
  width: 100%;
  text-align: left;
  border: 1.5px dashed var(--nxm-brick);
  background: var(--nxm-brick-soft);
  color: var(--nxm-ink);
  border-radius: var(--r-lg);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s3);
  font-family: var(--font-ui);
  cursor: pointer;
}
.nxm-banner b { display: block; font-size: 15px; margin-bottom: 2px; }
.nxm-banner span { display: block; font-size: 13px; color: var(--nxm-dim); line-height: 1.4; }
.nxm-banner i { display: block; font-style: normal; font-weight: 700; font-size: 13px; color: var(--nxm-brick); margin-top: 6px; }

/* ── Option cards ─────────────────────────────────────────── */
.nxm-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--nxm-card);
  color: var(--nxm-ink);
  border: none;
  border-left: 5px solid var(--nxm-c, var(--nxm-brick));
  border-radius: var(--r-lg);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s3);
  box-shadow: var(--nxm-shadow);
  font-family: var(--font-ui);
  cursor: pointer;
}
.nxm-card:active { transform: scale(0.99); }
.nxm-card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.nxm-card-name { font-weight: 800; font-size: 17px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nxm-card-name em { font-style: normal; font-weight: 600; font-size: 11px; color: var(--nxm-dim); text-transform: uppercase; letter-spacing: 0.06em; margin-left: 4px; }
.nxm-card-badges { display: flex; gap: 4px; flex-shrink: 0; }
.nxm-card-place { font-size: 13px; color: var(--nxm-dim); margin: 2px 0 var(--s2); min-height: 1em; }
.nxm-badge {
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: var(--nxm-field); color: var(--nxm-dim);
}
.nxm-badge--buy { background: var(--nxm-brick-soft); color: var(--nxm-brick); }
.nxm-card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.nxm-card-stats span { display: block; font-size: 11px; color: var(--nxm-dim); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.nxm-card-stats b { display: block; font-size: 22px; font-weight: 800; margin: 1px 0; }
.nxm-card-stats i { display: block; font-style: normal; font-size: 12px; color: var(--nxm-dim); font-weight: 600; }
.nxm-card-life { font-size: 13px; color: var(--nxm-dim); margin-top: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--nxm-line); }
.nxm-card-life b { color: var(--nxm-ink); }
.nxm-card-warn {
  margin-top: var(--s2); font-size: 12px; font-weight: 700;
  color: var(--nxm-down); background: var(--nxm-brick-soft);
  border-radius: var(--r-sm); padding: 5px 8px;
}
#module-nextmove .nxm-up, [class*="nxm-modal-"] .nxm-up { color: var(--nxm-up); }
#module-nextmove .nxm-down, [class*="nxm-modal-"] .nxm-down { color: var(--nxm-down); }

.nxm-add-btn {
  width: 100%;
  border: 1.5px dashed var(--nxm-line);
  background: transparent;
  color: var(--nxm-brick);
  font: 700 15px var(--font-ui);
  border-radius: var(--r-lg);
  padding: var(--s4);
  cursor: pointer;
}
.nxm-add-btn span { font-size: 18px; margin-right: 4px; }
.nxm-disclaimer { font-size: 12px; color: var(--nxm-dim); text-align: center; margin: var(--s5) var(--s3) 0; line-height: 1.4; }

/* ── Detail ───────────────────────────────────────────────── */
.nxm-back {
  border: none; background: none; color: var(--nxm-brick);
  font: 700 15px var(--font-ui); padding: var(--s1) 0 var(--s2); cursor: pointer;
}
.nxm-detail-head { margin-bottom: var(--s3); }
.nxm-title-input, .nxm-place-input {
  display: block; width: 100%; min-width: 0;
  border: none; background: transparent; color: var(--nxm-ink);
  font-family: var(--font-ui); padding: 2px 0;
  border-bottom: 1.5px solid transparent;
}
.nxm-title-input { font-size: 24px; font-weight: 800; }
.nxm-place-input { font-size: 15px; color: var(--nxm-dim); margin-bottom: var(--s2); }
.nxm-title-input:focus, .nxm-place-input:focus { outline: none; border-bottom-color: var(--nxm-brick); }
.nxm-seg-row { display: flex; gap: var(--s2); flex-wrap: wrap; }
.nxm-seg { display: inline-flex; background: var(--nxm-field); border-radius: 999px; padding: 3px; }
.nxm-seg button {
  border: none; background: none; color: var(--nxm-dim);
  font: 700 13px var(--font-ui); padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.nxm-seg button.nxm-seg--on { background: var(--nxm-card); color: var(--nxm-ink); box-shadow: var(--nxm-shadow); }

.nxm-hero {
  background: var(--nxm-card);
  border-radius: var(--r-lg);
  padding: var(--s4);
  box-shadow: var(--nxm-shadow);
  margin-bottom: var(--s3);
  border-top: 4px solid var(--nxm-c, var(--nxm-ink));
}
.nxm-hero-main span { display: block; font-size: 12px; font-weight: 700; color: var(--nxm-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.nxm-hero-main b { display: block; font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin: 2px 0; }
.nxm-hero-main i { display: block; font-style: normal; font-size: 13px; font-weight: 600; color: var(--nxm-dim); margin-bottom: var(--s2); line-height: 1.35; }
.nxm-dl { display: grid; grid-template-columns: 1fr auto; gap: 6px var(--s3); margin: var(--s3) 0 0; font-size: 14px; }
.nxm-dl dt { color: var(--nxm-dim); }
.nxm-dl dd { margin: 0; font-weight: 700; text-align: right; }
.nxm-dl dd em { display: block; font-style: normal; font-weight: 500; font-size: 12px; color: var(--nxm-dim); }

.nxm-section {
  background: var(--nxm-card);
  border-radius: var(--r-lg);
  padding: var(--s4);
  box-shadow: var(--nxm-shadow);
  margin-bottom: var(--s3);
}
.nxm-section h3, .nxm-compare-h, .nxm-modal-h {
  font: 800 16px var(--font-ui); margin: 0 0 var(--s1); color: var(--nxm-ink);
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); flex-wrap: wrap;
}
.nxm-section h3 + .nxm-textarea { margin-bottom: var(--s3); }
.nxm-compare-h { margin-top: var(--s4); }
.nxm-modal-h { margin-top: var(--s4); padding-bottom: 4px; border-bottom: 1px solid var(--nxm-line); margin-bottom: var(--s3); }
.nxm-modal-h:first-child { margin-top: 0; }
.nxm-life-sum { font-size: 13px; font-weight: 600; color: var(--nxm-dim); }
.nxm-life-sum b { color: var(--nxm-ink); }
.nxm-help { font-size: 13px; color: var(--nxm-dim); line-height: 1.4; margin: 0 0 var(--s3); }
.nxm-gap-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--nxm-gap); vertical-align: -1px; }

.nxm-field {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: 8px 0; border-top: 1px solid var(--nxm-line);
}
.nxm-field-label { font-size: 14px; font-weight: 600; min-width: 0; flex: 1; }
.nxm-field-label em { display: block; font-style: normal; font-weight: 500; font-size: 12px; color: var(--nxm-dim); }
.nxm-field-input {
  display: flex; align-items: center; gap: 4px;
  background: var(--nxm-field); border-radius: var(--r-md);
  padding: 0 10px; flex-shrink: 0; width: 44%; max-width: 190px;
}
.nxm-field-input input {
  flex: 1; min-width: 0; width: 100%;
  border: none; background: transparent; color: var(--nxm-ink);
  font: 700 16px var(--font-ui); /* 16px stops iOS zoom */
  padding: 9px 0; text-align: right;
}
.nxm-field-input input::placeholder { color: var(--nxm-dim); font-weight: 500; font-size: 13px; opacity: 0.8; }
.nxm-field-input input:focus { outline: none; }
.nxm-field-input:focus-within { box-shadow: 0 0 0 2px var(--nxm-brick); }
.nxm-field-input i { font-style: normal; font-size: 11px; color: var(--nxm-dim); font-weight: 700; white-space: nowrap; }
.nxm-invalid { color: var(--nxm-down) !important; }

.nxm-toggles { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); padding-top: var(--s2); border-top: 1px solid var(--nxm-line); }
.nxm-check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.nxm-check input { width: 18px; height: 18px; accent-color: var(--nxm-brick); }
.nxm-check--wide { padding: var(--s2) 0; }

.nxm-score-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 28px; align-items: center; gap: var(--s2);
  padding: 8px 6px; border-top: 1px solid var(--nxm-line); margin: 0 -6px; border-radius: var(--r-sm);
}
.nxm-score-row--gap { background: var(--nxm-gap); }
.nxm-score-name { font-size: 14px; font-weight: 600; min-width: 0; }
.nxm-score-name em { display: block; font-style: normal; font-size: 11px; font-weight: 600; color: var(--nxm-dim); }
.nxm-score-btns { display: flex; gap: 3px; }
.nxm-score-btns button {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid var(--nxm-line); background: var(--nxm-card); color: var(--nxm-dim);
  font: 700 13px var(--font-ui); cursor: pointer; padding: 0;
}
.nxm-score-btns button.nxm-score--on { background: var(--nxm-brick); border-color: var(--nxm-brick); color: #fff; }
.nxm-score-theirs { text-align: center; font-weight: 800; font-size: 15px; color: var(--nxm-ink); }

.nxm-textarea {
  display: block; width: 100%; min-width: 0; box-sizing: border-box;
  background: var(--nxm-field); color: var(--nxm-ink);
  border: none; border-radius: var(--r-md); padding: var(--s3);
  font: 16px/1.4 var(--font-ui); resize: vertical; margin-top: var(--s1);
}
.nxm-textarea:focus { outline: 2px solid var(--nxm-brick); }
.nxm-links { margin: 0; padding-left: 18px; font-size: 14px; }
.nxm-links li { margin: 4px 0; word-break: break-all; }
.nxm-links a { color: var(--nxm-brick); font-weight: 600; }
.nxm-danger {
  width: 100%; border: none; background: none; color: var(--nxm-down);
  font: 700 14px var(--font-ui); padding: var(--s3); cursor: pointer;
}

/* ── Chart ────────────────────────────────────────────────── */
.nxm-chart { display: block; width: 100%; height: auto; margin-top: var(--s2); overflow: visible; }
.nxm-grid { stroke: var(--nxm-line); stroke-width: 1; }
.nxm-grid--zero { stroke: var(--nxm-dim); stroke-dasharray: 2 3; }
.nxm-axis { fill: var(--nxm-dim); font: 600 9.5px var(--font-ui); }
.nxm-line { stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.nxm-line--dashed { stroke-dasharray: 5 4; stroke-width: 2; }
.nxm-legend { display: flex; flex-wrap: wrap; gap: 4px var(--s3); font-size: 12px; font-weight: 600; color: var(--nxm-dim); margin-top: var(--s1); }
.nxm-legend span { display: inline-flex; align-items: center; gap: 5px; }
.nxm-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.nxm-legend i.nxm-legend-dash { height: 0; background: none !important; border-top: 2px dashed var(--nxm-s0); }

/* ── Compare ──────────────────────────────────────────────── */
.nxm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s3); }
.nxm-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--nxm-line); background: transparent; color: var(--nxm-dim);
  font: 700 13px var(--font-ui); padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.nxm-chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--nxm-c); opacity: 0.4; }
.nxm-chip--on { background: var(--nxm-card); color: var(--nxm-ink); border-color: var(--nxm-c); box-shadow: var(--nxm-shadow); }
.nxm-chip--on i { opacity: 1; }

.nxm-table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--nxm-card); border-radius: var(--r-lg); box-shadow: var(--nxm-shadow);
}
.nxm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.nxm-table th, .nxm-table td { padding: 8px 10px; text-align: right; border-top: 1px solid var(--nxm-line); white-space: nowrap; }
.nxm-table thead th { border-top: none; font-weight: 800; color: var(--nxm-ink); vertical-align: bottom; white-space: normal; min-width: 72px; }
.nxm-table thead th i { display: block; width: 100%; height: 3px; border-radius: 2px; background: var(--nxm-c); margin-bottom: 5px; }
.nxm-table tbody th { text-align: left; font-weight: 600; color: var(--nxm-dim); white-space: normal; min-width: 96px; }
.nxm-table td b { font-size: 15px; }
.nxm-table--grid td { font-weight: 700; }
.nxm-table td.nxm-gap { background: var(--nxm-gap); }

/* ── Toast ────────────────────────────────────────────────── */
.nxm-toast {
  position: absolute; left: 50%; bottom: 18px; transform: translate(-50%, 20px);
  background: var(--nxm-ink); color: var(--nxm-bg);
  font: 600 14px var(--font-ui); padding: 10px 16px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100% - 32px); text-align: center;
}
.nxm-toast--show { opacity: 1; transform: translate(-50%, 0); }

/* ── Modals (appended to <body>) ──────────────────────────── */
.nxm-modal-sheet { background: var(--nxm-card); color: var(--nxm-ink); max-height: 88vh; }
body.dark .nxm-modal-sheet { background: var(--nxm-card); }
.nxm-modal-sheet::before { background: var(--nxm-line); }
.nxm-modal-sheet .modal-sheet-title { font-family: var(--font-ui); font-weight: 800; color: var(--nxm-ink); }
.nxm-modal-sheet .modal-close-btn { background: var(--nxm-field); color: var(--nxm-dim); }
.nxm-modal-sheet .modal-confirm-btn,
body.dark .nxm-modal-sheet .modal-confirm-btn {
  background: var(--nxm-brick); color: #fff;
  font-family: var(--font-ui); font-weight: 700; font-size: 16px; margin-top: var(--s3);
}
.nxm-modal-sheet .modal-confirm-btn:active { background: var(--nxm-brick-dark); }
.nxm-modal-sheet .modal-confirm-btn:disabled { opacity: 0.6; }
.nxm-modal-body { font-family: var(--font-ui); padding-top: var(--s2); overflow-y: auto; }
.nxm-mfield { display: block; margin-bottom: var(--s4); }
.nxm-mfield > span { display: block; font-size: 13px; font-weight: 700; margin-bottom: var(--s2); }
.nxm-mfield input {
  width: 100%; min-width: 0; box-sizing: border-box;
  background: var(--nxm-field); color: var(--nxm-ink);
  border: 1.5px solid transparent; border-radius: var(--r-md);
  padding: var(--s3); font: 16px var(--font-ui);
}
.nxm-mfield input:focus { outline: none; border-color: var(--nxm-brick); }

.nxm-crit-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 32px; gap: 6px; margin-bottom: 6px; }
.nxm-crit-name, .nxm-crit-weight {
  min-width: 0; background: var(--nxm-field); color: var(--nxm-ink);
  border: none; border-radius: var(--r-md); padding: 9px 10px; font: 16px var(--font-ui);
}
.nxm-crit-weight { font-size: 13px; font-weight: 600; }
.nxm-crit-del { border: none; background: none; color: var(--nxm-dim); font-size: 22px; cursor: pointer; }
.nxm-add-row {
  border: none; background: none; color: var(--nxm-brick);
  font: 700 14px var(--font-ui); padding: var(--s2) 0; cursor: pointer;
}
