/* W2 shell. Paper, ink, lacquer. Page bodies keep their existing class names. */

body {
  font-family: "Be Vietnam Pro", system-ui, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: 96px;
}
h1, h2, .brand strong, .display {
  font-family: "Source Serif 4", "Be Vietnam Pro", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}
a { color: var(--link, var(--seal)); }
a:hover { text-decoration: underline; }
.skip {
  position: absolute;
  left: 12px;
  top: 0;
  transform: translateY(-120%);
  background: var(--seal);
  color: var(--seal-ink);
  padding: 10px 14px;
  z-index: 20;
  border-radius: 12px;
}
.skip:focus { transform: none; top: 12px; }
:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.site-header {
  background: color-mix(in srgb, var(--card) 92%, var(--bg));
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
/* Brand length: full name by default; short name in mid desktop (see ≥801). */
.brand .brand-full { display: block; }
.brand .brand-short { display: none; }
.site-header a, .site-header button { color: var(--ink); }
.header-row { padding: 12px 0; align-items: center; display: flex; gap: 12px 16px; }
@media (min-width: 801px) {
  /* Opaque sticky backdrop so crumbs/title never show through the floating pill
     (real overlap on scroll and on wide full-page captures). */
  .site-header {
    background: var(--bg, var(--surface));
    border-bottom: 0;
    padding-bottom: 8px;
  }
  .header-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px 10px;
    height: 64px;
    max-width: 100%;
    margin-top: 10px;
    padding: 0 10px 0 10px;
    background: color-mix(in srgb, var(--card) 92%, var(--bg));
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 6%, transparent);
    overflow: visible;
  }
  .brand { flex: 0 1 auto; min-width: 0; }
  .brand small { display: none; }
  .brand strong {
    white-space: nowrap;
    font-size: 16px;
    /* No ellipsis — truncation would pass overflow gates but fail scrollWidth checks. */
    overflow: visible;
    max-width: none;
  }
  /* HOME2: mid desktop widths use the short brand so the full name never clips. */
  .brand .brand-full { display: none; }
  .brand .brand-short { display: block; }
  /* Keep the seal search button inside its flex slot so it cannot
     peek through the rounded left corner of the Hôm nay nav pill. */
  .site-search {
    flex: 0 0 auto;
    min-width: 0;
    max-width: 220px; /* fits placeholder "Tìm công cụ" + seal button */
    overflow: hidden;
    position: relative;
    z-index: 0;
  }
  .nav {
    /* Size to children, sit on the right. flex-start so any leftover
       squeeze overflows RIGHT — flex-end was painting the Hôm nay pill
       over the seal search button (red crescent on the left curve).
       Keep position:static so .mega-panel can anchor to .header-row. */
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    min-width: 0;
    flex: 0 0 auto;
    justify-content: flex-start;
    position: static;
    z-index: 1;
  }
  .nav-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg) 72%, var(--card));
    border: 1px solid var(--line);
    isolation: isolate;
  }
  .nav-group a, .nav-group summary { min-height: 34px; padding: 0 9px; border-radius: 999px; font-size: 13.5px; }
  .site-search input {
    width: 100%;
    min-width: 0;
    max-width: none;
    flex: 1 1 auto;
    min-height: 36px;
    border-radius: 999px;
  }
  .site-search button {
    min-height: 36px;
    min-width: 36px;
    width: 36px;
    border-radius: 999px;
    flex: 0 0 36px;
  }
  .theme-open {
    border: 0;
    background: transparent;
    border-radius: 999px;
    flex: 0 0 auto;
    max-width: 100%;
  }
  .theme-open .theme-word {
    /* Full label when shown (≥1360); icon-only below that — never ellipsize mid-word. */
    white-space: nowrap;
  }
  .nav-desktop a, .nav-desktop summary, .lang, .site-header button { white-space: nowrap; }
}
/* Below 1360: icon-only theme — text "Đổi nền" was truncating to "Đổi …"
   and squeezing search ("Tìm công cụ" → "Tìm công"). Truncation ≠ overflow. */
