/* NewbieNeuro — công cụ lâm sàng. Token màu và kiểu chữ dùng chung với trang chủ. */
:root {
  --bg: #E7EAE7; --panel: #F1F3F0; --sunk: #DBE0DC; --rowHover: #EFF2EF;
  --ink: #12191A; --ink2: #3C4745; --meta: #5B6764;
  --hair: #BFC7C1; --strong: #12191A; --dash: #8E9A94;
  --core: #A8114F; --coreH: #78093A; --coreOn: #FFFFFF; --coreBg: #F3DCE6;
  --pen: #1B6655; --penOn: #FFFFFF; --penBg: #D3E6DE;
  --amber: #8A5A00; --amberBg: #F3E5C4;
  --inv: #12191A; --invInk: #E7EAE7; --invInk2: #C3CCC8; --invMeta: #9DA9A4; --invHair: #3A4548; --invCore: #FF7FAE; --invPen: #6ED3B4; --invAmber: #F2C46B;
  --shadow: rgba(12, 18, 20, 0.16);
  --display: 'Archivo', 'Be Vietnam Pro', system-ui, sans-serif;
  --body: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #12191B; --panel: #1B2326; --sunk: #283236; --rowHover: #222B2F;
  --ink: #E3E9E5; --ink2: #B2BDB8; --meta: #8B9793;
  --hair: #2F3A3D; --strong: #5A686D; --dash: #4A585C;
  --core: #FF74A8; --coreH: #FFA3C6; --coreOn: #24050F; --coreBg: #3A1024;
  --pen: #63CCAB; --penOn: #05261D; --penBg: #16352C;
  --amber: #EFC478; --amberBg: #3A2A13;
  --inv: #28343A; --invInk: #EDF2EF; --invInk2: #C0CBC6; --invMeta: #94A09B; --invHair: #435256; --invCore: #FF8FBB; --invPen: #7FDCBE; --invAmber: #F5CE82;
  --shadow: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 15.5px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--core); text-decoration: none; }
a:hover { color: var(--coreH); text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--core); outline-offset: 3px; }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }
b, strong { font-weight: 600; }

.top-rule { height: 4px; background: var(--core); }

/* ---------- header ---------- */
.site-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1280px; margin: 0 auto; padding: 14px 24px;
  border-bottom: 1px solid var(--hair);
}
.wordmark {
  display: flex; align-items: baseline; gap: 12px; color: var(--ink); text-decoration: none;
  font-family: var(--display); font-variation-settings: 'wdth' 118, 'wght' 750; font-size: 21px; letter-spacing: -0.015em;
}
.wordmark:hover { color: var(--ink); text-decoration: none; }
.wm-sub { font-family: var(--body); font-variation-settings: normal; font-weight: 500; font-size: 13.5px; letter-spacing: 0; color: var(--meta); }
.theme-switch { display: flex; border: 1px solid var(--hair); border-radius: 2px; overflow: hidden; flex-shrink: 0; }
.theme-btn {
  min-height: 44px; padding: 0 13px; display: flex; align-items: center; gap: 7px;
  font-size: 13.5px; font-weight: 500; border: 0; background: transparent; color: var(--ink);
}
.theme-btn + .theme-btn { border-left: 1px solid var(--hair); }
.theme-btn[aria-pressed="true"] { background: var(--inv); color: var(--invInk); }
.theme-btn:not([aria-pressed="true"]):hover { background: var(--sunk); }

/* ---------- hub ---------- */
.hub, .tool { max-width: 1280px; margin: 0 auto; padding: 0 24px 64px; }
.hub-hero { padding: 48px 0 18px; max-width: 860px; }
h1 {
  margin: 0 0 12px; font-family: var(--display); font-variation-settings: 'wdth' 112, 'wght' 730;
  font-size: clamp(30px, 5vw, 52px); line-height: 1.04; letter-spacing: -0.026em;
}
.lead { margin: 0; font-size: 16.5px; line-height: 1.6; color: var(--ink2); max-width: 680px; }
.privacy {
  display: flex; gap: 10px; align-items: flex-start; margin: 22px 0 0; padding-left: 14px;
  border-left: 3px solid var(--pen); color: var(--ink2); font-size: 14px; max-width: 620px;
}
.privacy svg { color: var(--pen); flex-shrink: 0; margin-top: 2px; }
.privacy b { color: var(--pen); }
.hub-search { margin-top: 28px; }
.f-label { display: block; font-size: 13px; font-weight: 500; color: var(--meta); margin-bottom: 7px; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--meta); pointer-events: none; }
.search-box input {
  width: 100%; height: 56px; padding: 0 16px 0 46px; font-size: 16px;
  background: var(--panel); border: 1.5px solid var(--strong); border-radius: 2px;
}
.hub-count { margin: 10px 0 0; font-size: 13px; color: var(--meta); font-family: var(--mono); }

