/* =============================================================================
   CFT shells (02_design_system.md §7). One container per surface (`.app`), so
   the same rules drive the mockup frames and the real pages. Bars are sticky,
   never fixed. Build note: production may swap @container for @media at the
   same breakpoints; the behaviour must not change.
   ============================================================================= */

.app { container: app / inline-size; background: var(--cft-bg); color: var(--cft-ink); min-height: 100%; position: relative; }

/* ── Public header ──────────────────────────────────────────────────────── */
.pub-top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--cft-bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--cft-border); }
.pub-in { max-width: var(--cft-content); margin: 0 auto; padding: 0 var(--cft-gutter); height: 68px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--cft-ink); line-height: 1.05; flex: none; }
.brand b { font-family: var(--cft-serif); font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.brand small { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--cft-accent-text); font-weight: 700; }
.pub-links { display: flex; align-items: center; gap: 18px; margin-left: 8px; }
.pub-links > a, .pub-links .drop-t { text-decoration: none; color: var(--cft-ink); font-size: var(--cft-fs-sm); font-weight: 600; padding: 6px 0; position: relative; }
.pub-links > a::after { content: ""; position: absolute; left: 0; right: 100%; bottom: 0; height: 2px; background: var(--cft-accent); transition: right var(--cft-dur); }
.pub-links > a:hover::after, .pub-links > a[aria-current]::after { right: 0; }
.pub-links .drop-c { left: 50%; right: auto; transform: translate(-50%, -6px); }
.pub-links .drop:hover .drop-c, .pub-links .drop:focus-within .drop-c { transform: translate(-50%, 0); }
.pub-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.locale-t { border: 1px solid var(--cft-border-strong) !important; border-radius: var(--cft-r-pill); padding: 6px 12px !important; }
.pub-burger { display: none; }
@container app (max-width: 991.98px) {
  .pub-links, .pub-tools .hide-sm { display: none; }
  .pub-burger { display: inline-flex; }
  .pub-in { height: 60px; gap: 10px; }
}
@container app (max-width: 480px) {
  .pub-in { gap: 6px; }
  .pub-tools { gap: 4px; }
  .pub-tools .btn-accent { padding: 0 12px; }
  .pub-top .brand { min-width: 0; flex: 1 1 auto; }
  .pub-top .brand b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand small { display: none; }
}
@container app (max-width: 360px) { .pub-tools .btn-accent span { display: none; } }
.pub-drawer { position: absolute; inset: 60px 0 0 0; z-index: 25; background: var(--cft-bg); padding: var(--cft-s4) var(--cft-gutter); overflow: auto; }
.pub-drawer nav a { display: flex; justify-content: space-between; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--cft-border); color: var(--cft-ink); text-decoration: none; font-weight: 600; }
.pub-drawer h6 { margin: 22px 4px 8px; font: 700 11px var(--cft-sans); text-transform: uppercase; letter-spacing: .1em; color: var(--cft-muted); }
.lang-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.lang-list a { display: flex; flex-direction: column; padding: 10px 12px; border: 1px solid var(--cft-border); border-radius: var(--cft-r-md); text-decoration: none; color: var(--cft-ink); background: var(--cft-surface); }
.lang-list a b { font-family: var(--cft-serif); }
.lang-list a i { font-style: italic; font-size: var(--cft-fs-xs); color: var(--cft-accent-text); }
.lang-list a[aria-current] { border-color: var(--cft-primary); box-shadow: inset 0 0 0 1px var(--cft-primary); }
.hero { position: relative; min-height: 340px; display: grid; align-items: end; color: #fff; overflow: hidden; }
.hero .bg { position: absolute; inset: 0; background: linear-gradient(160deg, #1e5a52 0%, #12271f 55%, #3b2f12 100%); }
.hero .in { position: relative; max-width: var(--cft-content); width: 100%; margin: 0 auto; padding: 40px var(--cft-gutter); }
.hero h1 { color: #fff; font-size: var(--cft-fs-hero); max-width: 14ch; }
.hero .dots { display: flex; gap: 6px; margin-top: 18px; }
.hero .dots i { width: 22px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.4); }
.hero .dots i.on { background: var(--cft-accent); }

/* ── Console shell: admin, portal, media share the frame ──────────────────── */
.con { display: grid; grid-template-columns: var(--cft-sidebar) minmax(0, 1fr); grid-template-rows: var(--cft-topbar) minmax(0, 1fr); min-height: 100dvh; }
.con-top { grid-column: 1 / -1; position: sticky; top: var(--cft-offset, 0px); z-index: 20; display: flex; align-items: center; gap: 12px; padding: 0 var(--cft-s4); background: var(--cft-surface); border-bottom: 1px solid var(--cft-border); }
.con-top .brand b { font-size: 17px; }
.surface-tag { font: 700 10px/1 var(--cft-sans); letter-spacing: .12em; text-transform: uppercase; padding: 4px 7px; border-radius: 4px; background: var(--cft-primary); color: var(--cft-on-primary); }
.surface-tag.portal { background: var(--cft-chart-1); color: #fff; }
.surface-tag.media { background: var(--cft-chart-3); color: #fff; }
.con-search { flex: 1; max-width: 460px; margin-left: 12px; position: relative; }
.con-search .form-control { min-height: 36px; padding-left: 34px; padding-right: 72px; text-overflow: ellipsis; background: var(--cft-bg); font-size: var(--cft-fs-sm); }
.con-search .ti { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--cft-muted); }
.con-search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.con-top .r { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* Admin workspaces (approved variant B): tabs in the top bar, pages in the sidebar */
.ws-tabs { display: flex; align-self: stretch; gap: 2px; margin-left: 10px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.ws-tabs a { display: flex; align-items: center; gap: 7px; padding: 0 12px; text-decoration: none; color: var(--cft-muted); font-weight: 600; font-size: var(--cft-fs-sm); white-space: nowrap;
  border-top: 3px solid transparent; border-bottom: 3px solid transparent; }
.ws-tabs a:hover { color: var(--cft-ink); background: var(--cft-surface-2); }
.ws-tabs a[aria-current] { color: var(--cft-ink); border-bottom-color: var(--cft-accent); }
.ws-tabs .ti { font-size: 17px; }
.search-btn { gap: 10px; color: var(--cft-muted); border-color: var(--cft-border) !important; }
.side-title { margin: 4px 10px 10px; font: 600 var(--cft-fs-lg)/1.2 var(--cft-serif); }
.nav-sub { margin: 14px 10px 4px; font: 700 10.5px/1 var(--cft-sans); text-transform: uppercase; letter-spacing: .09em; color: var(--cft-muted); }
.ws-grid { display: none; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px 4px 12px; margin-bottom: 8px; border-bottom: 1px solid var(--cft-border); }
.ws-grid a { display: flex; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--cft-border); border-radius: var(--cft-r-md); text-decoration: none; color: var(--cft-ink); font-weight: 600; font-size: var(--cft-fs-sm); background: var(--cft-surface); }
.ws-grid a[aria-current] { border-color: var(--cft-primary); box-shadow: inset 0 0 0 1px var(--cft-primary); background: var(--cft-soft); }
.ws-grid a .count { margin-left: auto; }
.con-burger { display: none; }
/* The sidebar fills the column from the top bar to the bottom of the window (flex column), so its footer — version + changelog — always sits at the very bottom. */
.con-side { position: sticky; top: calc(var(--cft-topbar) + var(--cft-offset, 0px)); align-self: start; display: flex; flex-direction: column; height: calc(100dvh - var(--cft-topbar) - var(--cft-offset, 0px)); overflow: auto; background: var(--cft-surface); border-right: 1px solid var(--cft-border); padding: var(--cft-s3) var(--cft-s2) 0; }
.nav-group { margin-bottom: 6px; }
.nav-group > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; font: 700 11px var(--cft-sans); text-transform: uppercase; letter-spacing: .09em; color: var(--cft-muted); border-radius: var(--cft-r-sm); }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary .chev { margin-left: auto; transition: transform var(--cft-dur); }
.nav-group[open] > summary .chev { transform: rotate(90deg); }
.side-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 1px 0; border-radius: var(--cft-r-sm); color: var(--cft-ink); text-decoration: none; font-size: var(--cft-fs-sm); font-weight: 500; position: relative; }
.side-item:hover { background: var(--cft-surface-2); }
.side-item[aria-current] { background: var(--cft-soft); font-weight: 700; }
.side-item[aria-current]::before { content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 3px; border-radius: 2px; background: var(--cft-accent); }
.side-item .ti { font-size: 18px; color: var(--cft-muted); flex: none; }
.side-item[aria-current] .ti { color: var(--cft-ink); }
.side-item .count { margin-left: auto; }
.side-item .ext { margin-left: auto; font-size: 14px; }
.con-main { min-width: 0; padding: var(--cft-s6); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: var(--cft-s4); }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--cft-muted); }
.page-head .r { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.side-foot { margin-top: auto; padding: 12px 10px;  font-size: var(--cft-fs-xs); color: var(--cft-muted); border-top: 1px solid var(--cft-border); display: flex; align-items: center; gap: 8px; }
.side-foot a { color: var(--cft-muted); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.side-foot a:hover { color: var(--cft-ink); text-decoration: underline; }
.con-side > .side-spacer { flex: 1 1 auto; }

/* Tablet: icon rail (labels move into tooltips; groups become dividers) */
@container app (max-width: 1199.98px) {
  .con { grid-template-columns: var(--cft-rail) minmax(0, 1fr); }
  .con-side { padding: var(--cft-s2) 8px; overflow: visible; }
  .con-side .nav-group > summary { font-size: 0; padding: 4px 0; border-top: 1px solid var(--cft-border); border-radius: 0; margin: 6px 4px; pointer-events: none; }
  .con-side .nav-group > summary .chev { display: none; }
  .con-side .nav-group:first-child > summary { border-top: 0; }
  .con-side .side-item { justify-content: center; padding: 10px 0; }
  .con-side .side-item > span:not(.count), .con-side .side-item .ext { display: none; }
  .con-side .side-item .count { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; font-size: 9.5px; padding: 0 4px; }
  .con-side .side-item[aria-current]::before { left: -8px; }
  .con-side .side-item:hover::after { content: attr(data-label); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); white-space: nowrap; background: var(--cft-ink); color: var(--cft-bg); font-size: 12px; padding: 4px 8px; border-radius: 5px; z-index: 40; }
  .con-side .side-foot { display: none; }
  .con-search { max-width: 300px; }
  .ws-tabs a { padding: 0 9px; }
  .ws-tabs a .ti { display: none; }
  .search-btn .lbl, .search-btn kbd { display: none; }
  .con-side .side-title, .con-side .nav-sub { display: none; }
}
/* Phone: top bar + drawer (admin) or bottom tab bar (portal, media) */
@container app (max-width: 767.98px) {
  .con { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--cft-topbar) minmax(0, 1fr) auto; }
  .con-side { display: none; }
  .con-burger { display: inline-flex; }
  .con-search { display: none; }
  .con-main { padding: var(--cft-s4) var(--cft-gutter); }
  .con.drawer-open .con-side { display: flex; height: auto; position: absolute; z-index: 30; top: var(--cft-topbar); left: 0; bottom: 0; width: min(300px, 86%); max-height: none; padding: var(--cft-s3) var(--cft-s2); box-shadow: var(--cft-shadow-lg); }
  .con.drawer-open .con-side .nav-group > summary { font-size: 11px; pointer-events: auto; border: 0; margin: 0; padding: 8px 10px; }
  .con.drawer-open .con-side .side-item { justify-content: flex-start; padding: 10px; }
  .con.drawer-open .con-side .side-item > span:not(.count), .con.drawer-open .con-side .side-item .ext { display: inline; }
  .con.drawer-open .con-side .side-item .count { position: static; margin-left: auto; }
  .con.drawer-open .con-side .side-title, .con.drawer-open .con-side .nav-sub { display: block; }
  .con.drawer-open .con-side .ws-grid { display: grid; }
  .ws-tabs { display: none; }
  .con.drawer-open::after { content: ""; position: absolute; inset: var(--cft-topbar) 0 0 0; background: var(--cft-scrim); z-index: 25; }
  .app .tabbar { display: grid; }  /* .app raises specificity over the base rule below */
  .has-tabbar .con-burger { display: none; }
}
.tabbar { display: none; grid-column: 1 / -1; position: sticky; bottom: 0; z-index: 20; grid-auto-flow: column; grid-auto-columns: 1fr; height: var(--cft-tabbar); background: var(--cft-surface); border-top: 1px solid var(--cft-border); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--cft-muted); font-size: 11px; font-weight: 600; position: relative; }
.tabbar a .ti { font-size: 22px; }
.tabbar a[aria-current] { color: var(--cft-ink); }
.tabbar a[aria-current]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--cft-accent); }
.tabbar .fab { align-self: center; justify-self: center; width: 52px; height: 52px; margin-top: -22px; border-radius: 50%; background: var(--cft-accent); color: var(--cft-on-accent); box-shadow: var(--cft-shadow-lg); }
.tabbar .fab .ti { font-size: 26px; }
.tabbar .count { position: absolute; top: 6px; left: 55%; }

/* ── Media library (Google Photos-like) ───────────────────────────────────── */
.day { margin-bottom: var(--cft-s6); }
.day-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; position: sticky; top: var(--cft-topbar); background: var(--cft-bg); padding: 6px 0; z-index: 5; }
.day-head h3 { margin: 0; font-family: var(--cft-sans); font-size: var(--cft-fs-md); }
.grid-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
@container app (max-width: 767.98px) { .grid-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; } .tile .flag .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* still read aloud */ .tile .flag { padding: 4px; } }
.selbar { position: sticky; top: var(--cft-topbar); z-index: 15; display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin: -8px 0 12px; background: var(--cft-primary); color: var(--cft-on-primary); border-radius: var(--cft-r-md); }
.selbar .btn-ghost { color: var(--cft-on-primary); }
.upq { display: grid; gap: 10px; }
.upq .upq-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.upq .thumb { width: 44px; height: 44px; border-radius: 6px; background: var(--cft-surface-2); }
.upq .name { font-size: var(--cft-fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.side-foot.stack-foot { display: block; }
