/* ==========================================================================
   Miki — clone stylesheet
   Design tokens extracted from the source Bettermode site.
   ========================================================================== */

:root {
  --color-primary: #c84062;
  --color-primary-hover: #9c2446;
  --color-primary-pressed: #7c1634;
  --color-deep-maroon: #530920;

  --color-bg: #f5f3ef;
  --color-surface: #ffffff;
  --color-border: #d5d4d0;

  --color-text: #070606;
  --color-text-subdued: #545452;
  --color-text-muted: #737270;

  --font-sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --radius-md: 0.5rem;
  --radius-pill: 9999px;

  --shadow-card: 0px 0px 0px 1px rgba(0, 0, 0, 0.05), 0px 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-pop: 0px 0px 0px 1px rgba(0, 0, 0, 0.05), 0px 8px 24px rgba(0, 0, 0, 0.16);

  --topbar-height: 64px;
  --sidebar-width: 272px;
}

:root[data-theme="dark"] {
  --color-primary: #e0587a;
  --color-primary-hover: #ec7592;
  --color-primary-pressed: #f4a3b7;
  --color-deep-maroon: #f3c7d2;

  --color-bg: #17151a;
  --color-surface: #211e24;
  --color-border: #37333b;

  --color-text: #f5f3ef;
  --color-text-subdued: #c9c6c2;
  --color-text-muted: #98948f;

  --shadow-card: 0px 0px 0px 1px rgba(0, 0, 0, 0.35), 0px 2px 4px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0px 0px 0px 1px rgba(0, 0, 0, 0.4), 0px 8px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html.shell-loading body { visibility: hidden; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); }

img { max-width: 100%; display: block; }

h1, h2, h3, h4 { color: var(--color-deep-maroon); line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; color: var(--color-text-subdued); }

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

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-pill);
  padding: 0.6em 1.4em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:active { background: var(--color-primary-pressed); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-ghost { background: transparent; color: var(--color-text-subdued); }
.btn-ghost:hover { background: rgba(200, 64, 98, 0.08); color: var(--color-primary); }
.btn-sm { padding: 0.4em 1em; font-size: 0.82rem; }

/* ---------- layout shell ---------- */
.app-shell { min-height: 100vh; }

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  z-index: 100;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  color: var(--color-text);
  min-width: 0;
  flex-shrink: 0;
}
.topbar-brand img { height: 26px; width: 26px; border-radius: 6px; object-fit: cover; }
.topbar-brand span { font-family: 'Georgia', serif; font-style: italic; font-size: 1.05rem; }
.topbar-brand span b { font-style: normal; font-weight: 700; }

.nav-toggle {
  display: none;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--color-text);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.topbar-search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 0.5em;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 0.45em 1em;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}
.topbar-search input {
  border: none; background: transparent; outline: none;
  font-family: var(--font-sans); font-size: 0.88rem; color: var(--color-text); width: 100%;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--color-text-subdued);
  position: relative;
}
.icon-btn:hover { background: var(--color-bg); color: var(--color-primary); }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-primary); border: 2px solid var(--color-surface);
}
.topbar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; cursor: pointer; border: 1px solid var(--color-border);
}

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding: 1rem 0.75rem 2rem;
  z-index: 90;
}
.sidebar-section { margin-bottom: 0.25rem; }
.sidebar-link, .sidebar-collection-toggle {
  display: flex;
  align-items: center;
  gap: 0.6em;
  width: 100%;
  padding: 0.55em 0.75em;
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
}
.sidebar-link:hover, .sidebar-collection-toggle:hover { background: var(--color-bg); color: var(--color-text); }
.sidebar-link.active {
  background: rgba(200, 64, 98, 0.12);
  color: var(--color-primary);
  font-weight: 700;
}
.sidebar-collection-toggle { color: var(--color-text-muted); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; justify-content: space-between; margin-top: 0.75rem; }
.sidebar-collection-toggle .chev { transition: transform 0.15s ease; font-size: 0.7rem; }
.sidebar-collection-toggle.collapsed .chev { transform: rotate(-90deg); }
.sidebar-children { display: flex; flex-direction: column; gap: 0.1rem; }
.sidebar-children.collapsed { display: none; }
.sidebar-icon { display: inline-flex; width: 1.2em; justify-content: center; }
.sidebar-copyright { font-size: 0.75rem; color: var(--color-text-muted); padding: 1rem 0.75em 0; }

