/*
 * Raj Bhu Calculator
 * Land-records portal style: deep navy header and footer, light grey page,
 * white cards, slate menu buttons and a sky-blue accent. Its own logo and
 * name; not a government site.
 */
:root {
  --indigo: #002E5B;     /* navy: header, primary buttons, table heads */
  --indigo-2: #0B4A85;
  --slate: #4A5A60;      /* menu buttons */
  --slate-2: #3B494E;
  --paper: #F5F5F5;
  --sheet: #FFFFFF;
  --text: #1E2B36;
  --muted: #5B6B73;
  --rule: #DEE2E6;
  --rule-strong: #A7B2B8;
  --mustard: #0A8FC4;    /* accent (sky blue); name kept so every rule follows */
  --mustard-ink: #05628A;
  --field: #2E7D46;
  --madder: #B3372E;
  --input-bg: #FFFFFF;
  --focus: #0A8FC4;

  /* Devanagari faces follow the Latin ones so Hindi text picks them up per glyph. */
  --display: "Palatino Linotype", "Book Antiqua", Palatino, "URW Palladio L", Georgia, "Nirmala UI", "Noto Serif Devanagari", "Kohinoor Devanagari", serif;
  --body: "Segoe UI", system-ui, -apple-system, Roboto, "Nirmala UI", "Noto Sans Devanagari", "Kohinoor Devanagari", "Noto Sans", sans-serif;

  --r-sm: 6px;
  --r-md: 10px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --indigo: #002448;
  --slate: #2A3F52;
  --slate-2: #34506A;
  --paper: #06182B;
  --sheet: #0C2540;
  --text: #E4ECF3;
  --muted: #9EB0C0;
  --rule: #1C3A5A;
  --rule-strong: #38597C;
  --mustard: #4FBDEB;
  --mustard-ink: #4FBDEB;
  --focus: #4FBDEB;
  --field: #6FC28A;
  --madder: #F08A80;
  --input-bg: #081D33;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 16px/1.5 var(--body);
}
[hidden] { display: none !important; }
code { font-family: Consolas, "Courier New", monospace; font-size: .92em; background: var(--paper); padding: 1px 5px; border-radius: 4px; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--indigo);
  color: #F5F6FB;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 40px);
  border-bottom: 4px solid var(--mustard);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 46px; height: 46px; flex: none; }