.group { margin-top: 44px; padding-top: 24px; border-top: 2px solid var(--strong); }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.group-head h2 {
  margin: 0; font-family: var(--display); font-variation-settings: 'wdth' 112, 'wght' 700;
  font-size: clamp(21px, 2.6vw, 28px); letter-spacing: -0.02em; line-height: 1.15;
}
.group-count { font-family: var(--mono); font-size: 13px; color: var(--meta); flex-shrink: 0; }
.sub + .sub { margin-top: 20px; }
.sub-head { margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--ink2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; min-height: 44px; padding: 9px 14px;
  font-size: 14.5px; font-weight: 500; color: var(--ink); background: var(--panel);
  border: 1px solid var(--hair); border-radius: 2px; text-decoration: none;
}
.chip:hover { color: var(--penOn); background: var(--pen); border-color: var(--pen); text-decoration: none; }
.hub-empty { margin-top: 32px; padding: 18px; border: 1px dashed var(--dash); color: var(--meta); }

/* ---------- tool page ---------- */
.crumbs { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 18px 0 0; font-size: 13.5px; }
.crumbs a { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; font-weight: 500; }
.crumb-sep { color: var(--meta); }
.tool-head { padding: 18px 0 26px; border-bottom: 1px solid var(--hair); }
.tool-code { margin: 0 0 6px; font-family: var(--mono); font-size: 13px; color: var(--core); }
.tool-head h1 { font-size: clamp(28px, 4.2vw, 44px); }
.tool-meta { margin: 12px 0 0; font-size: 13.5px; color: var(--meta); display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; }
.tool-link { font-weight: 500; }

.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 40px; padding-top: 28px; align-items: start; }
.side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 14px; }

.intro { margin-bottom: 18px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--hair); border-radius: 2px; font-size: 14px; color: var(--ink2); }
.intro p { margin: 0 0 8px; } .intro p:last-child { margin: 0; }
.intro ul { margin: 6px 0 0; padding-left: 18px; }
.in-heading {
  margin: 26px 0 10px; font-family: var(--display); font-variation-settings: 'wdth' 110, 'wght' 680;
  font-size: 17px; letter-spacing: -0.01em;
}
.inputs > .in-heading:first-child, .intro + .in-heading { margin-top: 0; }

/* score items */
.item { margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
.item legend, .seg legend { display: flex; flex-direction: column; gap: 2px; padding: 0; margin-bottom: 8px; }
.it-label { font-size: 15px; font-weight: 600; color: var(--ink); }
.it-note { font-size: 13px; color: var(--meta); font-weight: 400; }
.opts { display: flex; flex-direction: column; border: 1px solid var(--hair); border-radius: 2px; background: var(--panel); }
.opt {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 9px 14px;
  cursor: pointer; font-size: 14.5px; line-height: 1.45;
}
.opt + .opt { border-top: 1px solid var(--hair); }
.opt:hover { background: var(--rowHover); }
.opt input, .yn input, .seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opt::before, .yn::before {
  content: ''; flex-shrink: 0; width: 18px; height: 18px; border: 1.5px solid var(--dash); border-radius: 50%; background: var(--bg);
}
.yn::before { border-radius: 2px; }
.opt:has(input:checked) { background: var(--coreBg); }
.opt:has(input:checked)::before { border-color: var(--core); background: var(--core); box-shadow: inset 0 0 0 3px var(--panel); }
.opt:has(input:focus-visible), .yn:has(input:focus-visible), .seg-opt:has(input:focus-visible) { outline: 2px solid var(--core); outline-offset: -2px; }
.opt-text { flex: 1; }
.opt-un .opt-text { color: var(--meta); }
.pts { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--meta); min-width: 28px; text-align: right; }
.opt:has(input:checked) .pts { color: var(--core); }

