/* ── Modal ───────────────────────────── */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  min-height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal__content {
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  padding: 2rem 2.5rem;
  min-width: 320px;
  max-width: 90vw;
  text-align: center;
  margin: auto;
}
/* SwimStory — club-branded theme */

:root {
  --color-primary: #0077be;
  --color-secondary: #00b4d8;
  --color-primary-dark: color-mix(in srgb, var(--color-primary), black 20%);
  --color-primary-deep: color-mix(in srgb, var(--color-primary), black 50%);
  --color-accent: var(--color-secondary);
  --color-bg: #131315;
  --color-surface: #1e1e24;
  --color-surface-light: #282832;
  --color-text: #ffffff;
  --color-text-light: #9ca3af;
  --color-text-muted: #6b7280;
  --color-border: #2e2e38;
  --color-danger: #e63946;
  --radius: 12px;
  --radius-lg: 16px;
  --sidebar-width: 220px;
}

/* ── Light mode overrides ──────────────────── */
body.light-mode {
  --color-bg: #f5f5f7;
  --color-surface: #ffffff;
  --color-surface-light: #eeeef2;
  --color-text: #1a1a2e;
  --color-text-light: #555568;
  --color-text-muted: #8888a0;
  --color-border: #d8d8e0;
}

body.light-mode .chat-input-bar input {
  background: var(--color-surface-light);
}

body.light-mode .story-card__delete {
  background: rgba(0, 0, 0, 0.35);
}

body.light-mode .auth-card .form-group input {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}

body.light-mode .auth-card .form-group input::placeholder {
  color: var(--color-text-muted);
}

body.light-mode .auth-card .form-group input:focus {
  border-color: var(--color-primary, #0077be);
  box-shadow: 0 0 0 3px rgba(0, 119, 190, 0.15);
}

body.light-mode .auth-card .form-group label {
  color: var(--color-text-light);
}

body.light-mode .form-group input,
body.light-mode .form-group textarea,
body.light-mode .form-group select {
  border-color: var(--color-border);
  background: var(--color-surface);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--color-accent);
}

/* ── Sidebar ───────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-primary);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  z-index: 100;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}

.sidebar__brand-icon {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.sidebar__brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar__drawer {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.sidebar__overlay {
  display: none;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.sidebar__link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar__link--active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-left-color: #fff;
}

.sidebar__link-icon {
  font-size: 1.1rem;
  width: 1.5rem;
  text-align: center;
}

.sidebar__divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0.75rem 1.25rem;
}

.sidebar__theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
}

.sidebar__footer {
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  margin-top: auto;
}

.sidebar__avatar {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #fff;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar__avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar__footer-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.sidebar__footer-link:hover .sidebar__username {
  color: #fff;
}

.sidebar__username {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  font-weight: 500;
}

.sidebar__logout {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-size: 0.8rem;
  margin-left: auto;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  transition: background 0.15s;
}

.sidebar__logout:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* ── Hamburger toggle (hidden on desktop) ──── */
.sidebar__hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  margin-left: auto;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  z-index: 110;
}

.sidebar__hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.2s;
}

/* Animate into X when open */
.sidebar__hamburger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.sidebar__hamburger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.sidebar__hamburger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ── Main content area ─────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 2.5rem;
}

/* ── Top bar (search/filter, used on feed) ─── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.topbar__title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

.topbar__actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* ── Cards ──────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--color-border);
}

.card__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--color-text);
}

.card__title a {
  text-decoration: none;
  color: inherit;
}

.card__title a:hover {
  color: var(--color-accent);
}

.card__meta {
  font-size: 0.85rem;
  color: var(--color-text-light);
  margin-bottom: 0.75rem;
}

.card__body {
  line-height: 1.7;
  color: var(--color-text-light);
}

/* ── Story grid (feed page) ────────────────── */
.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
}

.story-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  min-width: 0;
}

.story-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.story-card__image {
  aspect-ratio: 1;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.3);
  overflow: hidden;
  flex: 1;
}

.story-card__media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.story-card__info {
  padding: 0.85rem 1rem;
}

.story-card__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-card__author {
  font-size: 0.8rem;
  color: var(--color-text-light);
}

/* Draft card wrapper — keeps delete btn positioned */
.story-card--draft {
  position: relative;
  overflow: visible;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.story-card__link {
  display: flex;
  flex-direction: column;
  flex: 1;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius);
  overflow: hidden;
}

.story-card__delete {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 10;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border: none;
  border-radius: 50%;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  padding: 0;
  line-height: 1;
}

