/* 人生換算所 — shared styles
   Layout: sticky slim header, centered column (wide for the directory, narrow for tools),
   punch-card panels; each category tints the page accent. */
:root {
  --bg: #eef1f5;
  --card: #ffffff;
  --soft: #f4f6f9;
  --ink: #151c26;
  --muted: #5a6573;
  --line: #d7dde5;
  --c-work: #e2521d;
  --c-money: #13896b;
  --c-loan: #2a5bd7;
  --c-life: #8a4fd6;
  --accent: var(--c-work);
  --good: #13896b;
  --warn: #c98a00;
  --bad: #d23b2a;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --radius: 14px;
  color-scheme: light;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131a; --card: #161d27; --soft: #111820; --ink: #e8edf3; --muted: #9ba7b5; --line: #29333f;
    --c-work: #ff7a45; --c-money: #36c39b; --c-loan: #7aa2ff; --c-life: #b48cff;
    --good: #36c39b; --warn: #f0b429; --bad: #ff6b5b;
    color-scheme: dark;
  }
}
body[data-cat="work"] { --accent: var(--c-work); }
body[data-cat="money"] { --accent: var(--c-money); }
body[data-cat="loan"] { --accent: var(--c-loan); }
body[data-cat="life"] { --accent: var(--c-life); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.65; }
[hidden] { display: none !important; }
a { color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.wrap { max-width: 1120px; margin: 0 auto; }
.wrap.narrow { max-width: 680px; }

/* header */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--card); z-index: 30; }
.site-header { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 900; font-size: 1.05rem; letter-spacing: .02em; }
.brand svg { width: 28px; height: 28px; flex: none; }
.nav-link { text-decoration: none; font-weight: 700; font-size: .9rem; padding: 7px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); }
.nav-link:hover { border-color: var(--ink); }

