/* Sprengningsplanlegger — main shell. No @media here (see mobile.css). */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body {
  font-family: var(--font);
  font-size: clamp(0.9rem, 0.85rem + 0.25vw, 1rem);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grid-opacity);
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 28px 28px;
}

h1, h2, h3, h4 {
  color: var(--text);
  font-weight: 700;
  line-height: 1.2;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-dk);
}

.hidden { display: none !important; }

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Mobile top brand bar (hidden on desktop via mobile.css inverse / main default) ── */
.site-header {
  display: none;
  flex-shrink: 0;
  min-height: var(--header-height);
  background: var(--header-bg);
  border: 0;
  z-index: 220;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.65rem 1rem;
  padding-top: max(0.65rem, env(safe-area-inset-top));
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.header-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
  font-size: 1.1rem;
}

.site-title {
  margin: 0;
  font-size: clamp(1rem, 0.95rem + 0.4vw, 1.25rem);
  font-weight: 800;
  color: var(--text);
}

.site-subtitle {
  margin: 0.1rem 0 0;
  font-size: clamp(0.72rem, 0.7rem + 0.2vw, 0.85rem);
  color: var(--text-muted);
  font-weight: 500;
}

.header-areas-toggle {
  min-width: 44px;
  min-height: 44px;
}

/* ── App layout ── */
.main-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

/* ── Desktop page sidebar ── */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-1);
  border-right: 0;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.15rem 1.1rem 1rem;
}

.sidebar-brand-text {
  min-width: 0;
}

.sidebar-brand-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
}

.sidebar-brand-sub {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem 1rem;
  flex: 1;
  min-height: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 46px;
  padding: 0.7rem 0.85rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-item i,
.nav-item .material-icons {
  width: 1.35rem;
  font-size: 1.15rem;
  color: var(--text-muted);
  text-align: center;
}

.nav-item:hover {
  background: var(--card-surface-soft);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item.active i,
.nav-item.active .material-icons {
  color: var(--accent);
}

.sidebar-overlay {
  display: none;
}

/* ── Bottom nav (shown on mobile only) ── */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 230;
  align-items: stretch;
  justify-content: space-around;
  gap: 0.25rem;
  min-height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom));
  background: var(--surface-1);
  box-shadow: 0 -8px 24px rgba(28, 25, 23, 0.08);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.bottom-nav-item i,
.bottom-nav-item .material-icons {
  font-size: 1.25rem;
  line-height: 1;
}

.bottom-nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.content-area {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: transparent;
}

.tab-panel {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.tab-panel.active {
  display: flex;
}

/* Kart layout: areas panel + map */
.kart-layout {
  display: grid;
  grid-template-columns: var(--areas-panel-width) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.areas-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-1);
  overflow: hidden;
}

.areas-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.75rem;
  flex-shrink: 0;
}

.areas-panel-heading {
  min-width: 0;
}

.areas-eyebrow {
  display: block;
  margin: 0 0 0.2rem;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.areas-title {
  margin: 0;
  font-size: clamp(1.05rem, 1rem + 0.35vw, 1.25rem);
  font-weight: 800;
}

.areas-panel-close {
  display: none;
}

.area-list {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.35rem 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* Never squash rows to fit — scroll the list instead */
.area-list > .area-item,
.area-list > .empty-state {
  flex: 0 0 auto;
}

.areas-sheet-overlay {
  display: none;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--surface-2);
}

.map-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* Settings page */
.settings-page-layout {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.25rem clamp(1rem, 2vw, 2rem) 2rem;
}

.settings-page-inner {
  width: min(820px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-page-title {
  margin: 0;
  font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.9rem);
  font-weight: 800;
}

.settings-page-subtitle {
  margin: 0.25rem 0 0.5rem;
  color: var(--text-muted);
  font-size: clamp(0.88rem, 0.85rem + 0.2vw, 1rem);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