/* ---------- main content ---------- */
.main-content {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
}
.content-inner { max-width: 880px; margin: 0 auto; padding: 2rem 1.75rem 4rem; }
.content-inner.wide { max-width: 1040px; }

/* ---------- cards ---------- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
}

/* ---------- hero / banners ---------- */
.hero-banner {
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
  position: relative;
}
.hero-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-banner.tall img { max-height: 320px; }
.hero-banner.short img { max-height: 160px; }
.hero-gradient {
  background: linear-gradient(135deg, var(--color-deep-maroon), var(--color-primary));
  color: #fff;
  padding: 3rem 2rem;
  border-radius: 0.75rem;
  text-align: center;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
}
.hero-gradient .hero-icon { font-size: 2.2rem; margin-bottom: 0.5rem; }
.hero-gradient h2 { color: #fff; margin: 0; }

.welcome-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}
.welcome-card h1 { margin-bottom: 0.35em; }
.welcome-card .welcome-copy { max-width: 560px; }
.welcome-card .welcome-actions { display: flex; gap: 0.75rem; flex-shrink: 0; }

/* ---------- section headers ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 2.25rem 0 1rem;
}
.section-head h2 { margin: 0; }
.section-head .view-all { font-size: 0.85rem; font-weight: 600; }

/* ---------- tutorial video grid ---------- */
.tutorial-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.tutorial-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.tutorial-thumb {
  height: 110px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary), var(--color-deep-maroon));
}
.tutorial-body { padding: 1rem; }
.tutorial-body h3 { margin-bottom: 0.35em; }
.tutorial-body p { font-size: 0.85rem; margin-bottom: 0; }

/* ---------- discussions tabs ---------- */
.tabs { display: flex; gap: 1.25rem; border-bottom: 1px solid var(--color-border); margin-bottom: 1rem; }
.tab-btn {
  border: none; background: none; font-family: var(--font-sans);
  font-weight: 600; font-size: 0.88rem; color: var(--color-text-muted);
  padding: 0.5em 0.1em 0.9em; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 2.5rem 1rem;
  font-size: 0.9rem;
}

