*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  min-height: 100vh;
  line-height: 1.6;
  /* Defense in depth: a single un-wrapped flex row anywhere in the app
     (e.g. a toolbar button group on a narrow phone) can otherwise push the
     whole page into horizontal scroll instead of just clipping locally.
     .landing-page already sets this for itself; this covers every other
     route, which had no such safety net. */
  overflow-x: hidden;
  /* Pins the footer to the bottom of the viewport on short-content pages
     (e.g. an empty dashboard) instead of it floating right under the
     content with a gap of bare background below — #app-root is the one
     flex item that grows to fill whatever space header+footer don't need.
     On tall pages this has no effect: #app-root just grows past 100vh like
     a block element normally would, and the footer follows it down. */
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-family: 'DM Serif Display', serif; font-weight: 400; }

a { color: inherit; }

button { font-family: inherit; }

/* HEADER */
/* Scoped to the shared chrome (a direct child of <body>, alongside
   <main id="app-root">) rather than a bare `header` tag selector, because
   views render their own markup inside #app-root and some use their own
   semantic <header>/<footer> tags — the landing page at /welcome has a
   full custom header of its own. An unscoped rule leaks this chrome's
   padding, border, and flex layout onto those, which is invisible in the
   CSS but very visible on the page. Same reasoning as the `body > header`
   query in App.Router.resolve(). */
body > header {
  padding: 22px 48px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.brand { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.icon-btn { padding: 8px 10px; font-size: 18px; line-height: 1; }
#tool-menu-toggle { color: var(--text); border: 1px solid var(--border); border-radius: 999px; }
#tool-menu-toggle:hover { background: var(--bg); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--text); color: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Serif Display', serif; font-size: 17px; flex-shrink: 0;
}
.brand-logo-img {
  height: 44px; width: auto; object-fit: contain; flex-shrink: 0;
}
.drawer-mark { height: 34px; }
.brand-title {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
}
.brand-title span { color: var(--muted); font-style: italic; font-size: 14px; display: block; margin-top: 3px; font-family: 'DM Sans', sans-serif; font-style: normal; }

/* SECTION LABELS */
.section-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

/* MAIN LAYOUT */
#app-root { display: block; flex: 1 0 auto; }
.page { padding: 36px 48px; max-width: 1400px; margin: 0 auto; }

/* FOOTER */
/* Scoped to the shared chrome the same way, and for the same reason, as
   `body > header` above. */
body > footer {
  border-top: 1px solid var(--border); padding: 20px 48px;
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 40px;
  background: var(--surface);
  flex-wrap: wrap; gap: 12px;
  flex-shrink: 0;
}
body > footer .copy { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted); }
body > footer .footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
body > footer .footer-link { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--border); }
body > footer .footer-link:hover { color: var(--text); border-color: var(--text); }

/* ASSUMPTION BADGES */
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.badge {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 14px;
  font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted);
}
.badge span { color: var(--text); font-weight: 500; margin-left: 4px; }

.mono { font-family: 'DM Mono', monospace; }
.pos { color: var(--positive); }
.neg { color: var(--negative); }

@media (max-width: 768px) {
  header, .page, footer { padding-left: 20px; padding-right: 20px; }
}