.story-card--draft:hover .story-card__delete {
  opacity: 1;
}

.story-card__delete:hover {
  background: var(--color-danger);
  color: #fff;
}

/* Owned published card — keeps action btns positioned */
.story-card--owned {
  position: relative;
  overflow: visible;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.story-card--owned .story-card__link {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  transition: transform 0.15s, box-shadow 0.15s;
}

.story-card--owned .story-card__link:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.story-card__actions {
  display: flex;
  gap: 0.4rem;
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.15s;
}

.story-card--owned:hover .story-card__actions {
  opacity: 1;
}

.story-card__action-btn {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border: none;
  border-radius: 50%;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  color: #fff;
  text-decoration: none;
  transition: background 0.15s;
  line-height: 1;
}

.story-card__action-btn:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ── Modal ──────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[hidden] { display: none; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal__dialog {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 400px;
  width: 90%;
}

.modal__title {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.modal__body {
  color: var(--color-text-light);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ── Buttons ────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
  gap: 0.4rem;
  box-sizing: border-box;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
}

.btn--primary:hover {
  background: var(--color-primary-dark);
}

.btn--secondary {
  background: var(--color-surface-light);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--secondary:hover {
  background: var(--color-border);
}

.btn--danger {
  background: var(--color-danger);
  color: #fff;
}

.btn--danger:hover {
  filter: brightness(1.15);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ── Forms ──────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--color-text-light);
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--color-text-muted);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(97, 61, 199, 0.25);
}

/* ── Emotions / Tags ────────────────────────── */
.tag {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  background: rgba(97, 61, 199, 0.2);
  color: var(--color-accent);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-right: 0.35rem;
  margin-bottom: 0.35rem;
}

.tag--meta {
  background: color-mix(in srgb, var(--color-secondary) 18%, transparent);
  color: var(--color-accent);
}

/* ── Section headings ───────────────────────── */
.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--color-text);
}

/* ── Helpers ────────────────────────────────── */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ── Chat ───────────────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  left: var(--sidebar-width);
  overflow: hidden;
}

.chat-header {
  padding: 1rem 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  z-index: 50;
}

.chat-header strong {
  color: var(--color-text);
}

/* Publish-readiness checklist */
.publish-checklist {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 100;
}

.publish-checklist__title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

.publish-checklist__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.publish-checklist__list li {
  font-size: 0.85rem;
  padding: 0.2rem 0;
}

