/* ═══════════════════════════════════════════════
   LAYOUT — Header, tabs, month bar, content
   ═══════════════════════════════════════════════ */

/* ── App Screen ────────────────────────────────── */
#app-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Main column — wraps everything right of the sidebar on desktop,
   full width on mobile. */
.main-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

/* ── Header ────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 52px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-faint);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

header h1 {
  font-family: var(--font-logo);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  flex-shrink: 0;
}

header h1 span { color: var(--color-primary); }

/* ── Tab Row ───────────────────────────────────── */
#tab-row {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  position: sticky;
  top: 52px;
  z-index: 99;
}

#main-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tab-btn {
  padding: 0 16px;
  height: 40px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-faint);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-base);
  letter-spacing: 0.01em;
}

.tab-btn:hover { color: var(--text-muted); }

.tab-btn.active {
  color: var(--text);
  border-bottom: 2px solid var(--color-primary);
}

/* ── Mobile header actions (Shop · Theme · Avatar) ─ */
.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--hairline);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.header-icon-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

.header-icon-btn img {
  width: 18px;
  height: 18px;
  display: block;
}

.header-avatar-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: var(--red);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease;
}

.header-avatar-btn:hover { transform: scale(1.04); }

.header-avatar-initial {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--paper);
  line-height: 1;
  user-select: none;
}

/* ── Mobile account menu popover ──────────────── */
.avatar-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 12px;
  min-width: 180px;
  background: var(--paper-deep);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 110;
}

.avatar-menu[hidden] { display: none; }

.avatar-menu-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 8px;
  border-bottom: 1px solid var(--hairline);
}

.avatar-menu-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--red);
  color: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar-menu-name {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.avatar-menu-item {
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--transition);
}

.avatar-menu-item:hover { background: rgba(42, 31, 26, 0.06); }

.avatar-menu-footer {
  padding: 6px 10px 2px;
  font-family: var(--font-body);
  font-size: 0.68rem;
  color: var(--ink-faint);
  border-top: 1px solid var(--hairline);
}

/* ═══════════════════════════════════════════════
   MONTH HEADER (PO07) — Editorial Option A
   Mobile: sticky #month-bar with Fraunces upgrade.
   Desktop: bar is hidden; .month-heading-editorial
   renders inside the My Log content stack.
   ═══════════════════════════════════════════════ */

/* ── Mobile sticky bar ───────────────────────── */
#month-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--paper-edge);
  gap: 8px;
  position: sticky;
  top: 52px;
  z-index: 98;
}

#current-month-label {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.01em;
}

#current-month-label em {
  font-style: italic;
  font-weight: 400;
  color: var(--red);
  font-size: 0.88rem;
}

#current-month-label .mhe-m-day {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 0.56rem;
  font-weight: 400;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

#month-bar-nav {
  display: flex;
  align-items: center;
  gap: 3px;
}

#month-bar button {
  background: none;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--ink-faint);
  transition: color var(--transition);
  flex-shrink: 0;
  cursor: pointer;
}

#month-bar button[hidden] { display: none !important; }

#month-bar button:hover:not(:disabled) { color: var(--red); }

#month-bar button:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

#cal-picker-btn .showup-icon { width: 16px; height: 16px; }

/* ── Desktop editorial heading ───────────────── */
.month-heading-editorial {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 18px 0 14px;
  margin-bottom: 12px;
  border-bottom: 1px dashed var(--hairline);
}

.mhe-top {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.mhe-month {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.mhe-month em {
  font-style: italic;
  font-weight: 400;
  color: var(--red);
}

.mhe-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
  top: -2px;
}

.mhe-btn {
  background: none;
  border: 1px solid var(--hairline);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--ink-faint);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  padding: 0;
}

.mhe-btn:hover:not(:disabled) {
  border-color: var(--red);
  color: var(--red);
}

.mhe-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.mhe-btn .showup-icon {
  width: 14px;
  height: 14px;
}

.mhe-sub {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}

/* ── Main Content ───────────────────────────────── */
#app-content {
  flex: 1;
  padding: 24px 28px;
  /* No background: lets the ambient texture show through around cards. */
}

.tab-panel {
  width: 100%;
  animation: tabFadeIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Mobile Bottom Nav (M3 variant) ────────────── */
#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--paper);
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  padding: 6px 6px 8px;
  gap: 4px;
}

