/* Skall og skjermoppsett. Mobil først: én skjerm fyller hele bredden, med
   egen topplinje og fast bunnlinje for hovedhandlingen. Fra 600 px holdes
   innholdet i en lesbar kolonne; fra 1024 px kommer en rolig sidemeny. */

.shell { min-height: 100dvh; }
.main { min-width: 0; }
.side { display: none; }

/* ── Skjerm ──────────────────────────────────────────────────────────── */

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
  max-width: var(--col);
  margin: 0 auto;
  background: var(--paper);
}

.screen-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap-section);
  padding: 6px var(--gutter) 32px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-top);
  display: grid;
  grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap);
  align-items: center;
  gap: 8px;
  min-height: 60px;
  padding: env(safe-area-inset-top, 0px) 10px 0;
  background: var(--paper);
}
.topbar-title {
  overflow: hidden;
  color: var(--ink-2);
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.icon-btn-spacer { width: var(--tap); }

.foot {
  position: sticky;
  bottom: 0;
  z-index: var(--z-foot);
  padding: 12px var(--gutter) calc(16px + var(--safe-bottom));
  border-top: 1px solid var(--line-2);
  background: var(--paper);
}
.foot-inner { display: flex; gap: 10px; }
.foot-inner > * { flex: 1; min-width: 0; }

/* ── Bunnark og toast ────────────────────────────────────────────────── */

.sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-scrim);
  background: var(--scrim);
  animation: fade-in 0.2s ease;
}
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-sheet);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 85dvh;
  overflow-y: auto;
  padding: 10px var(--gutter) calc(20px + var(--safe-bottom));
  border-radius: 26px 26px 0 0;
  background: var(--paper);
  box-shadow: var(--shadow-sheet);
  animation: sheet-up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-grab { width: 38px; height: 5px; margin: 0 auto 10px; border-radius: 9px; background: #DAD7D1; }
.sheet-title { margin-bottom: 4px; font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.01em; }
.sheet-stack { display: flex; flex-direction: column; gap: 14px; }
.sheet-list { max-height: 50dvh; overflow-y: auto; }

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  z-index: var(--z-toast);
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 500;
  animation: toast-in 0.2s ease;
}
.toast-ok .icon { color: #7DDCA6; }
.toast-error .icon { color: #FFB1A9; }

/* ── Bredere skjermer ────────────────────────────────────────────────── */

@media (min-width: 600px) {
  :root { --gutter: 28px; }
  .screen { border-left: 1px solid var(--line-2); border-right: 1px solid var(--line-2); }
  .sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: min(480px, calc(100% - 48px));
    border-radius: var(--r-xl);
    transform: translate(-50%, -50%);
    animation: fade-in 0.18s ease;
  }
  .sheet-grab { display: none; }
  .toast-region { bottom: calc(110px + var(--safe-bottom)); }
}

/* ── Desktop: sidemeny ───────────────────────────────────────────────── */

@media (min-width: 1024px) {
  body { background: var(--stone-2); }
  .shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .screen { border: 0; }
  .main { background: var(--paper); border-left: 1px solid var(--line); }
  .shell .only-small { display: none; }

  .side {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    height: 100dvh;
    overflow-y: auto;
    padding: 22px 16px 20px;
  }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 600; font-size: var(--fs-lg); letter-spacing: -0.01em; }
  .brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--brand); color: var(--paper); }
  .side-site {
    display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 12px;
    border-radius: var(--r-md); background: var(--paper); border: 1px solid var(--line);
    font-weight: 500;
  }
  .side-site span { flex: 1; }
  .side-site:hover { border-color: var(--line-strong); }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-item {
    display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 0 12px;
    border-radius: 12px; color: var(--ink-2); font-weight: 500;
  }
  .side-item:hover { background: var(--stone); color: var(--ink); text-decoration: none; }
  .side-item[aria-current='page'] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
  .side-label { flex: 1; }
  .side-count { color: var(--ink-2); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
  .side-foot { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
  .side-toggle { display: flex; align-items: center; gap: 10px; padding: 0 12px; color: var(--ink-2); font-weight: 500; }
  .side-toggle span { flex: 1; }
  .side-note { padding: 0 12px; color: var(--ink-2); font-size: var(--fs-xs); line-height: 1.45; }
  .side-note b { display: block; color: var(--ink-2); font-weight: 600; }
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(105%); } to { transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