.publish-checklist__item--done {
  color: var(--color-success, #4caf50);
}

.publish-checklist__item--missing {
  color: var(--color-danger, #ef4444);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--color-bg);
}

.chat-bubble {
  max-width: 75%;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  line-height: 1.55;
  white-space: pre-wrap;
}

.chat-bubble--user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.chat-bubble--assistant {
  align-self: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-bottom-left-radius: 3px;
}

.chat-input-bar {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-input-bar input {
  flex: 1;
  padding: 0.85rem 1rem;
  min-height: 50px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text);
}

.chat-input-bar input::placeholder {
  color: var(--color-text-muted);
}

.chat-input-bar input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.chat-typing {
  align-self: flex-start;
  color: var(--color-text-light);
  font-style: italic;
  font-size: 0.9rem;
  display: none;
}

/* ── Auth pages (login/signup) ─────────────── */
.auth-page {
  min-height: 100vh;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  background: var(--color-primary-deep);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-card__logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-card__logo-icon {
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--color-primary);
  font-weight: 700;
}

.auth-card__logo-img {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
}

.auth-card h2 {
  text-align: center;
  color: #fff;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.auth-card__subtitle {
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.auth-card .form-group input {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.auth-card .form-group input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.auth-card .form-group input:focus {
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.auth-card .form-group label {
  color: rgba(255, 255, 255, 0.6);
}

.auth-card .btn--primary {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
  margin-top: 0.5rem;
}

.auth-card .btn--primary:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.9rem;
}

.auth-footer a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: underline;
}

.auth-footer a:hover {
  color: #fff;
}

/* ── Hero (landing page) ──────────────────── */
.hero {
  text-align: center;
  padding: 6rem 1rem 4rem;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 1rem;
}

.hero h1 span {
  color: var(--color-accent);
}

.hero p {
  font-size: 1.15rem;
  color: var(--color-text-light);
  max-width: 500px;
  margin: 0 auto 2.5rem;
}

.hero__actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* ── Messages (Django messages) ────────────── */
.message-banner {
  background: var(--color-surface);
  border-left: 4px solid var(--color-primary);
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  color: var(--color-text);
}

/* ── Responsive ────────────────────────────── */

/* Touch-friendly: ensure minimum tap target sizes */
@media (pointer: coarse) {
  .btn {
    min-height: 44px;
    padding: 0.65rem 1.4rem;
  }

  .sidebar__link {
    min-height: 44px;
  }

  .chat-input-bar input {
    min-height: 44px;
  }

  /* Show delete button always on touch devices (no hover) */
  .story-card__delete {
    opacity: 1;
  }

  /* Show action buttons always on touch devices */
  .story-card__actions {
    opacity: 1;
  }
}

/* ── Tablet & small desktop (≤ 768px) ─────── */
@media (max-width: 768px) {
  /* Sidebar → horizontal top bar */
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    gap: 0;
  }

  .sidebar__brand {
    margin-bottom: 0;
    padding: 0;
    font-size: 1.1rem;
    flex: 1;
    order: 1;
  }

  .sidebar__brand-icon {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
  }

  /* Show hamburger on mobile — pinned to far right */
  .sidebar__hamburger {
    display: flex;
    position: absolute;
    right: 1rem;
    top: 0.55rem;
    order: 2;
    padding: 0.5rem;
    z-index: 210;
  }

  /* Overlay backdrop */
  .sidebar__overlay--visible {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 199;
  }

  /* Right-side drawer panel */
  .sidebar__drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    background: var(--color-primary);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 200;
    padding: 1.25rem 0;
    overflow-y: auto;
  }

  .sidebar__drawer--open {
    transform: translateX(0);
  }

  /* Nav links inside drawer */
  .sidebar__nav {
    flex-direction: column;
    gap: 0;
    width: auto;
    overflow: visible;
    max-height: none;
    padding: 0;
  }

  .sidebar__nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar__link {
    padding: 0.6rem 1rem;
    border-left: 3px solid transparent;
    border-bottom: none;
    white-space: nowrap;
    font-size: 0.88rem;
  }

  .sidebar__link--active {
    border-left-color: #fff;
    border-bottom-color: transparent;
    background: rgba(255, 255, 255, 0.12);
  }

  .sidebar__divider {
    margin: 0.4rem 1rem;
  }

  /* Footer inside drawer */
  .sidebar__footer {
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin-top: auto;
    padding: 0.6rem 1rem;
    width: auto;
    overflow: visible;
    max-height: none;
  }

  .sidebar__avatar {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }

  /* Main content */
  .main-content {
    margin-left: 0;
  }

  .container {
    padding: 1rem 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  /* Topbar stacks on narrow screens */
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .topbar__title {
    font-size: 1.3rem;
  }

  /* Story grid adapts */
  .story-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .story-card__image {
    font-size: 2.2rem;
  }

  /* Chat full-viewport below top bar */
  .chat-container {
    position: fixed;
    left: 0;
    right: 0;
    top: 3.75rem;
    bottom: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .chat-input-bar {
    flex-shrink: 0;
  }

  .chat-messages {
    padding: 1rem;
  }

  .chat-bubble {
    max-width: 88%;
  }

  .chat-input-bar {
    padding: 0.75rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }

  .chat-header {
    padding: 0.75rem 1rem;
  }

  .chat-header strong {
    font-size: 0.95rem;
  }

  /* Hero */
  .hero {
    padding: 3rem 1rem 2rem;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .hero__actions {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }

  .hero__actions .btn {
    width: 100%;
    max-width: 300px;
  }

  /* Auth pages */
  .auth-page {
    padding: 1rem;
  }

  .auth-card {
    padding: 2rem 1.5rem;
  }

  .auth-card h2 {
    font-size: 1.35rem;
  }

  /* Choose method */
  .choose-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .choose-card {
    padding: 1.5rem 1.25rem;
  }

  /* Edit form */
  .edit-form {
    max-width: 100%;
  }

  /* Modal */
  .modal__dialog {
    max-width: 92%;
    padding: 1.5rem;
  }

  /* Cards */
  .card {
    padding: 1.25rem;
  }
}

/* ── Small phone (≤ 480px) ─────────────────── */
@media (max-width: 480px) {
  .sidebar {
    padding: 0.4rem 0.5rem;
  }

  .sidebar__brand {
    font-size: 1rem;
    gap: 0.4rem;
  }

  .sidebar__link {
    padding: 0.5rem 0.65rem;
    font-size: 0.78rem;
  }

  .sidebar__logout {
    font-size: 0.75rem;
    padding: 0.25rem 0.4rem;
  }

  .container {
    padding: 0.75rem;
  }

  .topbar__title {
    font-size: 1.15rem;
  }

  .story-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }

  .story-card__info {
    padding: 0.6rem 0.7rem;
  }

  .story-card__title {
    font-size: 0.85rem;
  }

  .story-card__author {
    font-size: 0.72rem;
  }

  .chat-bubble {
    max-width: 92%;
    padding: 0.7rem 0.9rem;
    font-size: 0.92rem;
  }

  .hero h1 {
    font-size: 1.65rem;
  }

  .hero p {
    font-size: 0.92rem;
  }

  .btn {
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
  }

  .card__title {
    font-size: 1rem;
  }

  .section-title {
    font-size: 1.1rem;
  }

  .auth-card {
    padding: 1.5rem 1.25rem;
    border-radius: var(--radius);
  }

  .auth-card h2 {
    font-size: 1.2rem;
  }

  .auth-card__subtitle {
    font-size: 0.82rem;
  }

  .choose-card__icon {
    font-size: 2rem;
  }

  .choose-card__title {
    font-size: 1rem;
  }

  .choose-card__desc {
    font-size: 0.85rem;
  }
}

/* ── Choose-method page ────────────────────── */
.choose-subtitle {
  color: var(--color-text-light);
  margin-bottom: 1.5rem;
}

.choose-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  max-width: 680px;
}

.choose-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text);
  transition: border-color 0.2s, transform 0.15s;
}

