/* Understory: styles shared by about.html and the portfolio pages (edit here; the home page has its own inline styles) */
  :root {
    --bg: #FAF7EF;
    --surface: #F1EDE0;
    --ink: #23281F;
    --ink-soft: #565C4C;
    --ink-muted: #75725f;
    --moss: #3B6748;
    --sprout: #5E8443;
    --clay: #97693D;
    --border: rgba(35, 40, 31, 0.14);
    --border-strong: rgba(35, 40, 31, 0.30);
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --bg: #14180F; --surface: #1B2115; --ink: #EDE9DC; --ink-soft: #A9AF98; --ink-muted: #8a8f7c;
      --moss: #9BC985; --sprout: #C7DC9E; --clay: #D6A96F;
      --border: rgba(237, 233, 220, 0.14); --border-strong: rgba(237, 233, 220, 0.30);
    }
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #14180F; --surface: #1B2115; --ink: #EDE9DC; --ink-soft: #A9AF98; --ink-muted: #8a8f7c;
    --moss: #9BC985; --sprout: #C7DC9E; --clay: #D6A96F;
    --border: rgba(237, 233, 220, 0.14); --border-strong: rgba(237, 233, 220, 0.30);
  }

  * { box-sizing: border-box; }
  body { background: var(--bg); color: var(--ink); font-family: "Karla", -apple-system, "Noto Sans TC", "PingFang TC", sans-serif; line-height: 1.75; -webkit-font-smoothing: antialiased; }
  h1, h2, h3, .wordmark { font-family: "Fraunces", "Noto Serif TC", Georgia, serif; text-wrap: balance; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
  .mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }
  a { color: var(--moss); }
  a:focus-visible, button:focus-visible { outline: 2px solid var(--moss); outline-offset: 3px; }
  .wrap { max-width: 900px; margin: 0 auto; padding-inline: 24px; }

  .topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); }
  .topbar .wrap { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; max-width: 980px; }
  .topbar .wordmark { font-size: 20px; margin: 0; }
  .topbar .wordmark span { color: var(--sprout); }
  .topnav { display: flex; align-items: center; gap: 22px; list-style: none; margin: 0; padding: 0; }
  .topnav a, .topnav .sub-btn, .topnav .soon { font-family: "IBM Plex Mono", monospace; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); text-decoration: none; }
  .topnav a:hover, .topnav .sub-btn:hover, .topnav .sub-btn[aria-expanded="true"] { color: var(--moss); }
  .topnav .sub-btn { background: none; border: 0; padding: 0; cursor: pointer; }
  .topnav .sub-btn .caret { display: inline-block; margin-left: 4px; font-size: 10px; transition: transform .2s ease; }
  .topnav .sub-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }
  .topnav .has-sub { position: relative; }
  .topnav .sub { display: none; position: absolute; top: calc(100% + 14px); left: -16px; min-width: 250px; list-style: none; margin: 0; padding: 8px 0; background: var(--bg); border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12); }
  .topnav .sub.open { display: block; }
  .topnav .sub a, .topnav .sub .soon { display: block; padding: 8px 18px; text-transform: none; letter-spacing: 0; font-family: "Karla", -apple-system, "Noto Sans TC", "PingFang TC", sans-serif; font-size: 14.5px; }
  .topnav .sub a:hover { background: var(--chip-bg); }
  .topnav .soon { color: var(--ink-muted); cursor: default; }
  .topnav .soon em { font-style: normal; font-size: 10.5px; letter-spacing: 0.04em; margin-left: 8px; padding: 2px 8px; border-radius: 20px; background: var(--chip-bg); color: var(--moss); white-space: nowrap; }
  .topbar .wordmark a { color: inherit; text-decoration: none; }
  .menu-btn { display: none; font-family: "IBM Plex Mono", monospace; font-size: 12.5px; letter-spacing: 0.05em; color: var(--ink-soft); background: none; border: 1px solid var(--border-strong); border-radius: 20px; padding: 5px 14px; cursor: pointer; }
  .topnav a:focus-visible, .sub-btn:focus-visible, .menu-btn:focus-visible { outline: 2px solid var(--moss); outline-offset: 3px; border-radius: 2px; }
  @media (max-width: 860px) {
    .topbar .wrap { flex-wrap: wrap; padding: 12px 28px; }
    .menu-btn { display: inline-block; }
    .topnav { display: none; width: 100%; flex-direction: column; align-items: flex-start; gap: 0; padding: 10px 0 6px; }
    .topnav.open { display: flex; }
    .topnav > li { width: 100%; padding: 10px 0; border-top: 1px solid var(--border); }
    .topnav .sub { position: static; min-width: 0; margin-top: 6px; padding: 0 0 0 4px; border: 0; border-radius: 0; box-shadow: none; background: none; }
    .topnav .sub a, .topnav .sub .soon { padding: 8px 12px; }
  }
  .topnav a[aria-current="page"] { color: var(--moss); }

  .eyebrow, .kicker { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; letter-spacing: 0.12em; margin: 0 0 14px; }
  .eyebrow { color: var(--sprout); }
  .kicker { color: var(--clay); }

  .hero { padding-block: 60px 48px; border-bottom: 1px solid var(--border); }
  .hero h1 { font-size: clamp(26px, 4.4vw, 40px); line-height: 1.35; margin: 0 0 26px; max-width: 22em; }
  .hero h1 .ask { color: var(--moss); }
  .hero .lede { font-size: 16.5px; color: var(--ink-soft); max-width: 60ch; margin: 0; }

  section.block { padding-block: 52px; border-bottom: 1px solid var(--border); scroll-margin-top: 64px; }
  section.block h2 { font-size: 25px; margin: 0 0 12px; }
  .intro { font-size: 15px; color: var(--ink-soft); max-width: 60ch; margin: 0 0 28px; }

  .skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); }
  .skill { background: var(--bg); padding: 22px 22px 24px; display: flex; flex-direction: column; gap: 10px; }
  .skill h3 { font-family: "Karla", "Noto Sans TC", sans-serif; font-size: 15.5px; font-weight: 700; color: var(--moss); margin: 0; }
  .skill p { font-size: 13.5px; color: var(--ink-soft); margin: 0; line-height: 1.7; }
  .skill dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13.5px; }
  .skill dt { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; color: var(--clay); padding-top: 2px; }
  .skill dd { margin: 0; color: var(--ink-soft); }
  .skill .note { font-size: 12.5px; color: var(--ink-muted); border-top: 1px dashed var(--border-strong); padding-top: 10px; }
  .fields { margin: 18px 0 0; font-size: 14px; color: var(--ink-soft); }
  .fields strong { color: var(--ink); }

  .tools { margin-top: 28px; padding-top: 22px; border-top: 1px dashed var(--border-strong); }
  .tools h3 { font-family: "Karla", "Noto Sans TC", sans-serif; font-size: 15px; font-weight: 700; margin: 0 0 12px; color: var(--ink); }
  .tools dl { margin: 0; display: grid; grid-template-columns: 7em 1fr; gap: 10px 16px; align-items: baseline; }
  .tools dt { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; color: var(--clay); }
  .tools dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 8px; }
  .tools dd span { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12.5px; color: var(--ink); border: 1px solid var(--border-strong); border-radius: 3px; padding: 1px 8px; }
  .projects .head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
  .plink { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12.5px; text-decoration: none; border-bottom: 1px solid var(--border-strong); align-self: flex-start; padding-bottom: 1px; }
  .plink:hover { border-color: var(--moss); }
  .projects { list-style: none; margin: 0; padding: 0; }
  .projects li { display: grid; grid-template-columns: minmax(0, 27em) minmax(0, 1fr); align-items: start; gap: 24px; padding-block: 18px; border-top: 1px solid var(--border); }
  .projects li:last-child { border-bottom: 1px solid var(--border); }
  .projects .type { font-family: "Fraunces", "Noto Serif TC", serif; font-weight: 600; font-size: 16px; color: var(--ink); }
  .tags { display: flex; flex-wrap: wrap; gap: 6px 8px; }
  .tags span { font-size: 13px; color: var(--ink-soft); background: var(--surface); border: 1px solid var(--border); border-radius: 3px; padding: 2px 9px; }
  .after { margin: 20px 0 0; font-size: 14.5px; color: var(--ink-soft); max-width: 60ch; }

  .steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); counter-reset: step; }
  .steps li { background: var(--bg); padding: 18px 16px 20px; display: flex; flex-direction: column; gap: 6px; counter-increment: step; }
  .steps li::before { content: counter(step); font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; color: var(--sprout); }
  .steps h3 { font-family: "Karla", "Noto Sans TC", sans-serif; font-size: 14.5px; font-weight: 700; margin: 0; color: var(--ink); }
  .steps p { font-size: 13px; color: var(--ink-soft); margin: 0; line-height: 1.65; }
  .diag { margin-top: 20px; font-size: 14px; color: var(--ink-soft); border-left: 2px solid var(--sprout); padding-left: 14px; max-width: 62ch; }

  .why { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; max-width: 64ch; }
  .why li { display: grid; grid-template-columns: 9em 1fr; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
  .why li:last-child { border-bottom: 0; padding-bottom: 0; }
  .why strong { color: var(--moss); font-size: 15px; }
  .why span { font-size: 14.5px; color: var(--ink-soft); }

  .name-note { font-size: 14px; color: var(--ink-muted); max-width: 62ch; margin: 0; }

  .contact { padding-block: 52px 44px; }
  .contact h2 { font-size: 25px; margin: 0 0 10px; }
  .contact .lead { margin: 0 0 22px; color: var(--ink-soft); font-size: 15px; max-width: 58ch; }
  .mailbox { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
  .mailbox .addr { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 15px; user-select: all; }
  .mailbox button { font: 600 13px "Karla", "Noto Sans TC", sans-serif; color: var(--bg); background: var(--moss); border: 0; border-radius: 4px; padding: 6px 12px; cursor: pointer; }
  .links { display: flex; gap: 24px; margin-top: 20px; flex-wrap: wrap; }
  .links a { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 14px; text-decoration: none; border-bottom: 1px solid var(--border-strong); padding-bottom: 2px; }

  footer { padding-block: 28px 56px; border-top: 1px solid var(--border); }
  footer p { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; color: var(--ink-muted); margin: 0; }

  @media (max-width: 760px) {
    .steps { grid-template-columns: 1fr; }
  }
  @media (max-width: 680px) {
    .skills { grid-template-columns: 1fr; }
    .projects li { grid-template-columns: 1fr; gap: 8px; }
    .why li { grid-template-columns: 1fr; gap: 2px; }
  }
  /* portfolio pages */
  .pf-page .wrap { max-width: 980px; }
  .pf-page .hero h1 { max-width: 24em; }
  .eyebrow a { color: inherit; text-decoration: none; }
  .eyebrow a:hover { text-decoration: underline; }
  section.pf { padding-block: 12px 24px; }
  .pf-row { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 0 36px; padding-block: 34px; border-bottom: 1px solid var(--border); }
  .pf-row:last-child { border-bottom: 0; }
  .pf-info h2 { font-family: "Karla", "Noto Sans TC", sans-serif; font-size: 17px; font-weight: 700; color: var(--moss); margin: 0 0 8px; letter-spacing: 0; }
  .pf-info p { margin: 0 0 8px; font-size: 14px; line-height: 1.75; color: var(--ink-soft); }
  .pf-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: start; }
  .pf-grid.c1 { grid-template-columns: minmax(0, 460px); }
  .pf-grid.c2, .pf-grid.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pf-item { margin: 0; min-width: 0; }
  .pf-item > a, .pf-item > .yt { display: block; position: relative; overflow: hidden; border-radius: 4px; border: 1px solid var(--border-strong); background: var(--surface); }
  .pf-item img { display: block; width: 100%; height: auto; transition: transform .35s ease; }
  .pf-item > a:hover img { transform: scale(1.03); }
  .pf-item > a.ph { cursor: zoom-in; }
  .pf-item > a.out { cursor: alias; }
  .pf-item figcaption { margin-top: 8px; font-size: 13px; line-height: 1.65; color: var(--ink-soft); }
  .yt { width: 100%; padding: 0; cursor: pointer; font: inherit; aspect-ratio: 16 / 9; }
  .yt img { height: 100%; object-fit: cover; }
  .yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
  .yt-play { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%; background: rgba(20, 24, 15, 0.62); border: 2px solid rgba(255, 255, 255, 0.9); transition: background .2s ease; }
  .yt-play::after { content: ""; position: absolute; left: 23px; top: 17px; border-style: solid; border-width: 12px 0 12px 20px; border-color: transparent transparent transparent #fff; }
  .yt:hover .yt-play { background: color-mix(in srgb, var(--moss) 90%, transparent); }
  .back { margin: 26px 0 0; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 13px; }
  .back a { text-decoration: none; border-bottom: 1px solid var(--border-strong); padding-bottom: 2px; }
  .back a:hover { border-color: var(--moss); }
  @media (max-width: 760px) {
    .pf-row { grid-template-columns: minmax(0, 1fr); gap: 14px 0; }
    .pf-grid, .pf-grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pf-grid.c1, .pf-grid.wide { grid-template-columns: minmax(0, 1fr); }
  }
  @media (prefers-reduced-motion: reduce) { .pf-item img, .yt-play { transition: none; } .pf-item > a:hover img { transform: none; } }

  /* photo viewer (opened by assets/js/lightbox.js) */
  dialog.lb { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
  dialog.lb::backdrop { background: rgba(12, 14, 9, 0.95); }
  .lb-inner { position: relative; width: 100%; height: 100%; display: grid; place-items: center; padding: 56px 12px 64px; }
  .lb img { max-width: min(100%, 1280px); max-height: calc(100vh - 130px); max-height: calc(100dvh - 130px); width: auto; height: auto; object-fit: contain; border-radius: 3px; box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5); }
  .lb-cap { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; color: #e8e6dc; font-size: 14px; padding: 0 60px; }
  .lb-cap .mono { color: #b6b9a8; font-size: 12.5px; margin-left: 8px; }
  .lb button { position: absolute; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.28); background: rgba(0, 0, 0, 0.35); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
  .lb button:hover { background: rgba(255, 255, 255, 0.16); }
  .lb button:focus-visible { outline: 2px solid #fff; }
  .lb .x { top: 10px; right: 10px; }
  .lb .prev { left: 10px; top: 50%; transform: translateY(-50%); }
  .lb .next { right: 10px; top: 50%; transform: translateY(-50%); }
  @media (max-width: 640px) { .lb .prev { left: 4px; } .lb .next { right: 4px; } }

  /* product pages (products/<slug>/) */
  .prose { max-width: 64ch; }
  .prose p { margin: 0 0 16px; }
  .prose p:last-child { margin-bottom: 0; }
  .prose strong { color: var(--moss); font-weight: 700; }
  .product { padding: 64px 0; border-bottom: 1px solid var(--border); scroll-margin-top: 64px; }
  .product h2 { font-size: 30px; margin: 12px 0 22px; }
  .product .status-chip { margin-bottom: 0; }
  .feature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); margin: 30px 0; }
  .feature { background: var(--bg); padding: 20px 22px; }
  .feature h3 { font-family: "Karla", sans-serif; font-size: 14.5px; font-weight: 700; color: var(--moss); margin: 0 0 8px; text-transform: none; letter-spacing: 0; }
  .feature p { font-size: 13.5px; color: var(--ink-soft); margin: 0; }
  .screens-block { margin: 30px 0; }
  .screens-block .chart-title { font-family: "IBM Plex Mono", monospace; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); margin: 0 0 18px; }
  .screens-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .screen-shot { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); }
  .screen-shot img { display: block; width: 100%; height: auto; }
  .screen-shot p { margin: 0; padding: 8px 10px; font-size: 11.5px; color: var(--ink-muted); text-align: center; border-top: 1px solid var(--border); }
  .chart-caption { font-size: 11.5px; color: var(--ink-muted); margin: 14px 0 0; font-style: italic; }
  .reference-note { font-size: 13px; color: var(--ink-muted); border-left: 2px solid var(--border-strong); padding-left: 16px; margin: 26px 0; }
  .callout { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 20px 24px; margin-top: 28px; font-size: 14px; color: var(--ink-soft); }
  .callout strong { color: var(--ink); }
  .callout.open { border-color: var(--clay); }
  .cta-btn { display: inline-block; margin-top: 14px; margin-right: 10px; padding: 10px 20px; background: var(--moss); color: var(--bg); text-decoration: none; border-radius: 3px; font-size: 13.5px; font-weight: 700; }
  .cta-btn:hover { opacity: 0.9; }
  .cta-btn.secondary { background: transparent; color: var(--moss); border: 1px solid var(--border-strong); }
  .cta-row { margin-top: 14px; }
  .callout .fine-print { display: block; margin-top: 14px; font-size: 12.5px; color: var(--ink-muted); }
  .product h1 { font-size: 30px; margin: 12px 0 22px; }
  .product .back { margin-top: 30px; }
  @media (max-width: 720px) { .screens-grid { grid-template-columns: repeat(2, 1fr); } }
  @media (max-width: 680px) { .feature-grid { grid-template-columns: 1fr; } }

  /* AppSheet overview (products/) */
  .points-title { font-family: "Karla", "Noto Sans TC", sans-serif; font-size: 15px; font-weight: 700; color: var(--ink); margin: 26px 0 10px; letter-spacing: 0; text-transform: none; }
  .points { margin: 0 0 24px; padding-left: 1.2em; max-width: 60ch; font-size: 15px; color: var(--ink-soft); }
  .points li { margin: 0 0 6px; }
  .points strong { color: var(--moss); font-weight: 700; }
  .teaser-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); margin-top: 40px; }
  .teaser { background: var(--bg); padding: 24px 26px; text-decoration: none; display: block; }
  .teaser-row .teaser:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .teaser .tname { font-size: 20px; margin: 0 0 8px; color: var(--ink); }
  .teaser p { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 10px; }
  .status-chip { display: inline-block; font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; background: var(--chip-bg); color: var(--moss); padding: 3px 9px; border-radius: 20px; }
  .status-chip.open { background: var(--chip-bg-open); color: var(--clay); }
  .topnav .sub-btn { padding: 0 2px; }
  @media (max-width: 680px) { .teaser-row { grid-template-columns: 1fr; } }

  /* chip colours (the home page defines the same tokens in its own :root) */
  :root { --chip-bg: rgba(59, 103, 72, 0.10); --chip-bg-open: rgba(169, 124, 79, 0.16); }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --chip-bg: rgba(155, 201, 133, 0.12); --chip-bg-open: rgba(214, 169, 111, 0.18); }
  }
  :root[data-theme="dark"] { --chip-bg: rgba(155, 201, 133, 0.12); --chip-bg-open: rgba(214, 169, 111, 0.18); }

  /* language switcher and Japanese type */
  .topnav .langs { font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: 0.04em; color: var(--ink-muted); margin-left: 6px; padding-left: 14px; border-left: 1px solid var(--border-strong); white-space: nowrap; }
  .topnav .langs a { color: var(--ink-muted); text-transform: none; }
  .topnav .langs a[aria-current="true"] { color: var(--moss); font-weight: 700; }
  @media (max-width: 860px) { .topnav .langs { margin-left: 0; padding-left: 0; border-left: 0; } }
  html[lang="ja"] body { font-family: "Karla", "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", sans-serif; }
  html[lang="ja"] h1, html[lang="ja"] h2, html[lang="ja"] h3, html[lang="ja"] .wordmark { font-family: "Fraunces", "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif; }
