/* Reset + app shell layout (header, scroll area, bottom tab bar). */

*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  overflow-x: hidden;
}
a {
  color: var(--accent);
  text-decoration: none;
}
h1 {
  font-size: var(--fs-h1);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 var(--sp-3);
}
h2 {
  font-size: var(--fs-h2);
  font-weight: 700;
  margin: 0 0 var(--sp-2);
}
h3 {
  font-size: var(--fs-h2);
  font-weight: 700;
  margin: 0 0 var(--sp-2);
}
p {
  margin: 0 0 var(--sp-3);
}
/* Weather values read better with aligned, tabular figures. */
.kv__v,
.badge,
.tile__sub,
.raw {
  font-variant-numeric: tabular-nums;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
input,
select {
  font: inherit;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background: var(--bg);
}

/* Body = (optional left favorites column) + content column. Tab bar sits below, full width. */
.app-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  min-width: 0;
  width: 100%;
}
.content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* Persistent favorites column — hidden on narrow screens (favorites tab covers that case). */
.sidebar {
  display: none;
  flex-direction: column;
  min-height: 0;
}
.sidebar__head {
  flex: 0 0 var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-3);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.sidebar__list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--sp-3);
}
.sidebar__item.is-active .tile {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--card));
}
#app.is-onboarding .sidebar {
  display: none !important;
}
/* Favorites route shows the full editable list in the main pane — hide the duplicate sidebar there. */
#app.is-favorites .sidebar {
  display: none;
}

/* Flat custom header — mirrors the mobile AppHeader (no native capsule back button). */
.app-header {
  flex: 0 0 var(--header-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-3);
  padding-top: env(safe-area-inset-top, 0);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 3;
}
.app-header__back {
  justify-self: start;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 16px;
  padding: 6px 4px;
}
.app-header__title {
  grid-column: 2;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header__action {
  justify-self: end;
  display: flex;
  gap: var(--sp-2);
}

.app-view {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-4);
}
.app-view.no-pad {
  padding: 0;
  overflow: hidden;
}

/* Bottom tab bar with emoji icons (no icon font), mirrors mobile. */
.tabslot {
  flex: 0 0 auto;
}
.tabbar {
  display: flex;
  min-height: var(--tabbar-h);
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.12);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabbar__item {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--subtext);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 6px 0;
}
.tabbar__item[aria-current="page"] {
  color: var(--accent);
}
.tabbar__item[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 0;
  width: 28px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
}
.tabbar__icon {
  font-size: 21px;
  line-height: 1;
}

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.col {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.muted {
  color: var(--subtext);
}
.mono {
  font-family: var(--mono);
}
.center {
  text-align: center;
}
.spacer {
  flex: 1;
}
.hidden {
  display: none !important;
}

/* Wide / tablet / desktop: show the favorites column on the left, content fills the rest.
   Breakpoint 760px so tablets in portrait (iPad ~768px) get the side column too. */
@media (min-width: 760px) {
  .sidebar {
    display: flex;
    flex: 0 0 300px;
    width: 300px;
    border-right: 1px solid var(--border);
    background: var(--bg);
  }
  .app-view {
    padding: var(--sp-5) clamp(16px, 4vw, 48px);
  }
  /* Keep long-form content readable on very wide screens without wasting the column. */
  .app-view > * {
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
  }
  .app-view.no-pad > * {
    max-width: none;
  }
}