.choose-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.choose-card__icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.choose-card__title {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.choose-card__desc {
  font-size: 0.9rem;
  color: var(--color-text-light);
  line-height: 1.5;
}

/* ── Edit form ─────────────────────────────── */
.edit-form {
  max-width: 640px;
}

.edit-form__label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  margin-top: 1.25rem;
  color: var(--color-text-light);
  font-size: 0.9rem;
}

.edit-form__input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 1rem;
}

.edit-form__input:focus,
.edit-form__textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

.edit-form__textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 1rem;
  resize: vertical;
  font-family: inherit;
  line-height: 1.6;
}

.edit-form__actions {
  margin-top: 1.5rem;
}

.edit-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
}

.edit-media-card {
  border: 1px solid var(--color-border);
  background: var(--color-surface-light);
  border-radius: var(--radius);
  padding: 0.55rem;
}

.edit-media-card--selectable {
  cursor: pointer;
}

.edit-media-card__media {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: calc(var(--radius) - 4px);
  display: block;
  margin-bottom: 0.45rem;
}

.edit-media-card__row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.83rem;
  color: var(--color-text-light);
  margin-bottom: 0.3rem;
}

.btn--rotate {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.35rem;
  cursor: pointer;
}

.btn--rotate:disabled {
  opacity: 0.5;
  cursor: wait;
}

.story-attachments {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
}

.story-attachments__item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface-light);
  display: block;
}

.story-attachments__media {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

/* ───────────────────── Admin panel ───────────────────────── */

.admin-section {
  margin-bottom: 2.5rem;
}

.admin-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.admin-section__title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

.admin-section__header--analytics {
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-analytics-actions {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}

.admin-window-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 0.25rem;
}

.admin-window-tab {
  text-decoration: none;
  color: var(--color-text-light);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
}

.admin-window-tab:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.07);
}

.admin-window-tab--active {
  color: #fff;
  background: var(--color-primary);
}