/* page shells */
main { padding-block: 28px 56px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.item-row { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 10px; align-items: center; padding: 10px 2px; border-top: 1px dashed var(--line); cursor: pointer; }
.item-row:first-child { border-top: 0; }
.item-row.sel .nm { color: var(--accent); }
.item-row .nm { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.item-row .nm span { display: block; font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.item-row .t { font-family: var(--mono); font-weight: 700; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item-row .x { border: 0; background: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 4px 6px; }
.item-row .bar { grid-column: 1 / -1; height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.item-row .bar i { display: block; height: 100%; background: var(--accent); opacity: .75; border-radius: 3px; }
.form-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 8px; align-items: end; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr 1fr; } .form-row .wide, .form-row .btn { grid-column: 1 / -1; } }
.crumbs { font-size: .85rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.page-title { margin: 0; font-weight: 900; font-size: clamp(1.8rem, 6vw, 2.4rem); line-height: 1.18; text-wrap: balance; letter-spacing: -.01em; }
.page-title em { font-style: normal; color: var(--accent); }
.lede { margin: 6px 0 0; color: var(--muted); max-width: 60ch; }

.panel { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel > h2, .eyebrow { margin: 0; font-size: .76rem; letter-spacing: .14em; color: var(--muted); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

label.field { display: flex; flex-direction: column; gap: 5px; font-size: .88rem; color: var(--muted); min-width: 0; }
.field .unit { display: flex; align-items: center; gap: 8px; }
.field .unit span { color: var(--muted); font-size: .88rem; white-space: nowrap; }
input, select { font: 500 1.05rem var(--sans); color: var(--ink); background: var(--soft); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; }
input[type="number"], input[type="time"], input.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input:focus { border-color: var(--accent); outline: none; }
.hint { font-size: .8rem; color: var(--muted); margin: 0; }

.seg { display: inline-flex; flex-wrap: wrap; border: 1.5px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; align-self: flex-start; background: var(--soft); }
.seg button { font: 700 .88rem var(--sans); border: 0; background: none; color: var(--muted); padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--card); }

.btn { font: 700 .95rem var(--sans); padding: 10px 16px; border-radius: 10px; cursor: pointer; border: 1.5px solid var(--ink); background: var(--ink); color: var(--card); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: 500 .88rem var(--sans); padding: 6px 12px; border-radius: 999px; cursor: pointer; border: 1.5px solid var(--line); background: var(--soft); color: var(--ink); }
.chip:hover { border-color: var(--accent); }
.toast { font-size: .85rem; color: var(--accent); min-height: 1.2em; margin: 0; overflow-wrap: anywhere; }

/* the big answer */
.readout { text-align: center; gap: 6px; padding-block: 22px; position: relative; overflow: hidden; }
.readout::before { content: ""; position: absolute; inset: 0 0 auto; height: 6px; background: repeating-linear-gradient(90deg, var(--accent) 0 18px, transparent 18px 30px); opacity: .55; }
.readout .q { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.readout .big { font-family: var(--mono); font-weight: 700; font-size: clamp(2.3rem, 10vw, 3.5rem); line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.readout .big small { font-family: var(--sans); font-size: .42em; color: var(--ink); font-weight: 700; margin-inline: 3px 6px; }
.readout .sub { color: var(--muted); font-size: .95rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .k { font-size: .8rem; color: var(--muted); }
.stat .v { font-family: var(--mono); font-weight: 700; font-size: 1.25rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .v small { font-family: var(--sans); font-size: .7em; font-weight: 500; color: var(--muted); margin-left: 3px; }
.pill { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; border: 1.5px solid currentColor; }
.pill.good { color: var(--good); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); }

.meter { height: 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }

.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; width: 100%; height: auto; min-width: 320px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82rem; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--sw); vertical-align: -1px; }

.list-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 2px; border-top: 1px dashed var(--line); align-items: center; }
.list-row:first-child { border-top: 0; }

/* share */
.share img { width: 100%; max-width: 420px; align-self: center; border-radius: 12px; border: 1.5px solid var(--line); display: block; }

/* prose / faq */
.prose p { margin: 0; color: var(--muted); }
.prose p + p { margin-top: 8px; }
.faq details { border-top: 1px dashed var(--line); padding: 10px 0; }
.faq details:first-of-type { border-top: 0; padding-top: 0; }
.faq summary { cursor: pointer; font-weight: 700; }
.faq p { margin: 6px 0 0; color: var(--muted); font-size: .94rem; }

/* tool cards (directory + related) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tcard { --tc: var(--c-work); display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); position: relative; transition: transform .15s, border-color .15s, box-shadow .15s; min-width: 0; }
.tcard:hover { transform: translateY(-2px); border-color: var(--tc); box-shadow: 0 10px 24px -14px color-mix(in srgb, var(--tc) 70%, transparent); }
.tcard[data-cat="money"] { --tc: var(--c-money); } .tcard[data-cat="loan"] { --tc: var(--c-loan); } .tcard[data-cat="life"] { --tc: var(--c-life); }
.tcard .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--tc) 14%, transparent); color: var(--tc); }
.tcard .ic svg { width: 24px; height: 24px; }
.tcard h3 { margin: 0; font-size: 1.12rem; font-weight: 900; line-height: 1.3; }
.tcard p { margin: 0; color: var(--muted); font-size: .92rem; }
.tcard .eg { margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--line); font-family: var(--mono); font-size: .82rem; color: var(--tc); font-weight: 700; overflow-wrap: anywhere; }
.tcard .go { position: absolute; top: 18px; right: 18px; color: var(--muted); transition: transform .15s, color .15s; }
.tcard:hover .go { transform: translateX(3px); color: var(--tc); }

.ad { min-height: 100px; text-align: center; }
.aff a { display: flex; flex-direction: column; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; text-decoration: none; }
.aff a span { color: var(--muted); font-size: .85rem; }

.site-footer { border-top: 1px solid var(--line); background: var(--card); }
.site-footer .wrap { padding-block: 28px; display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; color: var(--muted); font-size: .82rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; }
.site-footer nav a { text-decoration: none; }
.site-footer nav a:hover { text-decoration: underline; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* directory home */
.hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 32px; align-items: center; padding-block: 12px 8px; }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; gap: 24px; } }
.hero-text { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.hero-title { margin: 0; font-weight: 900; font-size: clamp(2.2rem, 7vw, 3.6rem); line-height: 1.12; letter-spacing: -.02em; text-wrap: balance; }
.hero-title em { font-style: normal; background: linear-gradient(90deg, var(--c-work), var(--c-life)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.search { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 4px 6px 4px 14px; max-width: 460px; color: var(--muted); }
.search:focus-within { border-color: var(--ink); }
.search svg { width: 20px; height: 20px; flex: none; }
.search input { border: 0; background: transparent; padding: 10px 6px; }
.search input:focus { outline: none; }
.hero-art { position: relative; height: 300px; }
@media (max-width: 820px) {
  .hero-art { height: auto; max-width: 440px; width: 100%; justify-self: center; display: flex; flex-direction: column; gap: 10px; }
  .hero-art .slip { position: relative; inset: auto; width: 84%; }
  .hero-art .slip.s2 { align-self: flex-end; }
  .hero-art .slip.s3 { margin-left: 4%; }
}
.slip { position: absolute; width: 74%; background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 18px 40px -24px rgba(21, 28, 38, .45); }
.slip::before { content: ""; position: absolute; top: 9px; left: 18px; right: 18px; height: 6px; background: radial-gradient(circle, var(--bg) 3px, transparent 3.5px) 0 0 / 16px 6px repeat-x; }
.slip-k { font-size: .82rem; color: var(--muted); margin-top: 6px; }
.slip-v { font-family: var(--mono); font-weight: 700; font-size: 2rem; line-height: 1.1; }
.slip-v small { font-family: var(--sans); font-size: .5em; margin: 0 4px; color: var(--ink); }
.slip.s1 { top: 0; left: 0; transform: rotate(-4deg); } .slip.s1 .slip-v { color: var(--c-work); }
.slip.s2 { top: 34%; right: 0; transform: rotate(3deg); z-index: 2; } .slip.s2 .slip-v { color: var(--c-money); }
.slip.s3 { bottom: 0; left: 8%; transform: rotate(-1.5deg); z-index: 3; } .slip.s3 .slip-v { color: var(--c-life); }
.cat-sec { display: flex; flex-direction: column; gap: 14px; padding-top: 18px; }
.cat-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.cat-head h2 { margin: 0; font-size: 1.35rem; font-weight: 900; display: flex; align-items: center; gap: 10px; }
.cat-head h2::before { content: ""; width: 12px; height: 12px; border-radius: 4px; background: var(--dot); }
.cat-head p { margin: 0; color: var(--muted); font-size: .92rem; }
.about { margin-top: 18px; }
