/* StoryCircle — unified design system matching the landing page aesthetic */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=Space+Grotesk:wght@500;600;700&family=Instrument+Serif:ital@0;1&display=swap');

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

:root {
  --ink: #1a1a2e;
  --page: #faf8f5;
  --amber: #e8a838;
  --amber-glow: #f5c563;
  --amber-dark: #c4891e;
  --deep-plum: #4a2c6a;
  --deep-plum-light: #5e3a84;
  --soft-lavender: #e8dff0;
  --warm-grey: #9a9494;
  --card-bg: #ffffff;
  --border: rgba(26,26,46,0.10);
  --shadow-sm: 0 1px 4px rgba(26,26,46,0.06);
  --shadow-md: 0 4px 20px rgba(26,26,46,0.09);
  --shadow-lg: 0 8px 40px rgba(26,26,46,0.12);
  --radius: 14px;
  --radius-sm: 8px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--page);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- NAV ---- */
.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250,248,245,0.90);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--deep-plum);
  letter-spacing: -0.3px;
  text-decoration: none;
}
.nav-logo span { color: var(--amber); }
.nav-links { display: flex; align-items: center; gap: 0.5rem; }
.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--warm-grey);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  transition: color 0.2s, background 0.2s;
}
.nav-link:hover { color: var(--ink); background: var(--soft-lavender); }
.nav-link.active { color: var(--deep-plum); }
.nav-btn {
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: var(--deep-plum);
  border: none;
  padding: 0.45rem 1.1rem;
  border-radius: 20px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s;
}
.nav-btn:hover { background: var(--deep-plum-light); transform: translateY(-1px); }

/* ---- LANDING ---- */
.landing-hero {
  min-height: 92vh;
  display: flex;
  align-items: center;
  padding: 6rem 2rem 4rem;
  position: relative;
  overflow: hidden;
}
.landing-hero::before {
  content: '';
  position: absolute;
  top: -10%;
  right: -5%;
  width: 500px; height: 500px;
  background: radial-gradient(circle, var(--soft-lavender) 0%, transparent 70%);
  pointer-events: none;
}
.hero-content { max-width: 620px; position: relative; }
.hero-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber-dark);
  background: rgba(232,168,56,0.12);
  border-radius: 20px;
  padding: 0.3rem 0.9rem;
  margin-bottom: 1.5rem;
}
.hero-content h1 {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(2.5rem, 6vw, 4.2rem);
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 1.25rem;
  letter-spacing: -1px;
}
.hero-content h1 em {
  font-style: italic;
  color: var(--deep-plum);
}
.hero-content p {
  font-size: 1.1rem;
  color: var(--warm-grey);
  max-width: 480px;
  margin-bottom: 2rem;
}
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--deep-plum);
  border: none;
  border-radius: var(--radius);
  padding: 0.8rem 1.75rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(74,44,106,0.3);
}
.btn-primary:hover { background: var(--deep-plum-light); transform: translateY(-2px); box-shadow: 0 6px 24px rgba(74,44,106,0.38); }
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1.75rem;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
}
.btn-secondary:hover { border-color: var(--deep-plum); background: var(--soft-lavender); }
.btn-amber {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--amber);
  border: none;
  border-radius: var(--radius);
  padding: 0.8rem 1.75rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s;
}
.btn-amber:hover { background: var(--amber-glow); transform: translateY(-1px); }
.btn-sm {
  font-size: 0.82rem;
  padding: 0.45rem 1.05rem;
  border-radius: var(--radius-sm);
}
.btn-danger {
  background: #dc2626; color: white; border: none;
}
.btn-danger:hover { background: #b91c1c; }

/* ---- SECTIONS ---- */
.features-section { padding: 5rem 2rem; }
.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber-dark);
  margin-bottom: 0.75rem;
}
.section-title {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 1rem;
}
.section-sub {
  font-size: 1rem;
  color: var(--warm-grey);
  max-width: 460px;
  margin-bottom: 3rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}
.feature-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  transition: box-shadow 0.2s, transform 0.2s;
}
.feature-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.feature-icon {
  width: 48px; height: 48px;
  background: var(--soft-lavender);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 1.25rem;
}
.feature-card h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.feature-card p { font-size: 0.9rem; color: var(--warm-grey); line-height: 1.55; }

/* ---- APP LAYOUT ---- */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 60px);
}
.sidebar {
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.sidebar-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--warm-grey);
  padding: 0.5rem 0.75rem;
  margin-top: 0.75rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--warm-grey);
  text-decoration: none;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.sidebar-link:hover { color: var(--ink); background: var(--soft-lavender); }
.sidebar-link.active { color: var(--deep-plum); background: rgba(74,44,106,0.08); font-weight: 600; }
.sidebar-icon { font-size: 1rem; opacity: 0.8; }
.main-content { padding: 2rem 2.5rem; max-width: 900px; }