/* ---------- space header ---------- */
.space-header { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.space-header .space-icon {
  font-size: 1.8rem; width: 56px; height: 56px; border-radius: var(--radius-md);
  background: var(--color-surface); box-shadow: var(--shadow-card);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.space-header .space-meta { flex: 1; min-width: 200px; }
.space-header .space-stats { font-size: 0.85rem; color: var(--color-text-muted); margin-top: 0.15em; }
.badge-joined {
  display: inline-flex; align-items: center; gap: 0.3em;
  background: rgba(200, 64, 98, 0.1); color: var(--color-primary);
  font-size: 0.78rem; font-weight: 700; padding: 0.3em 0.75em; border-radius: var(--radius-pill);
}

/* ---------- collection cards (Program Desk / Collaboration Space) ---------- */
.space-card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.space-card {
  background: var(--color-surface); border-radius: var(--radius-md); box-shadow: var(--shadow-card);
  padding: 1.25rem; display: flex; align-items: center; gap: 0.9rem;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.space-card:hover { box-shadow: var(--shadow-pop); transform: translateY(-1px); }
.space-card .icon { font-size: 1.6rem; width: 46px; height: 46px; border-radius: var(--radius-md); background: var(--color-bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.space-card .info h3 { margin-bottom: 0.2em; }
.space-card .info .stats { font-size: 0.82rem; color: var(--color-text-muted); }

/* ---------- lesson list ---------- */
.module-group { margin-bottom: 1.75rem; }
.module-group h3 { font-size: 1rem; margin-bottom: 0.6em; padding-bottom: 0.4em; border-bottom: 1px solid var(--color-border); }
.lesson-row {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.75em 0.5em; border-radius: var(--radius-md);
  cursor: pointer;
}
.lesson-row:hover { background: var(--color-surface); box-shadow: var(--shadow-card); }
.lesson-row .num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--color-bg);
  border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center; font-size: 0.75rem; color: var(--color-text-muted); flex-shrink: 0;
}
.lesson-row .title { font-size: 0.92rem; color: var(--color-text); }

.callout-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 1.5rem 0; }
.callout {
  border-radius: var(--radius-md); padding: 1.1rem; box-shadow: var(--shadow-card); background: var(--color-surface);
  border-top: 3px solid var(--color-primary);
}
.callout .tag { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; color: var(--color-primary); }
.callout h4 { margin: 0.35em 0 0.3em; color: var(--color-text); font-size: 0.95rem; }
.callout p { font-size: 0.85rem; margin: 0; }

.bullet-list { margin: 0.5rem 0 1.25rem; padding-left: 1.1rem; color: var(--color-text-subdued); }
.bullet-list li { margin-bottom: 0.4em; font-size: 0.92rem; }

.setup-steps { list-style: none; margin: 0 0 1.25rem; padding: 0; counter-reset: step; }
.setup-steps li {
  counter-increment: step;
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.75em 0.5em; border-radius: var(--radius-md);
}
.setup-steps li:hover { background: var(--color-surface); box-shadow: var(--shadow-card); }
.setup-steps li::before {
  content: counter(step);
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
}

.qa-callout {
  display: flex; align-items: center; gap: 0.85rem;
  background: var(--color-surface); border-radius: var(--radius-md); box-shadow: var(--shadow-card);
  padding: 1rem 1.25rem; margin: 1.75rem 0;
}
.qa-callout .avatar-mark { width: 40px; height: 40px; border-radius: 50%; background: var(--color-deep-maroon); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.qa-callout p { margin: 0; }

/* ---------- posts / discussion feed ---------- */
.post-card { background: var(--color-surface); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 1.5rem; margin-bottom: 1.25rem; }
.post-author { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.post-author img.avatar, .avatar-fallback {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.avatar-fallback { background: var(--color-deep-maroon); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.post-author .who b { display: block; font-size: 0.92rem; color: var(--color-text); }
.post-author .who span { font-size: 0.78rem; color: var(--color-text-muted); }
.post-body p { color: var(--color-text); }
.post-body .bullet-list { color: var(--color-text); }
.post-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--color-border); }
.post-actions { display: flex; gap: 1.5rem; }
.post-actions button { background: none; border: none; cursor: pointer; font-family: var(--font-sans); font-size: 0.85rem; font-weight: 600; color: var(--color-text-muted); display: flex; align-items: center; gap: 0.35em; }
.post-actions button:hover { color: var(--color-primary); }
.post-timestamp { font-size: 0.78rem; color: var(--color-text-muted); }
.comment-box { display: flex; align-items: center; gap: 0.75rem; margin-top: 1.25rem; }
.comment-box input { flex: 1; border: 1px solid var(--color-border); background: var(--color-bg); border-radius: var(--radius-pill); padding: 0.6em 1.1em; font-family: var(--font-sans); font-size: 0.88rem; color: var(--color-text); }
.comment-box input:focus { outline: none; border-color: var(--color-primary); }

/* ---------- settings page ---------- */
.settings-layout { display: flex; gap: 2.5rem; align-items: flex-start; }
.settings-nav { width: 200px; flex-shrink: 0; display: flex; flex-direction: column; gap: 0.2rem; position: sticky; top: calc(var(--topbar-height) + 2rem); }
.settings-nav button {
  text-align: left; background: none; border: none; font-family: var(--font-sans);
  padding: 0.6em 0.85em; border-radius: var(--radius-md); font-size: 0.92rem; font-weight: 600;
  color: var(--color-text-subdued); cursor: pointer;
}
.settings-nav button.active { background: rgba(200, 64, 98, 0.12); color: var(--color-primary); }
.settings-nav button:hover:not(.active) { background: var(--color-bg); }
.settings-panel { flex: 1; min-width: 0; }
.settings-panel h2 { margin-bottom: 1.5rem; }
.theme-options { display: flex; gap: 1rem; margin: 1.25rem 0 1.75rem; }
.theme-option {
  border: 2px solid var(--color-border); border-radius: var(--radius-md); padding: 1rem;
  width: 130px; cursor: pointer; text-align: center; background: var(--color-surface);
}
.theme-option.selected { border-color: var(--color-primary); }
.theme-preview { height: 60px; border-radius: 6px; margin-bottom: 0.6rem; }
.theme-preview.sync { background: linear-gradient(90deg, #fff 50%, #1c1a1f 50%); }
.theme-preview.light { background: #fff; border: 1px solid var(--color-border); }
.theme-preview.dark { background: #1c1a1f; }
.theme-option span { font-size: 0.82rem; font-weight: 600; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 0; border-bottom: 1px solid var(--color-border); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .label b { display: block; font-size: 0.92rem; color: var(--color-text); }
.toggle-row .label span { font-size: 0.82rem; color: var(--color-text-muted); }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--color-border); border-radius: var(--radius-pill); cursor: pointer; transition: background 0.15s ease; }
.switch .track::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.15s ease; }
.switch input:checked + .track { background: var(--color-primary); }
.switch input:checked + .track::before { transform: translateX(18px); }
.radio-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0; font-size: 0.9rem; }

/* ---------- member profile ---------- */
.profile-cover { height: 160px; border-radius: 0.75rem; background: linear-gradient(135deg, var(--color-deep-maroon), var(--color-primary)); position: relative; margin-bottom: 3.25rem; }
.profile-cover .cover-btn { position: absolute; right: 1rem; top: 1rem; }
.profile-identity { display: flex; align-items: flex-end; gap: 1.25rem; margin-top: -3.5rem; padding: 0 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.profile-avatar { width: 92px; height: 92px; border-radius: 50%; border: 4px solid var(--color-bg); background: var(--color-deep-maroon); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; flex-shrink: 0; }
.profile-identity .name-row { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-bottom: 0.4rem; }
.profile-tabs { display: flex; gap: 1.5rem; border-bottom: 1px solid var(--color-border); margin-bottom: 1.5rem; }
.profile-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; align-items: start; }
.about-card h3 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); }
.about-card dl { margin: 0; }
.about-card dt { font-size: 0.78rem; color: var(--color-text-muted); margin-top: 0.9rem; }
.about-card dd { margin: 0.15em 0 0; font-size: 0.9rem; color: var(--color-text); }

/* ---------- notifications ---------- */
.notif-item { display: flex; gap: 0.9rem; background: var(--color-surface); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 1.1rem 1.25rem; margin-bottom: 0.9rem; }
.notif-item .meta { flex: 1; }
.notif-item .meta .top-line { font-size: 0.88rem; color: var(--color-text); margin-bottom: 0.2em; }
.notif-item .meta .top-line b { color: var(--color-text); }
.notif-item .meta .sub-line { font-size: 0.78rem; color: var(--color-text-muted); margin-bottom: 0.5em; }
.notif-item .meta p { font-size: 0.88rem; margin-bottom: 0.4em; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .tutorial-grid { grid-template-columns: repeat(2, 1fr); }
  .space-card-grid { grid-template-columns: 1fr; }
  .callout-row { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .nav-toggle { display: flex; }
  .topbar-search { display: none; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-pop);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .tutorial-grid { grid-template-columns: 1fr; }
  .welcome-card { flex-direction: column; align-items: flex-start; }
  .settings-layout { flex-direction: column; }
  .settings-nav { width: 100%; flex-direction: row; overflow-x: auto; position: static; }
}