/* Stripe top border — red / yellow / blue gradient per spec §6 */
#bottom-nav::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right,
    var(--red) 0 33%,
    var(--yellow) 33% 66%,
    var(--blue) 66% 100%);
}

.bottom-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 4px;
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--ink-faint);
  background: none;
  border: none;
  gap: 3px;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  font-family: var(--font-body);
  border-radius: var(--r-md);
}

.bottom-tab.active {
  background: var(--ink);
  color: var(--paper);
}

.bottom-tab-icon {
  width: 22px;
  height: 22px;
  display: block;
}

/* ── Month Heading ─────────────────────────────── */
.month-heading {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}

/* ── Back to Top ─────────────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 90;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s, background 0.15s, color 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--red);
  color: var(--paper);
  border-color: var(--red);
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 767px) {
  #tab-row { display: none; }
  #bottom-nav { display: flex; }
  #app-content { padding: 16px 16px 80px; }
  header { padding: 0 14px; height: 52px; }
  .back-to-top { bottom: 76px; right: 16px; }
  #global-loader { top: 93px; }
  .sidebar { display: none; }
}

/* ═══════════════════════════════════════════════
   SIDEBAR (desktop V3 Hybrid 1)
   Per MIXTAPE_SPEC §6.
   ═══════════════════════════════════════════════ */

.sidebar { display: none; } /* default: hidden until desktop */

@media (min-width: 768px) {
  #app-screen {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: auto;
    align-items: stretch;
  }

  /* Hide legacy header + tab row on desktop; sidebar replaces them.
     Month bar is mobile-only on desktop the editorial heading inside
     .mylog-centered-stack carries month name + nav (PO07). */
  .main-col > header,
  .main-col > #tab-row { display: none; }
  #month-bar { display: none; }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 24px 14px 16px;
    background: rgba(236, 225, 198, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-right: 1px solid var(--hairline);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 50;
  }

  [data-theme="side-b"] .sidebar {
    background: rgba(46, 27, 26, 0.78);
    border-right-color: var(--hairline);
  }
}

/* ── Sidebar top (motif + logo) ───────────────── */
.sb-top {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 6px 0;
}

.sb-motif {
  width: 44px;
  height: 12px;
  display: block;
}

.sb-motif-squiggle { stroke: var(--red); }
.sb-motif-dot      { fill:   var(--yellow); }
.sb-motif-star     { fill:   var(--red); }

.sb-logo {
  font-family: var(--font-logo);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1;
}

.sb-logo span { color: var(--red); }

/* ── Sidebar nav ──────────────────────────────── */
.sb-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sb-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border: none;
  background: none;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.sb-nav-item:hover {
  background: rgba(42, 31, 26, 0.05);
  color: var(--ink);
}

.sb-nav-item.active {
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

.sb-nav-item.active:hover {
  background: var(--ink);
}

.sb-nav-num {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  min-width: 18px;
}

.sb-nav-item.active .sb-nav-num {
  color: var(--red);
}

/* ── Sidebar foot ─────────────────────────────── */
.sb-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 6px 4px;
  border-top: 1px solid var(--hairline);
}

.sb-user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.sb-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--red);
  color: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sb-user-name {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-foot-actions {
  display: flex;
  gap: 6px;
}

.sb-foot-btn {
  flex: 1;
  padding: 4px 10px;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.sb-foot-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ── Side A / Side B theme pill (Step 8) ────────
   Two-segment pill used in sidebar foot (desktop) and mobile header.
   Active segment = ink fill + paper text, same vocabulary as sidebar
   nav active pill per spec §6. */
.theme-pill {
  display: flex;
  padding: 2px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-full);
  background: transparent;
  align-self: stretch;
}

.theme-pill-seg {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  line-height: 0;
  transition: background var(--transition), color var(--transition);
}

.theme-pill-seg:hover {
  color: var(--ink);
}

.theme-pill-seg[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.theme-pill-seg[aria-pressed="true"]:hover {
  color: var(--paper);
}

/* Mobile header variant: content-sized (not stretched), tighter padding */
.theme-pill--header {
  display: inline-flex;
  align-self: auto;
}

.theme-pill--header .theme-pill-seg {
  flex: 0 0 auto;
  padding: 5px 9px;
}
