/* ============================================================
   BASE : reset, shell layout, responsive. Screens never edit this.
   ============================================================ */

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

html { height: 100%; }

body {
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, var(--bg-2), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}

img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-soft); }

h1, h2, h3, h4 { font-weight: 800; line-height: 1.15; }

/* ---------- shell grid ---------- */

#app {
  display: grid;
  grid-template-areas: "header header" "sidebar main";
  /* minmax(0, …) : without it the column's automatic minimum is the header's
     min-content (≈605px: brand + full nav + actions), which blew the whole page
     past the viewport at 375px. Integration review 2026-08-12. */
  grid-template-columns: 264px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 18px 74px;
  min-height: 100vh;
}

.shell-header { grid-area: header; }
.shell-sidebar { grid-area: sidebar; align-self: start; position: sticky; top: 14px; }
.shell-main { grid-area: main; min-width: 0; }

/* ---------- header ---------- */

.shell-header {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-xl);
  padding: 10px 14px;
  box-shadow: var(--shadow-1);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 900; font-size: 19px; letter-spacing: -.2px;
  padding-right: 6px; white-space: nowrap;
}

.brand-logo {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, var(--blue-soft), var(--accent-soft));
  border: 1px solid var(--line);
}

.shell-nav { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.shell-nav::-webkit-scrollbar { display: none; }

.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: var(--r-md);
  font-weight: 700; font-size: 14.5px; color: var(--ink-soft);
  white-space: nowrap;
  transition: background .2s ease, color .2s ease;
}
.nav-link:hover { background: var(--bg-2); color: var(--ink); }
.nav-link.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-1); border: 1px solid var(--line-soft); }
.nav-link .ico { font-size: 16px; }

.header-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- sidebar ---------- */

.shell-sidebar { display: flex; flex-direction: column; gap: 14px; }

.side-card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 14px;
  box-shadow: var(--shadow-1);
}

.side-title { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.side-title .side-emoji {
  width: 34px; height: 34px; border-radius: 10px; font-size: 17px;
  display: grid; place-items: center;
  background: var(--bg-2);
}
.side-title h3 { font-size: 15px; }
.side-title p { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- main ---------- */

/* padding-bottom clears the fixed .tipbar, which otherwise sits on top of the
   last card of every screen. */
.shell-main { display: flex; flex-direction: column; gap: 16px; padding-bottom: 64px; }

.screen { animation: screen-in .35s ease both; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- tip bar ---------- */

.tipbar {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%);
  z-index: 40;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  box-shadow: var(--shadow-2);
  padding: 9px 18px;
  font-size: 13px; font-weight: 700; color: var(--ink-soft);
  max-width: min(92vw, 640px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- focus route: shell disappears ---------- */

body[data-route="focus"] #app { display: block; padding: 0; max-width: none; }
body[data-route="focus"] .shell-header,
body[data-route="focus"] .shell-sidebar,
body[data-route="focus"] .tipbar { display: none; }
body[data-route="focus"] .shell-main { height: 100vh; }

/* screen-in interpolates transform to `none`, which settles as matrix(1,0,0,1,0,0)
   and keeps .screen a containing block for the scene's position:fixed, collapsing
   it to 0px. The focus route fades in without transform so the scene can fill the
   viewport. */
body[data-route="focus"] .screen { animation-name: screen-fade-in; }

@keyframes screen-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  #app {
    grid-template-areas: "header" "sidebar" "main";
    grid-template-columns: minmax(0, 1fr);
    padding: 10px 10px 70px;
    gap: 12px;
  }
  .shell-sidebar { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .brand span.brand-name { display: none; }
}

@media (max-width: 560px) {
  .shell-sidebar { grid-template-columns: 1fr; }
  .nav-link { padding: 8px 11px; font-size: 13.5px; }
  .nav-link .label { display: none; }
  .nav-link .ico { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