/* ---- CARDS & LISTS ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-sm); }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}
.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.card-meta {
  font-size: 0.8rem;
  color: var(--warm-grey);
}
.card-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  background: var(--soft-lavender);
  color: var(--deep-plum);
}
.badge-amber { background: rgba(232,168,56,0.15); color: var(--amber-dark); }

/* ---- PAGE HEADER ---- */
.page-header {
  margin-bottom: 2rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 {
  font-family: 'Instrument Serif', serif;
  font-size: 2rem;
  color: var(--ink);
  line-height: 1.2;
}
.page-header .sub {
  font-size: 0.9rem;
  color: var(--warm-grey);
  margin-top: 0.25rem;
}

/* ---- FORMS ---- */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.45rem;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--deep-plum);
  box-shadow: 0 0 0 3px rgba(74,44,106,0.10);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: 0.8rem; color: var(--warm-grey); margin-top: 0.3rem; }
.form-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
}

/* ---- AUTH PAGE ---- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page);
  padding: 2rem;
}
.auth-box {
  width: 100%;
  max-width: 400px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: var(--shadow-md);
}
.auth-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--deep-plum);
  text-align: center;
  margin-bottom: 0.25rem;
}
.auth-logo span { color: var(--amber); }
.auth-subtitle { text-align: center; font-size: 0.875rem; color: var(--warm-grey); margin-bottom: 2rem; }
.auth-switch { text-align: center; font-size: 0.875rem; color: var(--warm-grey); margin-top: 1.5rem; }
.auth-switch a { color: var(--deep-plum); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ---- PROGRESS BAR ---- */
.progress-bar-wrap {
  background: var(--soft-lavender);
  border-radius: 100px;
  height: 6px;
  overflow: hidden;
  margin-top: 0.5rem;
}
.progress-bar-fill {
  background: linear-gradient(90deg, var(--deep-plum), var(--amber));
  height: 100%;
  border-radius: 100px;
  transition: width 0.4s ease;
}

/* ---- CHAPTER DISCUSSION ---- */
.chapter-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.chapter-tab {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  background: var(--soft-lavender);
  color: var(--deep-plum);
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
.chapter-tab.active, .chapter-tab:hover { background: var(--deep-plum); color: white; }
.discussion-post {
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--soft-lavender);
  margin-bottom: 1rem;
  background: var(--card-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.post-author { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.25rem; color: var(--deep-plum); }
.post-body { font-size: 0.9rem; line-height: 1.55; }
.post-time { font-size: 0.75rem; color: var(--warm-grey); margin-top: 0.35rem; }

/* ---- STORY READER ---- */
.story-chapter {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.story-chapter h2 {
  font-family: 'Instrument Serif', serif;
  font-size: 1.4rem;
  color: var(--deep-plum);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.story-chapter p, .chapter-text {
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--ink);
  white-space: pre-wrap;
}
.continue-box {
  background: linear-gradient(135deg, var(--soft-lavender) 0%, rgba(232,223,240,0.4) 100%);
  border: 1px solid rgba(74,44,106,0.15);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-top: 1.5rem;
}
.continue-box h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--deep-plum);
}

/* ---- MEMBER LIST ---- */
.member-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.member-item:last-child { border-bottom: none; }
.member-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--soft-lavender);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--deep-plum);
  flex-shrink: 0;
}
.member-name { font-weight: 500; font-size: 0.9rem; }
.member-role { font-size: 0.75rem; color: var(--warm-grey); }

/* ---- INVITE CODE ---- */
.invite-code-box {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--soft-lavender);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--deep-plum);
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}
.invite-code-box:hover { background: rgba(74,44,106,0.12); }
.invite-copy-hint { font-size: 0.75rem; color: var(--warm-grey); margin-top: 0.35rem; }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--warm-grey);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; color: var(--ink); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.9rem; margin-bottom: 1.5rem; }

/* ---- DASHBOARD ---- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.stat-number {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--deep-plum);
  line-height: 1;
}
.stat-label { font-size: 0.85rem; color: var(--warm-grey); margin-top: 0.35rem; }

/* ---- UTILITIES ---- */
.text-muted { color: var(--warm-grey); }
.text-plum { color: var(--deep-plum); }
.text-amber { color: var(--amber-dark); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
a { color: inherit; }

/* ---- LOADING ---- */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-content { padding: 1.25rem 1rem; }
  .hero-content h1 { font-size: 2.2rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .app-nav { padding: 0.85rem 1rem; }
  .story-chapter { padding: 1.5rem 1.25rem; }
}
@media (max-width: 480px) {
  .auth-box { padding: 1.75rem 1.25rem; }
  .page-header { flex-direction: column; }
}

/* ---- PWA Install Banner ---- */
#sc-install-banner,
#sc-ios-tip {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: calc(100% - 2rem);
  max-width: 480px;
  background: #fff;
  border: 1px solid rgba(74,44,106,0.15);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#sc-install-banner.sc-install-hidden,
#sc-ios-tip.sc-install-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(1rem);
  pointer-events: none;
}
.sc-install-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
}
.sc-install-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
}
.sc-install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.sc-install-text strong {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--deep-plum);
  white-space: nowrap;
}
.sc-install-text span {
  font-size: 0.78rem;
  color: var(--warm-grey);
  line-height: 1.4;
}
.sc-install-btn {
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: var(--deep-plum);
  border: none;
  border-radius: 10px;
  padding: 0.45rem 1rem;
  cursor: pointer;
  white-space: nowrap;
}
.sc-install-btn:hover { background: var(--deep-plum-light); }
.sc-install-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--warm-grey);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem 0.35rem;
  border-radius: 6px;
  line-height: 1;
}
.sc-install-close:hover { background: var(--soft-lavender); }
