/* Age Health Guide — The New KO workspace. 20260716a */
.tn-ahg-page,
.tn-ahg-page * { box-sizing: border-box; }

.tn-ahg-page {
  --ahg-paper: #faf6ee;
  --ahg-wash: #f5efdf;
  --ahg-panel: #fffaf0;
  --ahg-ink: #1a1208;
  --ahg-muted: #5a4a30;
  --ahg-line: #b8a888;
  --ahg-soft-line: #ddd4be;
  --ahg-accent: #c44a00;
  --ahg-primary-bg: #1a1208;
  --ahg-primary-ink: #fff7e8;
  --ahg-secondary-bg: #ede6d4;
  --ahg-secondary-ink: #1a1208;
  --ahg-hi-bg: #f4e2d6;
  --ahg-hi-ink: #8e3b12;
  --ahg-hi-line: #d9a982;
  --ahg-mid-bg: #eee6d3;
  --ahg-mid-ink: #6a5326;
  --ahg-low-bg: #e9edea;
  --ahg-low-ink: #4c5a52;
  --ahg-success-bg: #26351f;
  --ahg-success-ink: #f3ffe5;
  --ahg-success-line: #7d965e;
  --ahg-track: #e7ddc7;
  width: min(1180px, calc(100vw - 10px));
  margin: 0 auto;
  color: var(--ahg-ink);
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

.tn-ahg-page :where(ul, ol) { list-style: none; padding-left: 0; margin: 0; }

.tn-ahg-tool {
  margin: 0 0 18px;
  color: var(--ahg-ink);
  background:
    linear-gradient(90deg, rgba(184, 168, 136, .13) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(0deg, rgba(184, 168, 136, .10) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--ahg-paper);
  border: 1px solid var(--ahg-line);
  padding: 12px;
  overflow: hidden;
}

.tn-ahg-workspace {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
  gap: 10px;
  align-items: stretch;
}

.tn-ahg-pane {
  min-width: 0;
  display: grid;
  grid-template-rows: auto;
  align-content: start;
  row-gap: 12px;
  background: color-mix(in srgb, var(--ahg-panel) 92%, transparent);
  border: 1px solid var(--ahg-line);
  padding: 12px;
}

.tn-ahg-kicker {
  margin: 0;
  color: var(--ahg-muted);
  -webkit-text-fill-color: var(--ahg-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ---- input pane ---- */
.tn-ahg-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; }
.tn-ahg-field {
  display: grid;
  grid-template-rows: auto auto;
  gap: 5px;
  align-content: start;
  min-width: 0;
  margin: 0;
  color: var(--ahg-muted);
  -webkit-text-fill-color: var(--ahg-muted);
  font-size: 12.5px;
  line-height: 1.2;
  font-weight: 850;
}
.tn-ahg-field > span { display: block; }

.tn-ahg-control {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px;
  background: var(--ahg-panel);
  border: 1px solid var(--ahg-line);
}
.tn-ahg-control input {
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--ahg-ink);
  -webkit-text-fill-color: var(--ahg-ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  font-weight: 800;
  outline: none;
}
.tn-ahg-control input::placeholder { color: var(--ahg-muted); -webkit-text-fill-color: var(--ahg-muted); opacity: .5; }
.tn-ahg-control input::-webkit-input-placeholder { color: var(--ahg-muted); -webkit-text-fill-color: var(--ahg-muted); opacity: .5; }
.tn-ahg-control b {
  flex: 0 0 auto;
  color: var(--ahg-muted);
  -webkit-text-fill-color: var(--ahg-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  font-weight: 800;
  border-left: 1px solid var(--ahg-soft-line);
  padding-left: 8px;
}

/* gender segmented control — appearance flat, same height as controls */
.tn-ahg-seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; height: 40px; border: 1px solid var(--ahg-line); overflow: hidden; }
.tn-ahg-seg button {
  appearance: none;
  -webkit-appearance: none;
  height: 100%;
  margin: 0;
  border: 0;
  border-right: 1px solid var(--ahg-line);
  background: var(--ahg-panel);
  color: var(--ahg-muted);
  -webkit-text-fill-color: var(--ahg-muted);
  font-family: "Noto Sans KR", system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
}
.tn-ahg-seg button:last-child { border-right: 0; }
.tn-ahg-seg button[aria-pressed="true"] {
  background: var(--ahg-primary-bg);
  color: var(--ahg-primary-ink);
  -webkit-text-fill-color: var(--ahg-primary-ink);
}

/* quick age chips */
.tn-ahg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tn-ahg-chip {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 6px 11px;
  border: 1px solid var(--ahg-soft-line);
  background: var(--ahg-wash);
  color: var(--ahg-muted);
  -webkit-text-fill-color: var(--ahg-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.tn-ahg-chip[aria-pressed="true"] {
  background: var(--ahg-primary-bg);
  color: var(--ahg-primary-ink);
  -webkit-text-fill-color: var(--ahg-primary-ink);
  border-color: var(--ahg-primary-bg);
}

.tn-ahg-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.tn-ahg-button {
  appearance: none;
  -webkit-appearance: none;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--ahg-line);
  background: var(--ahg-secondary-bg);
  color: var(--ahg-secondary-ink);
  -webkit-text-fill-color: var(--ahg-secondary-ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.tn-ahg-button--primary { background: var(--ahg-primary-bg); border-color: var(--ahg-primary-bg); color: var(--ahg-primary-ink); -webkit-text-fill-color: var(--ahg-primary-ink); }
.tn-ahg-button:focus-visible { outline: 2px solid var(--ahg-accent); outline-offset: 2px; }
.tn-ahg-seg button:focus-visible,
.tn-ahg-chip:focus-visible { outline: 2px solid var(--ahg-accent); outline-offset: 2px; }

.tn-ahg-status {
  margin: 0;
  padding: 9px 11px;
  background: var(--ahg-wash);
  border: 1px solid var(--ahg-soft-line);
  color: var(--ahg-muted);
  -webkit-text-fill-color: var(--ahg-muted);
  font-size: 12.5px;
  line-height: 1.35;
  font-weight: 700;
}
.tn-ahg-status[data-tone="success"] { background: var(--ahg-success-bg); border-color: var(--ahg-success-line); color: var(--ahg-success-ink); -webkit-text-fill-color: var(--ahg-success-ink); }

/* ---- result pane ---- */
.tn-ahg-summary { display: grid; gap: 10px; }
.tn-ahg-badge-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tn-ahg-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 10px;
  background: var(--ahg-primary-bg);
  color: var(--ahg-primary-ink);
  -webkit-text-fill-color: var(--ahg-primary-ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.1;
}
.tn-ahg-badge[data-empty="true"] { background: var(--ahg-wash); color: var(--ahg-muted); -webkit-text-fill-color: var(--ahg-muted); }
.tn-ahg-card-tools { display: flex; gap: 6px; }
.tn-ahg-mini {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 5px 9px;
  border: 1px solid var(--ahg-soft-line);
  background: var(--ahg-wash);
  color: var(--ahg-muted);
  -webkit-text-fill-color: var(--ahg-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.tn-ahg-mini:focus-visible { outline: 2px solid var(--ahg-accent); outline-offset: 2px; }

/* progress meter — visual affordance */
.tn-ahg-meter { display: grid; gap: 6px; padding: 10px 11px; border: 1px solid var(--ahg-soft-line); background: var(--ahg-panel); }
.tn-ahg-meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tn-ahg-meter-label { color: var(--ahg-muted); -webkit-text-fill-color: var(--ahg-muted); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.tn-ahg-meter-value { color: var(--ahg-ink); -webkit-text-fill-color: var(--ahg-ink); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; font-weight: 900; }
.tn-ahg-meter-track { position: relative; height: 8px; background: var(--ahg-track); overflow: hidden; }
.tn-ahg-meter-fill { position: absolute; inset: 0 auto 0 0; width: 0%; background: var(--ahg-accent); transition: width .25s ease; }

/* priority distribution mini-bar — visual affordance */
.tn-ahg-priority { display: grid; gap: 6px; padding: 10px 11px; border: 1px solid var(--ahg-soft-line); background: var(--ahg-panel); }
.tn-ahg-priority-label { color: var(--ahg-muted); -webkit-text-fill-color: var(--ahg-muted); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.tn-ahg-priority-bar { display: flex; height: 12px; background: var(--ahg-track); overflow: hidden; }
.tn-ahg-priority-bar > span { display: block; width: 0%; transition: width .25s ease; }
.tn-ahg-priority-bar > .seg-high { background: var(--ahg-accent); }
.tn-ahg-priority-bar > .seg-mid { background: color-mix(in srgb, var(--ahg-accent) 42%, var(--ahg-track)); }
.tn-ahg-priority-bar > .seg-low { background: var(--ahg-low-ink); }
.tn-ahg-priority-legend { display: flex; flex-wrap: wrap; gap: 12px; }
.tn-ahg-priority-legend span { display: inline-flex; align-items: center; gap: 5px; color: var(--ahg-muted); -webkit-text-fill-color: var(--ahg-muted); font-size: 11.5px; font-weight: 800; }
.tn-ahg-dot { width: 9px; height: 9px; display: inline-block; }
.tn-ahg-dot.seg-high { background: var(--ahg-accent); }
.tn-ahg-dot.seg-mid { background: color-mix(in srgb, var(--ahg-accent) 42%, var(--ahg-track)); }
.tn-ahg-dot.seg-low { background: var(--ahg-low-ink); }

/* cards */
.tn-ahg-cards { display: grid; gap: 8px; }
.tn-ahg-card { border: 1px solid var(--ahg-line); background: var(--ahg-panel); }
.tn-ahg-card-head {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  cursor: pointer;
}
.tn-ahg-check {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin: 0;
  flex: 0 0 auto;
  border: 1px solid var(--ahg-line);
  background: var(--ahg-paper);
  position: relative;
  cursor: pointer;
}
.tn-ahg-check:checked { background: var(--ahg-accent); border-color: var(--ahg-accent); }
.tn-ahg-check:checked::before {
  content: "";
  position: absolute;
  left: 6px; top: 2px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.tn-ahg-check:focus-visible { outline: 2px solid var(--ahg-accent); outline-offset: 2px; }
.tn-ahg-card-title { color: var(--ahg-ink); -webkit-text-fill-color: var(--ahg-ink); font-size: 14px; font-weight: 850; line-height: 1.25; }
.tn-ahg-card-freq { color: var(--ahg-muted); -webkit-text-fill-color: var(--ahg-muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; font-weight: 800; white-space: nowrap; }
.tn-ahg-tag {
  display: inline-flex; align-items: center; min-height: 20px; padding: 2px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; font-weight: 800; line-height: 1; white-space: nowrap;
  border: 1px solid transparent;
}
.tn-ahg-tag.pri-high { background: var(--ahg-hi-bg); color: var(--ahg-hi-ink); -webkit-text-fill-color: var(--ahg-hi-ink); border-color: var(--ahg-hi-line); }
.tn-ahg-tag.pri-medium { background: var(--ahg-mid-bg); color: var(--ahg-mid-ink); -webkit-text-fill-color: var(--ahg-mid-ink); border-color: var(--ahg-soft-line); }
.tn-ahg-tag.pri-low { background: var(--ahg-low-bg); color: var(--ahg-low-ink); -webkit-text-fill-color: var(--ahg-low-ink); border-color: var(--ahg-soft-line); }
.tn-ahg-expand { width: 14px; height: 14px; color: var(--ahg-muted); transition: transform .2s ease; }
.tn-ahg-card.is-open .tn-ahg-expand { transform: rotate(180deg); }
.tn-ahg-card-body { display: none; padding: 0 11px 11px; border-top: 1px solid var(--ahg-soft-line); }
.tn-ahg-card.is-open .tn-ahg-card-body { display: grid; gap: 9px; padding-top: 10px; }
.tn-ahg-sec { display: grid; gap: 3px; }
.tn-ahg-sec h5 { margin: 0; color: var(--ahg-muted); -webkit-text-fill-color: var(--ahg-muted); font-size: 11.5px; font-weight: 850; letter-spacing: .02em; }
.tn-ahg-sec p { margin: 0; color: var(--ahg-ink); -webkit-text-fill-color: var(--ahg-ink); font-size: 13px; line-height: 1.5; font-weight: 500; }
.tn-ahg-source { color: var(--ahg-muted); -webkit-text-fill-color: var(--ahg-muted); font-size: 11px; font-weight: 800; }
.tn-ahg-source[data-kind="personal"] { color: var(--ahg-hi-ink); -webkit-text-fill-color: var(--ahg-hi-ink); }

/* empty skeleton — result pane never a void */
.tn-ahg-skeleton { display: grid; gap: 8px; }
.tn-ahg-skeleton-row { height: 42px; border: 1px dashed var(--ahg-soft-line); background: repeating-linear-gradient(90deg, transparent 0 12px, color-mix(in srgb, var(--ahg-soft-line) 40%, transparent) 12px 13px); }
.tn-ahg-hint { margin: 0; padding: 9px 11px; border: 1px solid var(--ahg-soft-line); background: var(--ahg-wash); color: var(--ahg-muted); -webkit-text-fill-color: var(--ahg-muted); font-size: 12.5px; line-height: 1.4; font-weight: 700; }

/* lifestyle */
.tn-ahg-life { display: grid; gap: 8px; }
.tn-ahg-life-title { color: var(--ahg-muted); -webkit-text-fill-color: var(--ahg-muted); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.tn-ahg-life-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tn-ahg-life-tip { display: grid; gap: 3px; padding: 9px 11px; border: 1px solid var(--ahg-soft-line); background: var(--ahg-panel); }
.tn-ahg-life-tip b { color: var(--ahg-ink); -webkit-text-fill-color: var(--ahg-ink); font-size: 13px; font-weight: 850; }
.tn-ahg-life-tip span { color: var(--ahg-muted); -webkit-text-fill-color: var(--ahg-muted); font-size: 12px; line-height: 1.4; font-weight: 600; }

.tn-ahg-notice {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--ahg-wash);
  border: 1px solid var(--ahg-soft-line);
  color: var(--ahg-muted);
  -webkit-text-fill-color: var(--ahg-muted);
  font-size: 12px;
  line-height: 1.45;
  font-weight: 700;
}

@media (max-width: 720px) {
  .tn-ahg-workspace { grid-template-columns: minmax(0, 1fr); }
  .tn-ahg-fields { grid-template-columns: minmax(0, 1fr); }
  .tn-ahg-life-grid { grid-template-columns: minmax(0, 1fr); }
  .tn-ahg-card-head { grid-template-columns: auto 1fr auto; grid-auto-rows: auto; }
  .tn-ahg-card-freq { grid-column: 2 / -1; }
}

/* ---------- dark / inverse / auto-dark: redefine tokens ---------- */
body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-l="dark"], [data-scheme="auto"][data-d="dark"]) .tn-ahg-page,
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-ahg-page {
  --ahg-paper: #201811;
  --ahg-wash: #2b2119;
  --ahg-panel: #241c15;
  --ahg-ink: #f7ecd8;
  --ahg-muted: #d3c2a4;
  --ahg-line: #6f5d40;
  --ahg-soft-line: #4c3f2c;
  --ahg-accent: #ff8a3d;
  --ahg-primary-bg: #ede0c6;
  --ahg-primary-ink: #201811;
  --ahg-secondary-bg: #33281c;
  --ahg-secondary-ink: #f7ecd8;
  --ahg-hi-bg: #3a2418;
  --ahg-hi-ink: #ffb98c;
  --ahg-hi-line: #7c4a2b;
  --ahg-mid-bg: #2f2519;
  --ahg-mid-ink: #d8c193;
  --ahg-low-bg: #232a26;
  --ahg-low-ink: #a9c0b3;
  --ahg-track: #3a2f21;
}

@media (prefers-color-scheme: dark) {
  body[data-scheme="auto"] .tn-ahg-page {
    --ahg-paper: #201811;
    --ahg-wash: #2b2119;
    --ahg-panel: #241c15;
    --ahg-ink: #f7ecd8;
    --ahg-muted: #d3c2a4;
    --ahg-line: #6f5d40;
    --ahg-soft-line: #4c3f2c;
    --ahg-accent: #ff8a3d;
    --ahg-primary-bg: #ede0c6;
    --ahg-primary-ink: #201811;
    --ahg-secondary-bg: #33281c;
    --ahg-secondary-ink: #f7ecd8;
    --ahg-hi-bg: #3a2418;
    --ahg-hi-ink: #ffb98c;
    --ahg-hi-line: #7c4a2b;
    --ahg-mid-bg: #2f2519;
    --ahg-mid-ink: #d8c193;
    --ahg-low-bg: #232a26;
    --ahg-low-ink: #a9c0b3;
    --ahg-track: #3a2f21;
  }
}

body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-l="dark"], [data-scheme="auto"][data-d="dark"]) .tn-ahg-control input,
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-ahg-control input { color-scheme: dark; }
@media (prefers-color-scheme: dark) { body[data-scheme="auto"] .tn-ahg-control input { color-scheme: dark; } }

/* dark: inverted-primary surfaces keep dark ink on their light surface (fixes #14 light-on-light).
   .tn-ahg-page ancestor raises specificity above the global The New dark text-fill rule. */
body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-l="dark"], [data-scheme="auto"][data-d="dark"]) .tn-ahg-page .tn-ahg-tool .tn-ahg-badge:not([data-empty="true"]),
body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-l="dark"], [data-scheme="auto"][data-d="dark"]) .tn-ahg-page .tn-ahg-tool .tn-ahg-button--primary,
body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-l="dark"], [data-scheme="auto"][data-d="dark"]) .tn-ahg-page .tn-ahg-tool .tn-ahg-seg button[aria-pressed="true"],
body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-l="dark"], [data-scheme="auto"][data-d="dark"]) .tn-ahg-page .tn-ahg-tool .tn-ahg-chip[aria-pressed="true"],
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-ahg-page .tn-ahg-tool .tn-ahg-badge:not([data-empty="true"]),
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-ahg-page .tn-ahg-tool .tn-ahg-button--primary,
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-ahg-page .tn-ahg-tool .tn-ahg-seg button[aria-pressed="true"],
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-ahg-page .tn-ahg-tool .tn-ahg-chip[aria-pressed="true"] {
  color: var(--ahg-primary-ink) !important;
  -webkit-text-fill-color: var(--ahg-primary-ink) !important;
}
@media (prefers-color-scheme: dark) {
  body[data-scheme="auto"] .tn-ahg-page .tn-ahg-tool .tn-ahg-badge:not([data-empty="true"]),
  body[data-scheme="auto"] .tn-ahg-page .tn-ahg-tool .tn-ahg-button--primary,
  body[data-scheme="auto"] .tn-ahg-page .tn-ahg-tool .tn-ahg-seg button[aria-pressed="true"],
  body[data-scheme="auto"] .tn-ahg-page .tn-ahg-tool .tn-ahg-chip[aria-pressed="true"] {
    color: var(--ahg-primary-ink) !important;
    -webkit-text-fill-color: var(--ahg-primary-ink) !important;
  }
}