.brand-name { font-family: var(--display); font-size: 24px; font-weight: 700; letter-spacing: .2px; line-height: 1.1; }
.brand-sub { font-size: 13px; opacity: .8; }
/* Breadcrumb strip under the header, like a records portal's menu bar. */
.crumbs {
  background: var(--sheet); border-bottom: 1px solid var(--rule);
  padding: 9px clamp(16px, 4vw, 40px); font-size: 14px; color: var(--muted);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.crumbs b { font-family: var(--display); font-size: 16px; color: var(--indigo); font-weight: 700; }
:root[data-theme="dark"] .crumbs b { color: var(--mustard); }
.crumbs .sep { opacity: .6; }
/* Footer: navy band with the unofficial-tool notice. */
.site-footer {
  background: var(--indigo); color: #E8EEF4; font-size: 13px; line-height: 1.6;
  padding: 20px clamp(16px, 4vw, 40px); border-top: 4px solid var(--mustard);
}
.site-footer .inner { max-width: 1080px; margin: 0 auto; display: grid; gap: 6px; }
.site-footer b { color: #fff; }
.site-footer .disclaimer { opacity: .85; }
.bigha-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.28);
  color: inherit; font: inherit; font-size: 14px;
  border-radius: 999px; padding: 7px 14px; cursor: pointer;
  white-space: nowrap; flex: none;
}
@media (max-width: 760px) { .brand-sub { display: none; } }
.bigha-chip:hover { background: rgba(255,255,255,.16); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.lang-btn {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--mustard);
  background: none; border: 1px solid transparent; border-radius: 999px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.lang-btn:hover { border-color: rgba(255,255,255,.28); }
/* Typing switch: अ | A, the active side filled. */
.type-btn {
  display: inline-flex; padding: 2px; gap: 2px; cursor: pointer; flex: none;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.28); border-radius: 999px;
  font: inherit; color: inherit;
}
.type-btn span { min-width: 28px; height: 28px; display: grid; place-items: center; border-radius: 999px; font-weight: 700; font-size: 15px; opacity: .7; }
.type-btn .t-hi { font-size: 17px; }
.type-btn[aria-pressed="true"] .t-hi, .type-btn[aria-pressed="false"] .t-en { background: var(--mustard); color: #fff; opacity: 1; }
:root[data-theme="dark"] .type-btn[aria-pressed="true"] .t-hi, :root[data-theme="dark"] .type-btn[aria-pressed="false"] .t-en { color: #06182B; }
.type-btn:hover { border-color: rgba(255,255,255,.5); }
.bigha-chip-label { opacity: .75; }
.bigha-chip-value { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 28px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px clamp(12px, 3vw, 32px) 64px;
}
/* Menu: a column of slate block buttons; the open one turns navy with an accent edge. */
.tools { display: flex; flex-direction: column; gap: 7px; position: sticky; top: 20px; align-self: start; }
.tool {
  position: relative;
  text-align: left; font: inherit; font-weight: 600; font-size: 15px;
  color: #fff; background: var(--slate); border: 0; cursor: pointer;
  padding: 11px 14px 11px 16px; border-radius: 5px;
  border-left: 4px solid transparent;
  box-shadow: 0 1px 2px rgba(0, 30, 60, .15);
}
.tool span { display: block; font-weight: 400; font-size: 13px; color: rgba(255, 255, 255, .78); }
.tool:hover { background: var(--slate-2); }
.tool.active { background: var(--indigo); border-left-color: var(--mustard); }
:root[data-theme="dark"] .tool.active { background: var(--indigo-2); }
.count {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  min-width: 22px; padding: 1px 7px; border-radius: 999px;
  background: var(--indigo); color: #fff; font-size: 12px; text-align: center; font-style: normal;
}
.tool b { font-weight: 600; }
:lang(hi) .help, :lang(hi) .note { line-height: 1.65; }
.tool .count { background: rgba(255, 255, 255, .22); }
.tool.active .count { background: var(--mustard); }
:root[data-theme="dark"] .count { background: var(--mustard); color: #06182B; }

.sheet {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 5px;
  box-shadow: 0 1px 3px rgba(0, 30, 60, .08);
  padding: clamp(18px, 4vw, 36px);
  min-width: 0;
}
.panel { display: none; }
.panel.active { display: block; }
.panel h1 {
  font-family: var(--display); font-size: 28px; line-height: 1.2; margin: 0 0 8px; font-weight: 700;
  color: var(--indigo); padding-bottom: 8px; border-bottom: 2px solid var(--rule);
}
:root[data-theme="dark"] .panel h1 { color: var(--text); }
.help { color: var(--muted); margin: 0 0 22px; max-width: 62ch; }
.note { color: var(--muted); font-size: 13.5px; margin: 6px 0 0; max-width: 62ch; }
h2.label { font-size: 15px; font-weight: 700; margin: 22px 0 8px; }

/* ---------- form controls ---------- */
label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
.opt { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="tel"], select {
  width: 100%;
  font: inherit; font-size: 17px;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  padding: 11px 12px;
  font-variant-numeric: tabular-nums;
}
select { padding-right: 32px; }
input[type="text"]::placeholder, input[type="tel"]::placeholder { color: var(--muted); opacity: .7; }
input.invalid { border-color: var(--madder); box-shadow: 0 0 0 1px var(--madder); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
input[type="text"]:focus-visible, input[type="tel"]:focus-visible, select:focus-visible { outline-offset: 0; }

.btn {
  font: inherit; font-weight: 600; font-size: 15px;
  background: var(--indigo); color: #fff;
  border: 1px solid var(--indigo); border-radius: var(--r-sm);
  padding: 10px 16px; cursor: pointer; white-space: nowrap;
}
:root[data-theme="dark"] .btn { background: var(--mustard); border-color: var(--mustard); color: #06182B; }
.btn:hover { background: var(--indigo-2); }
.btn.ghost,
:root[data-theme="dark"] .btn.ghost { background: transparent; color: var(--text); border-color: var(--rule-strong); }
.btn.ghost:hover,
:root[data-theme="dark"] .btn.ghost:hover { background: var(--paper); }
:root[data-theme="dark"] .btn.danger { color: var(--madder); }
.btn.danger { color: var(--madder); }
.btn.small { padding: 6px 11px; font-size: 14px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { flex: 1; }
.suffix { color: var(--muted); }
.error { color: var(--madder); font-size: 14px; margin: 8px 0 0; }

.segmented {
  display: inline-flex; flex-wrap: wrap;
  border: 1px solid var(--rule-strong); border-radius: var(--r-sm); overflow: hidden;
}
.segmented label { margin: 0; font-weight: 500; font-size: 14.5px; cursor: pointer; position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { padding: 8px 14px; border-right: 1px solid var(--rule-strong); }
.segmented label:last-child { border-right: 0; }
.segmented label:has(input:checked) { background: var(--indigo); color: #fff; }
:root[data-theme="dark"] .segmented label:has(input:checked) { background: var(--mustard); color: #1B2240; }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }

/* area input component */
.area-input .unit-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 10px; }
.area-input .bbb { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; }
.area-input .bbb label { margin-top: 0; font-weight: 600; font-size: 13px; color: var(--muted); }
.area-input .bbb label small { font-weight: 400; font-size: 12px; margin-left: 5px; opacity: .85; }
.area-input .unit-select { margin-bottom: 10px; }
.area-input .unit-select label { margin-top: 0; }

/* rows (add/subtract, shares) */
.rows { display: flex; flex-direction: column; }
.row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 36px;
  gap: 12px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}
.row:first-child { border-top: 1px solid var(--rule); }
.sign {
  width: 44px; height: 44px; margin-top: 2px;
  font: 700 22px/1 var(--display);
  border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--field); color: var(--field); background: transparent;
}
.sign.minus { border-color: var(--madder); color: var(--madder); }
.remove {
  width: 36px; height: 36px; margin-top: 4px;
  border: 0; background: none; color: var(--muted); cursor: pointer;
  border-radius: var(--r-sm); font-size: 20px; line-height: 1;
}
.remove:hover { background: var(--paper); color: var(--madder); }
.row-eq { font-size: 13px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.row-actions { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.share-row { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 36px; }
.share-row label { margin-top: 0; font-weight: 500; font-size: 13px; color: var(--muted); }
.share-equal { max-width: 220px; }

details.quick { margin-top: 20px; border-top: 1px dashed var(--rule-strong); padding-top: 10px; }
details.quick summary { cursor: pointer; font-weight: 600; color: var(--indigo-2); padding: 4px 0; }
:root[data-theme="dark"] details.quick summary { color: var(--mustard); }
details.quick .help { margin: 8px 0 10px; }

/* plot */
.plot-grid { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 24px; align-items: start; }
.plot-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.plot-figure { margin: 14px 0 0; padding: 10px; border: 1px dashed var(--rule-strong); border-radius: var(--r-md); }
.plot-figure svg { display: block; width: 100%; height: auto; }
.plot-figure .shape { fill: color-mix(in srgb, var(--mustard) 18%, transparent); stroke: var(--text); stroke-width: 2; }
.plot-figure .diag { stroke: var(--madder); stroke-width: 2; stroke-dasharray: 6 5; }
.plot-figure text { font: 600 15px var(--body); fill: var(--text); }
.plot-figure text.d { fill: var(--madder); }

/* ---------- result: the register ---------- */
.result { margin-top: 28px; }
.result:empty { display: none; }
.result-empty { color: var(--muted); border: 1px dashed var(--rule-strong); border-radius: var(--r-md); padding: 18px; margin: 0; }
.result-error { color: var(--madder); border: 1px solid var(--madder); border-radius: var(--r-md); padding: 14px 18px; margin: 0; }

.register {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 3px solid var(--indigo);
  border-bottom: 1px solid var(--rule-strong);
}
:root[data-theme="dark"] .register { border-top-color: var(--mustard); }
.register > div { padding: 14px 16px 12px; border-right: 1px solid var(--rule); }
.register > div:last-child { border-right: 0; }
.register .num {
  display: block;
  font-family: var(--display);
  font-size: clamp(34px, 6vw, 52px);
  font-weight: 700;
  line-height: 1.05;
  font-variant-numeric: lining-nums tabular-nums;
  overflow-wrap: anywhere;
}
.register .unit { display: block; font-weight: 600; font-size: 15px; margin-top: 4px; }
.register .unit small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
.register .num::after {
  content: ""; display: block; width: 28px; height: 3px; background: var(--mustard); margin-top: 8px;
}
.register.negative .num { color: var(--madder); }
.register-caption { font-size: 13.5px; color: var(--muted); margin: 8px 0 0; }

.ledger { width: 100%; border-collapse: collapse; margin-top: 18px; font-variant-numeric: tabular-nums; }
.ledger th, .ledger td { text-align: left; padding: 9px 4px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ledger th { font-weight: 500; color: var(--muted); width: 45%; }
.ledger td { font-weight: 600; text-align: right; }
.ledger td button { all: unset; cursor: pointer; border-radius: 4px; padding: 0 3px; }
.ledger td button:hover { background: var(--paper); }
.ledger td button:focus-visible { outline: 3px solid var(--focus); }
.ledger.people th, .ledger.people td { text-align: left; }
.ledger.people thead th {
  font-size: 13px; width: auto; border-bottom: 0;
  background: var(--indigo); color: #fff; font-weight: 600; padding: 9px 8px;
}
.ledger.people tbody tr:nth-child(even) td, .ledger.people tbody tr:nth-child(even) th { background: color-mix(in srgb, var(--paper) 70%, var(--sheet)); }
.ledger.people td, .ledger.people tbody th { padding-left: 8px; padding-right: 8px; }
.ledger.people td.num-col, .ledger.people th.num-col { text-align: right; white-space: nowrap; padding-left: 12px; }
.table-scroll { overflow-x: auto; margin-top: 18px; }
.table-scroll .ledger { margin-top: 0; min-width: 480px; }
.ledger.people tfoot td, .ledger.people tfoot th { border-bottom: 0; border-top: 2px solid var(--rule-strong); }

.big-money {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(34px, 6vw, 50px); line-height: 1.1;
  border-top: 3px solid var(--indigo); padding-top: 14px;
  font-variant-numeric: lining-nums;
}
:root[data-theme="dark"] .big-money { border-top-color: var(--mustard); }
.big-money small { display: block; font-family: var(--body); font-size: 15px; font-weight: 500; color: var(--muted); margin-top: 4px; }

.status { margin: 14px 0 0; padding: 10px 14px; border-radius: var(--r-sm); font-size: 14.5px; }
.status.ok { background: color-mix(in srgb, var(--field) 12%, transparent); color: var(--field); }
.status.warn { background: color-mix(in srgb, var(--madder) 10%, transparent); color: var(--madder); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

/* saved */
.saved-list { list-style: none; padding: 0; margin: 0; }
.saved-list li { border-bottom: 1px solid var(--rule); padding: 14px 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; }
.saved-list li:first-child { border-top: 1px solid var(--rule); }
.saved-tool { font-size: 13px; color: var(--muted); }
.saved-title { font-weight: 600; }
.saved-body { white-space: pre-line; font-size: 14px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.saved-actions { display: flex; gap: 6px; align-items: start; }

/* my land */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.land-top-actions { margin-top: 0; }
.file-btn { position: relative; display: inline-flex; align-items: center; margin: 0; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-btn:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
#landPdfError { margin-top: 12px; }
.land-list { list-style: none; padding: 0; margin: 20px 0 0; }
.land-list li { border-bottom: 1px solid var(--rule); padding: 16px 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; }
.land-list li:first-child { border-top: 3px solid var(--indigo); }
:root[data-theme="dark"] .land-list li:first-child { border-top-color: var(--mustard); }
.land-list li.result-empty { display: block; border: 1px dashed var(--rule-strong); border-radius: var(--r-md); padding: 18px; }
.land-title { font-family: var(--display); font-weight: 700; font-size: 20px; }
.land-meta { color: var(--muted); font-size: 14px; }
.land-area { margin-top: 4px; font-variant-numeric: tabular-nums; }
.land-list .saved-actions { flex-wrap: wrap; justify-content: flex-end; max-width: 260px; }


.land-editor .editor-title { font-family: var(--display); font-size: 24px; margin: 0 0 4px; }
.import-banner { margin: 10px 0 4px; }
.khasra-unit { max-width: 260px; }
.khasra-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.khasra-table th { text-align: left; font-size: 13px; font-weight: 600; color: #fff; background: var(--indigo); padding: 7px 8px; }
.khasra-table td:first-child { padding-left: 0; }
/* Boxed form sections with a navy title bar, like a records-portal form. */
.records-box { border: 1px solid var(--rule); border-radius: 5px; padding: 0 14px 14px; margin-top: 18px; background: var(--sheet); }
.records-box .box-head {
  margin: 0 -14px 4px; padding: 8px 14px; border-radius: 4px 4px 0 0;
  background: var(--indigo); color: #fff; font-weight: 600; font-size: 15px;
}
:root[data-theme="dark"] .records-box .box-head, :root[data-theme="dark"] .khasra-table th,
:root[data-theme="dark"] .ledger.people thead th { background: var(--slate-2); }
.khasra-table td { padding: 4px 8px 4px 0; }
.khasra-table td:last-child, .khasra-table th:last-child { width: 40px; padding-right: 0; }
.khasra-table .remove { margin-top: 0; }
.share-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.share-chips span { flex-basis: 100%; }
.share-chips [aria-pressed="true"] { border-color: var(--mustard); box-shadow: inset 0 0 0 1px var(--mustard); }
.import-extra { margin: 6px 0 4px; }
.owners-table { min-width: 560px; }
.owners-table td, .owners-table th { padding-top: 7px; padding-bottom: 7px; }
.owner-pick {
  font: inherit; font-weight: 600; color: inherit; text-align: left;
  background: none; border: 0; padding: 2px 0; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 4px;
}
.owners-table tr.picked td { background: color-mix(in srgb, var(--mustard) 16%, transparent); }
.owners-table tr.picked .owner-pick { text-decoration: none; }
.share-head { font-size: 16px; margin: 24px 0 8px; }
.pdf-text { white-space: pre-wrap; font-size: 12.5px; max-height: 260px; overflow: auto; background: var(--paper); padding: 10px; border-radius: var(--r-sm); }
.editor-actions { gap: 10px; border-top: 1px solid var(--rule); padding-top: 18px; }
@media (max-width: 520px) {
  .land-list li { grid-template-columns: 1fr; }
  .land-list .saved-actions { justify-content: flex-start; max-width: none; }
}

/* family tree (वंशवृक्ष) */
.tree-view .editor-title { margin-top: 14px; }
.tree { list-style: none; padding: 0; margin: 18px 0 0; }
.tree ul { list-style: none; margin: 0; padding-left: 26px; position: relative; }
.tree ul > li { position: relative; }
/* vertical line from parent down, and a tick into each child */
.tree ul > li::before {
  content: ""; position: absolute; left: -16px; top: 0; bottom: 0;
  border-left: 2px solid var(--rule-strong);
}
.tree ul > li:last-child::before { bottom: auto; height: 26px; }
.tree ul > li::after {
  content: ""; position: absolute; left: -16px; top: 26px; width: 12px;
  border-top: 2px solid var(--rule-strong);
}
.tree > li { margin-bottom: 14px; }
.tree > li > .node { border-top: 3px solid var(--indigo); }
:root[data-theme="dark"] .tree > li > .node { border-top-color: var(--mustard); }
.tree li.result-empty { display: block; border: 1px dashed var(--rule-strong); border-radius: var(--r-md); padding: 18px; }
.node {
  border: 1px solid var(--rule); border-radius: var(--r-sm);
  padding: 9px 12px; margin: 8px 0; background: var(--sheet);
}
.node.deceased { background: var(--paper); }
.node-main { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.node-name {
  font: inherit; font-weight: 700; font-size: 16.5px; color: inherit;
  background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
  text-decoration: underline dotted; text-underline-offset: 4px;
}
.node.deceased .node-name { font-weight: 600; color: var(--muted); }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--rule-strong); color: var(--muted); }
.tag.nakal { border-color: var(--field); color: var(--field); }
.tag.bad { border-color: var(--madder); color: var(--madder); }
.node-area { font-size: 14.5px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.node-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.node-actions .btn.small { padding: 4px 9px; font-size: 13px; }
#treeStatus { margin-top: 14px; }
#treeActions .actions { margin-top: 20px; }

/* family chart: pan / zoom canvas with draggable cards */
.view-switch { display: inline-flex; margin-left: auto; border: 1px solid var(--rule-strong); border-radius: 999px; overflow: hidden; }
.view-switch button { border: 0; background: transparent; color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; padding: 6px 14px; cursor: pointer; }
.view-switch button[aria-pressed="true"] { background: var(--indigo); color: #fff; }
:root[data-theme="dark"] .view-switch button[aria-pressed="true"] { background: var(--mustard); color: #1B2240; }
.view-switch button:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.tree-view .row-actions { align-items: center; }

.tree-stage {
  --male: #4F8FC0; --female: #C06BB8; --none: var(--mustard); --buyer: #2F8F7E; --share: #C2621F;
  position: relative; overflow: hidden; margin-top: 14px;
  height: min(72vh, 640px); min-height: 380px;
  border: 1px solid var(--rule); border-radius: var(--r-md);
  background-color: var(--paper);
  background-image: radial-gradient(circle, var(--rule-strong) 1px, transparent 1.2px);
  background-size: 22px 22px;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
}
.tree-stage.dragging, .tree-stage:active { cursor: grabbing; }
.tree-stage[hidden] { display: none; }
.tree-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.tree-links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.tree-links .lk { fill: none; stroke: var(--rule-strong); stroke-width: 1.6; }
:root[data-theme="dark"] .tree-links .lk:not(.sale):not(.share) { stroke: #6A75AE; }
.tree-links .lk.spouse { stroke-dasharray: 0; }
.tree-links .lk.sale { stroke: var(--buyer); stroke-dasharray: 6 5; }
.tree-links .pill { pointer-events: auto; cursor: pointer; }
.tree-links .pill rect { fill: var(--sheet); stroke: var(--rule-strong); stroke-width: 1.3; }
.tree-links .pill text { fill: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-anchor: middle; text-transform: uppercase; }
.tree-links .pill.sale rect { stroke: var(--buyer); }
.tree-links .pill.sale text { fill: var(--buyer); }
.tree-links .lk.share { stroke: var(--share); stroke-width: 1.8; stroke-dasharray: 3 4; stroke-linecap: round; pointer-events: stroke; }
.tree-links .sh-head { fill: var(--share); }
.tree-links .pill.share { pointer-events: none; }
.tree-links .pill.share rect { stroke: var(--share); }
.tree-links .pill.share text { fill: var(--share); letter-spacing: .02em; }
.tree-links .pill:hover rect { stroke: var(--mustard); stroke-width: 2; }
.fcard.g-b { border-top-color: var(--buyer); border-style: dashed; border-top-style: solid; }
.fcard.g-b .fc-avatar { background: var(--buyer); }
.tag.sold { border-color: #2F8F7E; color: #2F8F7E; }
:root[data-theme="dark"] .tag.sold { border-color: #5CC4B0; color: #5CC4B0; }
.tag.share { border-color: #C2621F; color: #A9521A; }
:root[data-theme="dark"] .tag.share { border-color: #E89A60; color: #E89A60; }
.tree-links .dot { fill: var(--sheet); stroke: var(--rule-strong); stroke-width: 1.6; }
.tree-links .ring circle { fill: var(--sheet); stroke: var(--rule-strong); stroke-width: 1.4; }
.tree-links .ring text { fill: var(--female); font-size: 11px; text-anchor: middle; }

.fcard {
  position: absolute; box-sizing: border-box;
  display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px;
  background: var(--sheet); color: var(--text);
  border: 1px solid var(--rule); border-top: 4px solid var(--none); border-radius: 10px;
  box-shadow: 0 1px 2px rgba(20, 28, 60, .06), 0 4px 14px rgba(20, 28, 60, .07);
  cursor: grab; transition: box-shadow .15s, transform .15s;
}
.fcard.g-m { border-top-color: var(--male); }
.fcard.g-f { border-top-color: var(--female); }
.fcard:hover { box-shadow: 0 2px 4px rgba(20, 28, 60, .08), 0 8px 22px rgba(20, 28, 60, .12); }
.fcard:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.fcard.selected { outline: 2.5px solid var(--mustard); outline-offset: 2px; }
.fcard.lifted { box-shadow: 0 10px 30px rgba(20, 28, 60, .25); z-index: 3; cursor: grabbing; transition: none; }
.fcard.drop-target { outline: 3px dashed var(--field); outline-offset: 4px; transform: scale(1.04); }
.fc-avatar {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 18px; color: #fff;
  background: var(--none);
}
.fcard.g-m .fc-avatar { background: var(--male); }
.fcard.g-f .fc-avatar { background: var(--female); }
.fcard.g-n .fc-avatar { color: #1B2240; }
.fcard.late .fc-avatar { filter: grayscale(.85); opacity: .75; }
.fcard.late { background: color-mix(in srgb, var(--sheet) 85%, var(--paper)); }
.fc-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.fc-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-land { font-size: 12.5px; margin-top: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-land b { color: var(--field); }
.fc-land .bad { color: var(--madder); font-weight: 600; }
.fc-land .opt { color: var(--muted); }
.fc-late {
  position: absolute; top: -11px; right: 10px;
  background: var(--madder); color: #fff; font-size: 11px; font-weight: 700;
  padding: 1px 8px; border-radius: 999px;
}
.fc-menu {
  position: absolute; transform: translateX(-50%); z-index: 4;
  display: flex; flex-wrap: nowrap; gap: 4px; padding: 5px;
  background: var(--indigo); border-radius: 999px; box-shadow: 0 6px 20px rgba(20, 28, 60, .25);
}
.fc-menu[hidden] { display: none; }
.fc-menu button {
  border: 0; background: transparent; color: #fff; font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 11px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.fc-menu button:hover, .fc-menu button:focus-visible { background: rgba(255, 255, 255, .16); outline: none; }
:root[data-theme="dark"] .fc-menu { background: var(--mustard); }
:root[data-theme="dark"] .fc-menu button { color: #1B2240; }
:root[data-theme="dark"] .fc-menu button:hover { background: rgba(0, 0, 0, .1); }

.stage-tools { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; z-index: 5; }
.stage-tools button {
  min-width: 36px; height: 36px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--rule-strong); background: var(--sheet); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.stage-tools button:hover { background: var(--paper); }
.stage-tools button:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.stage-hint {
  position: absolute; left: 10px; bottom: 8px; max-width: calc(100% - 20px); margin: 0; pointer-events: none;
  font-size: 12px; color: var(--muted); line-height: 1.35;
  background: color-mix(in srgb, var(--paper) 88%, transparent); padding: 4px 8px; border-radius: 6px;
}
@media (max-width: 520px) {
  .tree-stage { height: 70vh; }
  .stage-tools { left: 10px; right: 10px; flex-wrap: wrap; justify-content: flex-start; gap: 5px; }
  .stage-tools button { height: 34px; min-width: 34px; padding: 0 10px; }
  .fc-avatar { width: 36px; height: 36px; font-size: 15px; }
  .fcard { gap: 8px; padding: 10px 9px 8px; }
  .fc-name { font-size: 14px; }
}

dialog .two-col { gap: 0 12px; }
.split-actions { align-items: center; gap: 8px; }
.split-actions .spacer { flex: 1; }
.heir-rows { margin-top: 8px; }
.heir-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 70px 32px; gap: 8px; align-items: end; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.heir-row label { margin: 0 0 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.heir-row input, .heir-row select { padding: 8px 9px; font-size: 15px; }
.heir-row .remove { margin: 0 0 4px; }
.split-preview { margin-top: 12px; }
.bbb-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.bbb-inputs label { margin-top: 10px; }
#plMode { margin-top: 12px; }
.or-line { margin: 8px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.bbb-tight label { margin-top: 4px; }
#pShareInfo { margin-top: 10px; }
.pass-rows { margin: 8px 0 4px; }
.pass-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.pass-row .choice { margin: 0; }
.pass-row input[type="text"] { padding: 7px 9px; font-size: 15px; }
.split-preview .ledger { margin-top: 0; }
@media (max-width: 520px) {
  .tree ul { padding-left: 18px; }
  .tree ul > li::before, .tree ul > li::after { left: -11px; }
  .tree ul > li::after { width: 8px; }
  .heir-row { grid-template-columns: minmax(0, 1fr) 70px 32px; }
  .heir-row > div:nth-child(2) { grid-column: 1 / -1; order: 3; }
}

/* settings dialog */
dialog {
  border: 1px solid var(--rule-strong); border-radius: var(--r-md);
  background: var(--sheet); color: var(--text);
  padding: 0; width: min(480px, calc(100vw - 24px));
}
dialog::backdrop { background: rgba(15, 20, 48, .55); }
.settings-form { padding: 24px; }
.settings-form h2 { font-family: var(--display); font-size: 24px; margin: 0 0 8px; }
fieldset { border: 0; padding: 0; margin: 18px 0 0; }
legend { font-weight: 700; padding: 0; }
.choice { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 10px 0 0; cursor: pointer; }
.choice input { margin-top: 5px; accent-color: var(--indigo); }
#customBighaWrap { margin: 8px 0 0 26px; }
.dialog-actions { margin-top: 24px; display: flex; justify-content: flex-end; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--indigo); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14.5px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- phone navigation: bottom bar + "More" sheet ---------- */
.bottom-nav { display: none; }
.brand-short { display: none; }
.bottom-nav svg, .more-grid svg {
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
dialog.bottom-sheet {
  width: 100%; max-width: 560px; margin: auto auto 0; padding: 6px 12px calc(16px + env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0; border-bottom: 0;
}
.sheet-grab { width: 42px; height: 4px; border-radius: 2px; background: var(--rule-strong); margin: 6px auto 14px; }
.more-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.more-grid button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 92px; padding: 12px 6px; border-radius: 10px; cursor: pointer;
  background: var(--paper); border: 1px solid var(--rule); color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1.25; text-align: center;
}
.more-grid button:active { transform: scale(.97); }
.more-grid svg { width: 26px; height: 26px; color: var(--indigo); }
:root[data-theme="dark"] .more-grid svg { color: var(--mustard); }
.more-grid button.active { border-color: var(--mustard); box-shadow: inset 0 0 0 1px var(--mustard); }
.more-grid small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.more-grid .count { top: 6px; right: 8px; transform: none; }
/* A lone last tile fills its row as a short bar. */
.more-grid button:last-child:nth-child(3n+1) { grid-column: 1 / -1; min-height: 52px; flex-direction: row; }

/* "Your details" popup and footer link */
.consent-box { margin-top: 14px; padding: 10px 12px; border-left: 3px solid var(--mustard); background: color-mix(in srgb, var(--mustard) 8%, transparent); border-radius: 4px; font-size: 14px; }
.consent-box p { margin: 0; }
.consent-box .note { margin-top: 6px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: #fff; text-decoration: underline; cursor: pointer; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; gap: 14px; padding-top: 14px; }
  /* The side menu and breadcrumb give way to the bottom bar. */
  .tools, .crumbs { display: none; }
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    padding: 4px max(4px, calc((100% - 640px) / 2)) calc(4px + env(safe-area-inset-bottom));
    background: var(--indigo); border-top: 3px solid var(--mustard);
    box-shadow: 0 -4px 16px rgba(0, 20, 45, .18);
  }
  .bottom-nav button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 54px; padding: 5px 2px; border: 0; border-radius: 10px; cursor: pointer;
    background: none; color: rgba(255, 255, 255, .72);
    font: inherit; font-size: 11.5px; font-weight: 600; line-height: 1.15; text-align: center;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav svg { width: 24px; height: 24px; }
  .bottom-nav button.active { color: #fff; background: rgba(255, 255, 255, .12); }
  .bottom-nav button.active svg { color: #5CC8F5; }
  .bottom-nav button:focus-visible { outline: 2px solid #5CC8F5; outline-offset: -2px; }
  .bottom-nav .count {
    top: 3px; right: calc(50% - 24px); transform: none; min-width: 18px; padding: 0 5px;
    font-size: 11px; line-height: 18px; background: var(--mustard); color: #fff;
  }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .plot-grid { grid-template-columns: 1fr; }
  .plot-figure { max-width: 260px; }
}
@media (max-width: 520px) {
  .brand-sub, .bigha-chip-label { display: none; }
  .brand-name { font-size: 19px; white-space: nowrap; }
  .brand { gap: 10px; min-width: 0; }
  .brand-mark { width: 34px; height: 34px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar-actions { gap: 6px; }
  .lang-btn { padding: 6px 6px; font-size: 13px; }
  .type-btn span { min-width: 26px; height: 26px; font-size: 13px; }
  .type-btn .t-hi { font-size: 15px; }
  /* Bigha size lives in More → Settings on phones. */
  .bigha-chip { display: none; }
  /* Cards run edge to edge: more room for the form. */
  .layout { padding-left: 0; padding-right: 0; }
  .sheet { border-radius: 0; border-left: 0; border-right: 0; padding: 20px 14px 24px; }
  .panel h1 { font-size: 24px; }
  .help { margin-bottom: 18px; }
  .two-col, .plot-fields { grid-template-columns: 1fr; }
  .area-input .unit-row { grid-template-columns: 1fr; }
  .area-input .bbb label small { display: block; margin-left: 0; }
  /* Bigger touch targets. */
  .btn { min-height: 44px; }
  .btn.small { min-height: 38px; padding: 7px 12px; }
  .row { grid-template-columns: 38px minmax(0, 1fr) 32px; gap: 8px; }
  .sign { width: 38px; height: 42px; }
  .register > div { padding: 12px 8px 10px; container-type: inline-size; }
  .register .num { font-size: clamp(20px, 24cqi, 40px); white-space: nowrap; overflow-wrap: normal; }
  .register .unit small { display: block; margin-left: 0; }
  .share-row { grid-template-columns: minmax(0, 1fr) 90px 36px; }
  .land-list .saved-actions { max-width: none; justify-content: flex-start; }
  .land-list li { grid-template-columns: 1fr; }
  /* Forms in pop-ups slide up from the bottom, with the buttons always in reach. */
  dialog:not(.bottom-sheet) {
    width: 100%; max-width: 100%; max-height: 94dvh; margin: auto 0 0;
    border-radius: 16px 16px 0 0; border-left: 0; border-right: 0; border-bottom: 0;
  }
  .settings-form { padding: 18px 16px 0; }
  .settings-form .dialog-actions {
    position: sticky; bottom: 0; z-index: 2; margin: 18px -16px 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--sheet); border-top: 1px solid var(--rule);
  }
}
@media (max-width: 400px) {
  .brand-name { font-size: 17px; }
  .brand-mark { width: 30px; height: 30px; }
  .brand { gap: 8px; }
}
@media (max-width: 360px) {
  .bottom-nav { gap: 0; padding-left: 2px; padding-right: 2px; }
  .bottom-nav button { font-size: 10.5px; padding-left: 1px; padding-right: 1px; letter-spacing: -.01em; }
}
@media (max-width: 350px) {
  .brand-full { display: none; }
  .brand-short { display: inline; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* ---------- Hindi typing suggestions ---------- */
.hi-pop {
  position: fixed; z-index: 1000; display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  max-width: min(440px, calc(100vw - 8px)); padding: 5px;
  background: var(--sheet); color: var(--text);
  border: 1px solid var(--rule-strong); border-top: 3px solid var(--indigo); border-radius: 5px;
  box-shadow: 0 6px 20px rgba(0, 30, 60, .22);
}
.hi-pop[hidden] { display: none; }
.hi-pop button {
  font: inherit; font-size: 17px; line-height: 1.3; color: inherit; cursor: pointer;
  background: none; border: 1px solid transparent; border-radius: 4px; padding: 4px 10px;
}
.hi-pop button:hover { background: var(--paper); }
.hi-pop button.on { background: var(--indigo); color: #fff; }
:root[data-theme="dark"] .hi-pop button.on { background: var(--mustard); color: #06182B; }
.hi-pop button.en { font-size: 14px; color: var(--muted); border-color: var(--rule); }
.hi-pop .hi-hint { flex-basis: 100%; font-size: 11.5px; color: var(--muted); padding: 0 6px 1px; }

/* ---------- print ---------- */
/* Family tree print: a white copy of the chart, built only while printing. */
.print-sheet {
  display: none;
  page: tree;
  --paper: #fff; --sheet: #fff; --text: #111; --muted: #444; --rule: #A6ADBD; --rule-strong: #6C7488;
  --field: #1F5A33; --madder: #A3322A; --mustard: #C98F12;
  --male: #3E7CB0; --female: #B0559F; --none: #C98F12; --buyer: #23786A; --share: #B0561A;
  color: #111; background: #fff; font-family: var(--body);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
@page tree { size: A4 landscape; margin: 10mm; }
.print-sheet h1 { font: 700 21px/1.2 var(--display); margin: 0 0 2px; color: #111; }
.print-sheet .ps-meta { margin: 0 0 12px; font-size: 12.5px; color: #444; }
.print-sheet .ps-chart { position: relative; overflow: hidden; margin: 0 auto; }
.print-sheet .ps-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.print-sheet .tree-links .lk { stroke: #6C7488 !important; }
.print-sheet .tree-links .lk.sale { stroke: var(--buyer) !important; }
.print-sheet .tree-links .lk.share { stroke: var(--share) !important; }
.print-sheet .fcard { box-shadow: none; border-color: #A6ADBD; cursor: default; }
.print-sheet .ps-list { break-before: page; white-space: pre-wrap; font-size: 13px; line-height: 1.65; }
.print-sheet .ps-list h2 { font: 700 17px var(--display); margin: 0 0 6px; white-space: normal; }
@media print {
  body.printing-tree > :not(.print-sheet) { display: none !important; }
  body.printing-tree { background: #fff; }
  body.printing-tree .print-sheet { display: block; }
}
@media print {
  body { background: #fff; color: #000; }
  .topbar { background: none; color: #000; border-bottom: 2px solid #000; padding: 0 0 8px; }
  .bigha-chip { border-color: #000; }
  .tools, .actions, .row-actions, details.quick, .remove, .toast, #clearSaved, .saved-actions, .crumbs { display: none !important; }
  .site-footer { background: none; color: #000; border-top: 1px solid #000; padding: 8px 0 0; }
  .site-footer b { color: #000; }
  .layout { display: block; padding: 12px 0; }
  .sheet { border: 0; padding: 0; }
  input[type="text"], input[type="tel"], select { border: 0; border-bottom: 1px solid #000; border-radius: 0; padding: 4px 0; }
}
