/* Bottom navigation — mobile */
.bottomnav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-top: 1px solid var(--border);
  backdrop-filter: var(--nav-blur);
  -webkit-backdrop-filter: var(--nav-blur);
  box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.06);
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}

.bottomnav__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text-muted);
  font-size: var(--nav-label);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  min-height: 46px;
  border-radius: 14px;
  padding: 4px 0;
  transition: color var(--motion-fast), background var(--motion-fast), transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.bottomnav__btn:active {
  transform: scale(0.96);
}

@media (prefers-reduced-motion: reduce) {
  .bottomnav__btn:active {
    transform: none;
  }
}

.bottomnav__btn.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.bottomnav__icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  line-height: 0;
}

.bottomnav__icon svg {
  display: block;
  width: var(--nav-icon);
  height: var(--nav-icon);
}

.bottomnav__label {
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Side nav — desktop */
.sidenav {
  display: none;
  flex-direction: column;
  width: 72px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: calc(12px + var(--safe-top)) 0 12px;
  gap: 4px;
}

.sidenav__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text-muted);
  font-size: var(--nav-label);
  font-weight: 600;
  padding: 10px 4px;
  cursor: pointer;
  border-radius: 14px;
  margin: 0 8px;
  position: relative;
  transition: color var(--motion-fast), background var(--motion-fast);
}

.sidenav__btn.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.sidenav__btn.is-active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.sidenav__icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  line-height: 0;
}

.sidenav__icon svg {
  display: block;
  width: var(--nav-icon);
  height: var(--nav-icon);
}

.shell-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Feed is the page scroller; do not inherit the flex-column overflow trap. */
.view--feed {
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  padding: var(--safe-top) 16px 0;
  height: calc(var(--header-h) + var(--safe-top));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.view-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.view-header--overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent);
  border: none;
  color: #fff;
  padding-top: var(--safe-top);
}

.view--clips {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

html[data-theme="dark"] .view--clips {
  background: var(--bg);
}

.btn-text {
  border: none;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 10px;
}

.btn-text:active {
  background: var(--accent-soft);
}

.btn-primary {
  display: grid;
  place-items: center;
  width: 100%;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: opacity var(--motion-fast);
}

.btn-primary:active {
  opacity: 0.88;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Sheets */
.sheet-scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  z-index: 50;
  backdrop-filter: blur(2px);
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  max-height: 90dvh;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  z-index: 51;
  overflow: auto;
  overscroll-behavior: contain;
  box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.12);
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet__head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sheet__caption {
  width: 100%;
  min-height: 80px;
  border: none;
  border-radius: 14px;
  background: var(--surface-2);
  padding: 12px 14px;
  resize: vertical;
  margin-top: 12px;
  font-size: 16px;
  outline: none;
}

.sheet__caption:focus {
  box-shadow: 0 0 0 2px var(--accent-soft-strong);
}

.sheet__mosaic,
#album-mosaic {
  background: var(--surface-2);
}

html[data-theme="dark"] .bottomnav {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.28);
}

@media (max-width: 860px) {
  .bottomnav {
    display: grid;
  }
  .app {
    padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
  }
  .app.is-thread-open {
    padding-bottom: 0;
  }
  .app.is-thread-open .bottomnav {
    display: none;
  }
}

@media (min-width: 861px) {
  .sidenav {
    display: flex;
  }
  .app {
    max-width: none;
    width: 100%;
    height: 100dvh;
    margin: 0;
  }
  .view--chats {
    flex-direction: row;
  }
  .panel--list {
    width: var(--list-width);
    max-width: 400px;
  }
  .panel--thread {
    flex: 1;
  }
  .btn-back {
    display: none !important;
  }
  .view--clips {
    max-width: none;
    margin: 0;
    width: 100%;
    background: #fff;
  }
  html[data-theme="dark"] .view--clips {
    background: var(--bg);
  }
}