@media (min-width: 801px) and (max-width: 1359px) {
  .theme-open .theme-word { display: none; }
  /* flex:0 so nav cannot squeeze the search below the full placeholder width. */
  .header-row .site-search {
    flex: 0 0 auto;
    min-width: 188px;
    max-width: 220px;
  }
  .header-row .site-search input {
    max-width: none;
    min-width: 140px;
    text-overflow: clip;
  }
  .nav-group a, .nav-group summary { padding: 0 8px; font-size: 13.5px; }
}
@media (min-width: 801px) and (max-width: 1100px) {
  .header-row .site-search { min-width: 176px; max-width: 200px; }
  .header-row .site-search input { min-width: 128px; }
  .nav-group a, .nav-group summary { padding: 0 7px; font-size: 13px; }
  .header-row .brand strong { font-size: 15px; }
}
@media (min-width: 1280px) {
  .brand .brand-full { display: block; }
  .brand .brand-short { display: none; }
}
.brand { color: var(--ink); text-decoration: none; }
.brand small { color: var(--muted); }
.mark { width: 36px; height: 36px; color: var(--seal-ink); display: block; }
.mark .mark-seal { fill: var(--seal); }
.mark svg { width: 36px; height: 36px; display: block; }
.nav a { font-weight: 600; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.nav button, .icon-button, .site-search button {
  min-height: 44px;
  min-width: 44px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.site-search { display: flex; gap: 6px; align-items: center; }
.site-search input {
  width: min(220px, 42vw);
  min-height: 44px;
  background: var(--card);
}
.site-search button { background: var(--seal); color: var(--seal-ink); border-color: var(--seal); }
/* Desktop re-assert AFTER the base 44px rules — otherwise the seal
   search button stays 44×44/radius-12 and kisses the Hôm nay pill. */
@media (min-width: 801px) {
  .header-row .site-search {
    flex: 0 0 auto;
    min-width: 188px;
    max-width: 220px;
    margin-right: 8px; /* gap before Hôm nay pill — no seal bleed through radius */
    overflow: hidden;
    position: relative;
    z-index: 0;
    isolation: isolate;
  }
  .header-row .site-search input {
    min-height: 36px;
    border-radius: 999px;
  }
  .header-row .site-search button {
    min-height: 36px;
    max-height: 36px;
    min-width: 36px;
    max-width: 36px;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    flex: 0 0 36px;
  }
  .header-row .nav {
    flex: 0 0 auto;
    margin-left: auto;
    justify-content: flex-start;
    position: static;
    z-index: 1;
  }
  .header-row .nav-group a,
  .header-row .nav-group summary {
    min-height: 34px;
  }
}
.icon { width: 20px; height: 20px; display: inline-flex; }
.icon svg { width: 20px; height: 20px; }
.mega { position: static; }
.mega summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.mega summary::-webkit-details-marker { display: none; }
.mega:not([open]) > .mega-panel { display: none; }
.mega-panel {
  /* Anchored to .header-row (position:relative), full pill width. */
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px 12px;
  display: block;
  box-shadow: 0 12px 40px color-mix(in srgb, var(--ink) 12%, transparent);
  z-index: 40;
  max-height: min(70vh, 560px);
  overflow-x: hidden;
  overflow-y: auto;
}
.mega-panel h2 { font-size: 0.95rem; margin: 0 0 6px; }
.mega-panel ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mega-panel a { text-decoration: none; color: var(--ink); font-weight: 500; }
.mega-panel a:hover { color: var(--link-hover, var(--seal)); }
.lang { text-decoration: none; font-weight: 700; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.crumbs { font-size: 0.95rem; margin: 0 0 12px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--seal); }
.crumbs [aria-current="page"] { color: var(--ink); font-weight: 600; }
.site-footer {
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 70%, var(--bg));
  color: var(--muted);
  padding: 28px 0 36px;
  overflow-x: clip;
}
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 18px; min-width: 0; }
.footer-grid h2 { font-size: 1rem; color: var(--ink); margin: 0 0 8px; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.footer-grid a { color: var(--ink); text-decoration: none; }
.footer-note { margin-top: 18px; }
.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
  justify-content: space-around;
  gap: 4px;
}
.bottom-nav a, .bottom-nav button {
  flex: 1;
  min-height: 44px;
  min-width: 44px;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  padding: 4px;
}
.bottom-nav .is-on { color: var(--seal); }
.theme-dialog {
  width: min(560px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  padding: 16px;
}
.theme-dialog::backdrop { background: color-mix(in srgb, var(--ink) 45%, transparent); }
.theme-dialog header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; }
.theme-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  min-height: 44px;
}
.theme-choice[aria-pressed="true"] { border-color: var(--seal); }
.swatch {
  width: 44px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Source Serif 4", serif;
}
.bloom { position: absolute; right: 12px; top: 8px; width: 72px; color: var(--seal); opacity: 0.55; pointer-events: none; }
[data-theme="muc"] .bloom, [data-theme="dark"] .bloom, [data-theme="go"] .bloom { display: none; }
[data-theme="son"] .site-header { border-bottom: 3px solid var(--seal); }
[data-theme="go"] .site-header {
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0 12px,
    color-mix(in srgb, var(--ink) 8%, transparent) 12px 13px
  );
}
.cell small, .cell em { font-size: 13px; }
.day-card, .panel, .stack, .picker, .month-card {
  background: var(--card);
  border-color: var(--line);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 4%, transparent);
}
.error-card { max-width: 36rem; }
.c-hero, .c-card, .c-gauge, .c-reader, .c-tree, .c-wheel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin: 12px 0;
}
.c-num {
  font-family: "Source Serif 4", "Be Vietnam Pro", serif;
  font-variant-numeric: tabular-nums;
  font-size: clamp(64px, 12vw, 112px);
  line-height: 0.9;
  margin: 0;
  color: var(--seal);
}
.c-row { display: flex; flex-wrap: wrap; gap: 8px; }
.c-chip, .filters a, .filters button {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--ink);
  padding: 6px 12px;
  min-height: 44px;
  text-decoration: none;
  font: inherit;
}
.c-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.c-grid a { min-height: 44px; text-decoration: none; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.c-hours { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.c-hours li { display: flex; justify-content: space-between; gap: 8px; min-height: 44px; align-items: center; }
.c-hours .is-open { box-shadow: inset 3px 0 0 var(--good); }
.icon-set { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-set figure { width: 72px; margin: 0; text-align: center; color: var(--muted); font-size: 13px; }
.icon-set svg, .icon-set img { width: 32px; height: 32px; color: var(--ink); }
.search-open { display: none; }
.search-sheet {
  width: min(640px, calc(100% - 24px));
  border: 0;
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  padding: 16px;
}
.search-sheet::backdrop { background: color-mix(in srgb, var(--ink) 46%, transparent); }
.search-sheet form { display: flex; flex-wrap: wrap; gap: 8px; }
.search-sheet input { flex: 1 1 180px; min-height: 48px; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font: inherit; }
.theme-open { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 800px) {
  .nav-desktop { display: none; }
  .bottom-nav { display: flex; }
  .mega { display: none; }
  .mega-panel { position: static; width: auto; box-shadow: none; }
  .header-row { flex-wrap: nowrap; height: 56px; min-height: 56px; padding: 0; gap: 6px; }
  .brand { min-width: 0; flex: 0 1 auto; max-width: calc(100% - 9.5rem); }
  .brand small, .theme-word, .site-search { display: none; }
  .brand .brand-full { display: none; }
  .brand .brand-short {
    display: block;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(42vw, 11rem);
  }
  .mark, .mark svg { width: 32px; height: 32px; flex: none; }
  .search-open { display: inline-flex; margin-left: auto; flex: 0 0 auto; }
  .nav { flex-wrap: nowrap; gap: 0; flex: 0 0 auto; }
  .site-header .nav button, .lang, .search-open, .drawer-open { border: 0; background: transparent; padding: 0; }
  .search-sheet { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; border-radius: 0; background: var(--bg); }
}
/* Narrow phones: logo only — title was painting under the search icon (UI2R). */
@media (max-width: 400px) {
  .brand strong, .brand .brand-full, .brand .brand-short { display: none; }
  .brand { max-width: none; }
}
@media (min-width: 801px) {
  body { padding-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .bloom { display: none !important; }
}
@media print {
  .bottom-nav, .theme-dialog, .site-search, .bloom, .mega { display: none !important; }
}
.print-sheet .bottom-nav,
.print-sheet .theme-dialog,
.print-sheet .site-header,
.print-sheet .site-footer,
.print-sheet .crumbs { display: none !important; }
.print-sheet body, body.print-sheet { padding-bottom: 0; background: #fff; color: #1c1712; }