.admin-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.admin-metric-card {
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.admin-metric-card__label {
  color: var(--color-text-light);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.admin-metric-card__value {
  font-size: 1.55rem;
  line-height: 1.1;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.admin-metric-card__meta {
  color: var(--color-text-light);
  font-size: 0.8rem;
}

.admin-bar-metric {
  display: grid;
  grid-template-columns: auto minmax(80px, 1fr);
  align-items: center;
  gap: 0.55rem;
}

.admin-bar-metric__track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.admin-bar-metric__fill {
  height: 100%;
  min-width: 2px;
  border-radius: 999px;
}

.admin-bar-metric__fill--members {
  background: linear-gradient(90deg, #2dd4bf, #14b8a6);
}

.admin-bar-metric__fill--posts {
  background: linear-gradient(90deg, #f59e0b, #f97316);
}

.admin-progress {
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
}

.admin-progress::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.09);
  border-radius: 999px;
}

.admin-progress::-webkit-progress-value {
  border-radius: 999px;
}

.admin-progress::-moz-progress-bar {
  border-radius: 999px;
}

.admin-progress--members::-webkit-progress-value {
  background: linear-gradient(90deg, #2dd4bf, #14b8a6);
}

.admin-progress--members::-moz-progress-bar {
  background: linear-gradient(90deg, #2dd4bf, #14b8a6);
}

.admin-progress--posts::-webkit-progress-value {
  background: linear-gradient(90deg, #f59e0b, #f97316);
}

.admin-progress--posts::-moz-progress-bar {
  background: linear-gradient(90deg, #f59e0b, #f97316);
}

.admin-trend-card {
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}

.admin-trend-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}

.admin-trend-card__title {
  font-size: 0.95rem;
  font-weight: 700;
}

.admin-trend-card__meta {
  font-size: 0.8rem;
  color: var(--color-text-light);
}

.admin-sparkline {
  width: 100%;
  height: 68px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  border-radius: 8px;
  display: block;
}

.admin-sparkline__line {
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.admin-sparkline__line--members {
  stroke: #2dd4bf;
}

.admin-sparkline__line--posts {
  stroke: #f59e0b;
}

.admin-trend-legend {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  color: var(--color-text-light);
  font-size: 0.78rem;
}

.admin-trend-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.admin-trend-legend__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.admin-trend-legend__dot--members {
  background: #2dd4bf;
}

.admin-trend-legend__dot--posts {
  background: #f59e0b;
}

.admin-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--color-card);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th {
  text-align: left;
  padding: 0.65rem 1rem;
  color: var(--color-text-light);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.admin-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.admin-table__logo {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 0.4rem;
}

@media (max-width: 900px) {
  .admin-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-analytics-actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 640px) {
  .admin-metrics-grid {
    grid-template-columns: 1fr;
  }

  .admin-section__header--analytics {
    align-items: flex-start;
  }

  .admin-analytics-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

.admin-form-card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 640px;
}

.admin-fieldset {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.admin-fieldset legend {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-light);
  padding: 0 0.5rem;
}

.admin-form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

.form-help {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--color-text-light);
}

.form-error {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: #dc3545;
}

/* ───────────────────── Moderation ────────────────────────── */

.mod-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 720px;
}

.mod-card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  border-left: 4px solid #dc3545;
}

.mod-card__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.mod-card__title {
  font-size: 1.1rem;
  font-weight: 600;
}

.mod-card__badge {
  background: rgba(220, 53, 69, 0.15);
  color: #dc3545;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mod-card__meta {
  color: var(--color-text-light);
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.mod-card__reason {
  background: rgba(255, 165, 0, 0.08);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  margin: 0.5rem 0;
  color: var(--color-text);
}

.mod-card__preview {
  color: var(--color-text-light);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0.5rem 0;
}

.mod-card__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn--sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

/* ───────────────────── Inline avatar ─────────────────────── */

.inline-avatar {
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  display: inline-block;
  margin-right: 0.3em;
}

.inline-avatar--fallback {
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  text-align: center;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ───────────────────────── Profile ───────────────────────── */

.profile-card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 640px;
}

.profile-card__header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.profile-card__avatar {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
}

.profile-card__pic {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

.profile-card__initial {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
}

.profile-card__info {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.profile-card__name {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.profile-card__badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  width: fit-content;
}

.profile-card__badge--member {
  background: rgba(0, 119, 190, 0.15);
  color: var(--color-primary);
}

.profile-card__badge--moderator {
  background: rgba(255, 165, 0, 0.15);
  color: #e69500;
}

.profile-card__badge--admin {
  background: rgba(220, 53, 69, 0.15);
  color: #dc3545;
}

.profile-card__badge--type {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text-light);
}

.profile-card__section {
  margin-bottom: 1.5rem;
}

.profile-card__label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-light);
  margin-bottom: 0.5rem;
}

.profile-card__bio {
  color: var(--color-text);
  line-height: 1.6;
}

.profile-card__details {
  display: grid;
  gap: 0.5rem;
}

.profile-card__detail-row {
  display: flex;
  gap: 1rem;
}

.profile-card__detail-row dt {
  flex: 0 0 120px;
  color: var(--color-text-light);
  font-size: 0.9rem;
}

.profile-card__detail-row dd {
  margin: 0;
  font-size: 0.9rem;
}

.profile-card__actions {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Profile edit form */
.profile-form__avatar-section {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.profile-form__actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.75rem;
}

/* ───────────────────── Profile links ─────────────────────── */

.profile-link {
  color: inherit;
  text-decoration: none;
  font-weight: 500;
}
.profile-link:hover {
  text-decoration: underline;
  color: var(--color-primary);
}

.story-card__author-link {
  cursor: pointer;
  position: relative;
  z-index: 1;
}
.story-card__author-link:hover {
  text-decoration: underline;
  color: var(--color-primary);
}