.yn {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 14px; margin-bottom: 6px;
  background: var(--panel); border: 1px solid var(--hair); border-radius: 2px; cursor: pointer; font-size: 14.5px;
}
.yn:hover { background: var(--rowHover); }
.yn:has(input:checked) { border-color: var(--core); background: var(--coreBg); }
.yn:has(input:checked)::before {
  border-color: var(--core); background: var(--core)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/13px no-repeat;
}
.yn-text { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.yn-note { font-size: 12.5px; color: var(--meta); }

/* form fields */
.field { margin-bottom: 14px; }
.field-yn { margin-bottom: 0; }
.field-yn + .field:not(.field-yn) { margin-top: 14px; }
.num-box { display: flex; align-items: stretch; max-width: 340px; }
.num-box input, .field select {
  width: 100%; min-height: 50px; padding: 0 14px; font-size: 17px; font-family: var(--mono);
  background: var(--panel); border: 1.5px solid var(--strong); border-radius: 2px;
}
.field select { font-family: var(--body); font-size: 15px; max-width: 520px; }
.num-box input { border-right-width: 0; border-radius: 2px 0 0 2px; }
.num-box input:only-child { border-right-width: 1.5px; border-radius: 2px; }
.unit {
  display: flex; align-items: center; padding: 0 12px; font-size: 13.5px; color: var(--meta); white-space: nowrap;
  border: 1.5px solid var(--strong); border-left: 1px solid var(--hair); border-radius: 0 2px 2px 0; background: var(--sunk);
}
.f-hint { margin: 6px 0 0; font-size: 12.5px; color: var(--meta); max-width: 520px; }
.field-time .num-box { max-width: 200px; }

.seg { margin: 0; padding: 0; border: 0; min-width: 0; }
.seg-row { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-opt {
  position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px;
  font-size: 14px; font-weight: 500; background: var(--panel); border: 1px solid var(--hair); border-radius: 2px; cursor: pointer;
}
.seg-opt:hover { border-color: var(--dash); }
.seg-opt:has(input:checked) { background: var(--inv); color: var(--invInk); border-color: var(--inv); }

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

/* ---------- result ---------- */
.result { background: var(--inv); color: var(--invInk); border-radius: 2px; padding: 20px 22px 22px; border-top: 4px solid var(--invMeta); }
.result[data-tone="ok"] { border-top-color: var(--invPen); }
.result[data-tone="warn"] { border-top-color: var(--invAmber); }
.result[data-tone="bad"] { border-top-color: var(--invCore); }
.result[data-tone="empty"] { background: var(--panel); color: var(--meta); border: 1px dashed var(--dash); border-top-width: 1px; }
.r-empty { margin: 0; font-size: 14px; }
.r-label { margin: 0 0 4px; font-size: 13px; color: var(--invMeta); font-weight: 500; }
.r-value { margin: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.r-num { font-family: var(--mono); font-size: 44px; font-weight: 500; line-height: 1.1; letter-spacing: -0.02em; color: var(--invInk); }
.r-unit { font-size: 15px; color: var(--invInk2); }
.r-band { margin: 6px 0 0; font-size: 16.5px; font-weight: 600; line-height: 1.35; }
.result[data-tone="ok"] .r-band { color: var(--invPen); }
.result[data-tone="warn"] .r-band { color: var(--invAmber); }
.result[data-tone="bad"] .r-band { color: var(--invCore); }
.r-detail { margin-top: 10px; font-size: 14px; line-height: 1.55; color: var(--invInk2); }
.r-detail p { margin: 0 0 6px; } .r-detail p:last-child { margin: 0; }
.r-rows { width: 100%; margin-top: 14px; border-collapse: collapse; font-size: 14px; }
.r-rows th, .r-rows td { padding: 8px 0; border-top: 1px solid var(--invHair); vertical-align: top; }
.r-rows th { text-align: left; font-weight: 400; color: var(--invInk2); padding-right: 12px; }
.r-rows td { text-align: right; font-family: var(--mono); font-weight: 500; color: var(--invInk); }
.r-rows tr[data-tone="bad"] td { color: var(--invCore); }
.r-rows tr[data-tone="warn"] td { color: var(--invAmber); }
.r-rows tr[data-tone="ok"] td { color: var(--invPen); }
.r-warn, .r-notes { margin: 12px 0 0; padding: 0; list-style: none; font-size: 13.5px; line-height: 1.5; }
.r-warn li { padding: 8px 10px; margin-top: 6px; border-left: 3px solid var(--invCore); background: rgba(255, 255, 255, 0.05); color: var(--invInk); }
.r-notes li { padding: 4px 0 4px 14px; position: relative; color: var(--invInk2); }
.r-notes li::before { content: ''; position: absolute; left: 0; top: 12px; width: 6px; height: 1px; background: var(--invMeta); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { min-height: 44px; padding: 0 16px; font-size: 14px; font-weight: 500; border-radius: 2px; }
.btn-ghost { background: transparent; border: 1px solid var(--hair); color: var(--ink); }
.btn-ghost:hover { background: var(--sunk); }
.btn-solid { background: var(--inv); border: 1px solid var(--inv); color: var(--invInk); }
.btn-solid:hover { opacity: 0.9; }

.verify { margin: 0; padding: 10px 12px; font-size: 13px; line-height: 1.5; color: var(--amber); background: var(--amberBg); border-radius: 2px; }
.formula { border: 1px solid var(--hair); border-radius: 2px; background: var(--panel); }
.formula summary { padding: 12px 14px; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 44px; }
.formula-body { padding: 0 14px 14px; font-size: 13.5px; line-height: 1.6; color: var(--ink2); }
.formula-body p { margin: 0 0 8px; }
.formula-body code, .formula-body .eq { font-family: var(--mono); font-size: 12.5px; color: var(--ink); background: var(--sunk); padding: 1px 5px; border-radius: 2px; }
.formula-body .eq { display: block; padding: 8px 10px; margin: 6px 0 10px; white-space: pre-wrap; }
.formula-body table { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 12.5px; }
.formula-body th, .formula-body td { text-align: left; padding: 5px 6px; border-top: 1px solid var(--hair); vertical-align: top; }
.formula-body th { font-weight: 600; color: var(--ink); }
.formula-body ul { margin: 4px 0 8px; padding-left: 18px; }
.refs { font-size: 12.5px; color: var(--meta); }
.refs-head { margin: 0 0 4px; font-weight: 600; color: var(--ink2); font-size: 13px; }
.refs ol { margin: 0; padding-left: 18px; }
.refs li { margin-bottom: 3px; }

/* reference tables inside tools */
.ref-table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--panel); border: 1px solid var(--hair); }
.ref-table th, .ref-table td { text-align: left; padding: 10px 12px; border-top: 1px solid var(--hair); vertical-align: top; }
.ref-table thead th { background: var(--inv); color: var(--invInk); font-size: 12.5px; font-weight: 600; border-top: 0; }
.ref-table tbody tr:hover { background: var(--rowHover); }
.ref-table .mono { color: var(--core); white-space: nowrap; }
.tag { display: inline-block; padding: 2px 8px; font-size: 12px; font-weight: 600; border-radius: 2px; white-space: nowrap; }
.tag-bad { color: var(--core); background: var(--coreBg); }
.tag-warn { color: var(--amber); background: var(--amberBg); }
.tag-ok { color: var(--pen); background: var(--penBg); }
.table-wrap { overflow-x: auto; }
.lookup-search { margin-bottom: 14px; }
.lookup-search input { width: 100%; max-width: 520px; min-height: 48px; padding: 0 14px; background: var(--panel); border: 1.5px solid var(--strong); border-radius: 2px; }

/* mRS shift bars */
.grotta { margin-top: 10px; }
.grotta-row { display: grid; grid-template-columns: 90px 1fr; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.grotta-bar { display: flex; height: 34px; border: 1px solid var(--hair); border-radius: 2px; overflow: hidden; }
.grotta-seg { display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 11.5px; color: #fff; min-width: 0; overflow: hidden; white-space: nowrap; }
.grotta-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--meta); margin-top: 6px; }
.grotta-legend span { display: inline-flex; align-items: center; gap: 5px; }
.grotta-legend i { width: 12px; height: 12px; border-radius: 1px; display: inline-block; }
.mrs-grid { display: grid; grid-template-columns: 70px repeat(2, minmax(0, 1fr)); gap: 6px 12px; align-items: center; max-width: 460px; }
.mrs-grid .num-box input { min-height: 44px; font-size: 15px; }
.mrs-grid .gh { font-size: 12.5px; font-weight: 600; color: var(--meta); }

/* ---------- footer ---------- */
.site-foot { max-width: 1280px; margin: 0 auto; padding: 24px 24px 90px; border-top: 1px solid var(--hair); font-size: 13px; color: var(--meta); }
.site-foot p { margin: 0 0 6px; max-width: 760px; }
.disc { color: var(--ink2); }

/* mobile result dock */
.dock { display: none; }

@media (max-width: 960px) {
  .tool-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .side { position: static; }
  .dock:not([hidden]) {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 30;
    min-height: 54px; padding: 12px 16px; border: 0; border-radius: 2px;
    background: var(--inv); color: var(--invInk); box-shadow: 0 10px 28px var(--shadow); text-align: left;
  }
  .dock-num { font-family: var(--mono); font-size: 20px; font-weight: 500; white-space: nowrap; }
  .dock-label { font-size: 13px; color: var(--invInk2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .site-head, .hub, .tool, .site-foot { padding-left: 16px; padding-right: 16px; }
  .wm-sub { display: none; }
  .theme-btn span { display: none; }
  .hub-hero { padding-top: 28px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .r-num { font-size: 38px; }
  .ref-table { font-size: 13px; }
  .ref-table th, .ref-table td { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .site-head, .actions, .dock, .crumbs, .site-foot .foot-meta { display: none !important; }
  .tool-grid { grid-template-columns: 1fr; }
  .result { color: #000; background: #fff; border: 1px solid #000; }
}
