*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Header ─────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
  position: sticky;
  top: 0;
  background: var(--color-bg);
  z-index: 10;
}

.header__title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.5px;
}

.header__actions {
  display: flex;
  gap: 8px;
}

/* ── Period nav ─────────────────────────────────────── */

.period-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 4px 16px 12px;
}

.period-nav__btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--color-accent);
  padding: 4px 8px;
  border-radius: var(--radius-s);
  line-height: 1;
}

.period-nav__btn:active { opacity: .6; }

#period-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  min-width: 140px;
  text-align: center;
}

/* ── Main scroll area ───────────────────────────────── */

.main {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px calc(var(--bottom-bar-h) + 24px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Card ───────────────────────────────────────────── */

.card {
  background: var(--color-surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* ── Bottom bar ─────────────────────────────────────── */

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-w);
  height: var(--bottom-bar-h);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 16px;
  z-index: 20;
}

/* ── Spinner overlay ────────────────────────────────── */

#spinner {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.2);
  z-index: 100;
}

.spinner__ring {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Sheets ─────────────────────────────────────────── */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.sheet--open { pointer-events: auto; }

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  opacity: 0;
  transition: opacity .25s;
}

.sheet--open .sheet__backdrop { opacity: 1; }

.sheet__panel {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: var(--max-w);
  background: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-sheet);
  transition: transform .3s cubic-bezier(.32,1,.32,1);
  max-height: 90dvh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.sheet--open .sheet__panel { transform: translateX(-50%) translateY(0); }

.sheet__handle {
  width: 36px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 12px auto 0;
}

.sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
}

.sheet__title {
  font-size: 18px;
  font-weight: 700;
}

.sheet__close {
  background: var(--color-surface-2);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-2);
}
