/* Base reset + app layout. Uses logical properties so RTL/LTR flip automatically. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: var(--fs-md);
  line-height: 1.55;
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0 0 var(--sp-3); line-height: 1.25; color: var(--starlight); }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--blue); }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== Shell ===== */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--sp-3);
  padding-inline: var(--sp-4);
  background: var(--starlight); color: var(--text-on-dark);
}
.brand { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; color: inherit; text-decoration: none; }
/* Text placeholder only — the official logo file replaces this when supplied (see ADR-003). */
.brand__mark { font-family: var(--font-en-head); font-weight: 800; letter-spacing: .08em; color: var(--sand); font-size: var(--fs-lg); }
.brand__name { font-size: var(--fs-sm); opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header__spacer { flex: 1; }
.header .btn--ghost { color: var(--text-on-dark); border-color: rgba(255,255,255,.35); }

.layout { flex: 1; display: flex; min-width: 0; }

.sidebar { display: none; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.nav-link {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--tap); padding-inline: var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text); text-decoration: none;
}
.nav-link:hover { background: var(--starlight-10); }
.nav-link[aria-current="page"] { background: var(--starlight); color: var(--text-on-dark); }
.nav-link__icon { width: 20px; height: 20px; flex: none; }
.nav-link__label { flex: 1; min-width: 0; }

.main { flex: 1; min-width: 0; padding: var(--sp-4); padding-bottom: calc(var(--bottomnav-h) + var(--sp-5)); }
.page { max-width: 1100px; margin-inline: auto; }
.page__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.page__head h1 { margin: 0; }
.grid { display: grid; gap: var(--sp-4); grid-template-columns: 1fr; }

/* Bottom nav (mobile) */
.bottomnav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  height: var(--bottomnav-h);
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav__item {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: 0; cursor: pointer;
  color: var(--text-muted); text-decoration: none; font: inherit; font-size: var(--fs-xs);
}
.bottomnav__item[aria-current="page"] { color: var(--starlight); font-weight: 700; box-shadow: inset 0 3px 0 var(--sand); }
.bottomnav__item svg { width: 22px; height: 22px; }
.bottomnav__item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-inline: 2px; }

/* Desktop */
@media (min-width: 900px) {
  .sidebar {
    display: block; width: var(--sidebar-w); flex: none;
    background: var(--surface); border-inline-end: 1px solid var(--border);
    padding: var(--sp-4) var(--sp-3);
    position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto;
  }
  .bottomnav { display: none; }
  .main { padding: var(--sp-6); padding-bottom: var(--sp-6); }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .grid--2 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 600px) and (max-width: 899px) {
  .grid--3, .grid--2 { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
