/* ===== Base ===== */
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-base);
  font-size: var(--fs-md);
  overflow-x: hidden;
}

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

/* ===== Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: var(--sp-2);
  padding-left: var(--sp-3);
  padding-right: var(--sp-3);
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.app-title {
  text-align: center;
  font-size: var(--fs-lg);
  letter-spacing: 0.02em;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-pill);
  color: var(--text);
  transition: background 0.15s;
}
.icon-btn:hover, .icon-btn:active { background: var(--surface-strong); }

/* ===== Main content ===== */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--sp-4);
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + var(--sp-5));
}

/* ===== Bottom nav (mobile only) ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: color-mix(in oklab, var(--bg) 95%, transparent);
  backdrop-filter: saturate(140%) blur(16px);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  border-top: 1px solid var(--border);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: var(--fs-xs);
  color: var(--text-mute);
  transition: color 0.15s, transform 0.15s;
}
.bottom-nav-item.active {
  color: var(--oshi);
}
.bottom-nav-item .bn-icon { font-size: 22px; line-height: 1; }
.bottom-nav-item:active { transform: scale(0.95); }

/* ===== Drawer ===== */
.drawer {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 100;
  width: var(--drawer-w);
  max-width: 85vw;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer-header {
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.drawer-oshi {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s;
}
.drawer-oshi:hover { background: var(--surface); }

.drawer-oshi-info { flex: 1; min-width: 0; }
.drawer-oshi-name {
  font-weight: 700;
  font-size: var(--fs-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-oshi-group {
  font-size: var(--fs-xs);
  color: var(--text-mute);
  margin-top: 2px;
}

.drawer-nav { padding: var(--sp-3) var(--sp-2); flex: 1; }

.drawer-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--fs-md);
  transition: background 0.15s, color 0.15s;
}
.drawer-link:hover { background: var(--surface); }
.drawer-link.active {
  background: var(--oshi-soft);
  color: var(--oshi);
  font-weight: 600;
}
.drawer-icon { font-size: 20px; width: 28px; text-align: center; }

.drawer-divider {
  height: 1px;
  background: var(--border);
  margin: var(--sp-3) var(--sp-3);
}

.drawer-footer {
  padding: var(--sp-4);
  border-top: 1px solid var(--border);
  text-align: center;
}
.drawer-brand {
  font-family: "Shippori Mincho", "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--brand-gold);
  letter-spacing: 0.16em;
  margin-bottom: 4px;
}
.drawer-version {
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

/* ===== Oshi avatar ===== */
.oshi-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--oshi), var(--oshi-strong));
  color: white;
  font-weight: 700;
  font-size: var(--fs-md);
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--oshi-soft);
  background-size: cover;
  background-position: center;
}
.oshi-avatar.lg { width: 48px; height: 48px; font-size: var(--fs-lg); }
.oshi-avatar.sm { width: 28px; height: 28px; font-size: var(--fs-xs); }
.oshi-avatar.has-image {
  border-radius: 22%;
  color: transparent;
  background-color: var(--surface-strong);
}
.oshi-avatar.xl {
  width: 96px;
  height: 96px;
  font-size: 36px;
}
.oshi-avatar-xl-wrap {
  display: flex;
  justify-content: center;
}

/* ===== Desktop adjustments ===== */
@media (min-width: 768px) {
  .bottom-nav { display: none; }
  .app-main {
    padding: var(--sp-5) var(--sp-5) var(--sp-7);
  }
}
