html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

a { color: var(--accent); }

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.app-shell {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ---------- Desktop side rail ---------- */
.side-rail {
  width: var(--nav-w);
  flex: 0 0 var(--nav-w);
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding: var(--sp-5) 0;
}

.side-rail__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-5) var(--sp-5);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--sp-4);
}

.side-rail__logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--surface);
}

.side-rail__brand-name {
  font-family: var(--font-display);
  font-size: var(--text-md);
  line-height: 1.3;
}

.side-rail nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 var(--sp-3);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  cursor: pointer;
}

.nav-link:hover { background: var(--paper); color: var(--ink); }
.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.nav-link__icon { width: 18px; text-align: center; flex: none; }

.nav-section-label {
  padding: var(--sp-4) var(--sp-3) 4px;
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav-divider {
  height: 1px;
  background: var(--line);
  margin: var(--sp-3) var(--sp-2);
}

/* ---------- Main column ---------- */
.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: none;
}

.view {
  flex: 1;
  padding: var(--sp-6) var(--sp-6) var(--sp-7);
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}
.page-link { display:flex; align-items:center; justify-content:flex-end; gap:var(--sp-2); margin-bottom:var(--sp-3); }
.page-link__url { max-width:48ch; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
@media (max-width: 767px) { .page-link__url { display:none; } }

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}

.view-header h1 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  margin: 0 0 var(--sp-1);
}

.view-header p {
  margin: 0;
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.bottom-tabs { display: none; }
.fab { display: none; }

.boot-loading, .boot-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-6);
  text-align: center;
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

/* ---------- Phone layout ---------- */
@media (max-width: 767px) {
  .side-rail { display: none; }

  .topbar {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    height: var(--topbar-h);
    padding: env(safe-area-inset-top, 0px) var(--sp-4) 0;
    padding-top: calc(env(safe-area-inset-top, 0px) + var(--sp-2));
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 20;
  }

  .topbar__logo { width: 26px; height: 26px; border-radius: var(--radius-sm); object-fit: contain; }
  .topbar__title { font-family: var(--font-display); font-size: var(--text-md); }

  .view {
    padding: var(--sp-4) var(--sp-4) calc(var(--bottombar-h) + var(--sp-7));
  }

  .bottom-tabs {
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: calc(var(--bottombar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    border-top: 1px solid var(--line);
    z-index: 30;
  }

  .bottom-tabs__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--ink-faint);
    font-size: 11px;
    text-decoration: none;
    background: none;
    border: none;
    font-family: inherit;
  }

  .bottom-tabs__item.is-active { color: var(--accent-strong); }
  .bottom-tabs__icon { font-size: 18px; }

  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: var(--sp-4);
    bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom, 0px) + var(--sp-4));
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 26px;
    border: none;
    box-shadow: 0 6px 16px hsl(var(--shadow-color) / 0.35);
    z-index: 30;
  }
}
