/* g2g-v2 mobile redesign: black & white, light, mobile-first */

:root {
  --bg: #ffffff;
  --surface: #f5f5f5;
  --surface-2: #fafafa;
  --text: #000000;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --border: #e5e5e5;
  --accent: #d9352c;
  --radius: 14px;
  --radius-sm: 8px;
  --tap: 44px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-h: 56px;
  --nav-h: 45px;
}

body.m-theme-dark {
  --bg: #0a0a0a;
  --surface: #1f1f1f;
  --surface-2: #181818;
  --text: #f2f2f2;
  --text-secondary: #a3a3a3;
  --text-tertiary: #737373;
  --border: #2a2a2a;
}

body, .m-header, .m-nav, .m-date-strip, .m-date-chip, .m-free-toggle, .m-event-card, .m-day-header, .m-sheet, .m-calendar-sheet, .m-edit-sheet, .m-edit-overlay, .m-user-sheet {
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  min-height: var(--tap);
  min-width: var(--tap);
}

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

/* Layout helpers */
.m-app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}

.m-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  color: var(--text);
}

body.m-theme-dark .m-header {
  background: rgba(10, 10, 10, 0.92);
}

.m-header__logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.m-header__actions {
  display: flex;
  gap: 4px;
}

.m-icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 20px;
  color: var(--text);
  transition: background 0.15s;
}

.m-icon-btn:active {
  background: var(--surface);
}

.m-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

body.m-theme-dark .m-nav {
  background: rgba(10, 10, 10, 0.96);
}

.m-nav__inner {
  max-width: 480px;
  margin: 0 auto;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.m-nav__item {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.m-nav__item.active {
  color: var(--text);
}

.m-nav__item span {
  font-size: 22px;
  line-height: 1;
}

/* Date strip */
.m-date-strip {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 8px 12px;
}

.m-header,
.m-date-strip {
  transition: transform 0.2s ease;
}

body.m-header-hidden .m-header {
  transform: translateY(-110%);
}

body.m-header-hidden .m-date-strip {
  transform: translateY(calc(-100% - var(--header-h)));
}

.m-date-strip::-webkit-scrollbar {
  display: none;
}

.m-date-strip__list {
  display: flex;
  gap: 6px;
}

.m-date-chip {
  flex-shrink: 0;
  min-width: 64px;
  padding: 8px 12px;
  border-radius: 100px;
  text-align: center;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.m-date-chip.active {
  background: var(--text);
  color: var(--bg);
}

.m-date-chip__day {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.m-date-chip__num {
  font-size: 16px;
  font-weight: 700;
}

.m-date-chip--calendar {
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.m-date-chip--calendar .m-date-chip__day {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Event list */
.m-feed {
  padding: 0 0 80px;
}

.m-day-header {
  position: sticky;
  top: calc(var(--header-h) + 60px);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg);
  padding: 12px 16px 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.m-free-toggle {
  flex-shrink: 0;
  min-width: auto;
  padding: 8px 12px;
  border-radius: 100px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  transition: all 0.15s;
}

.m-free-toggle.active {
  background: var(--text);
  color: var(--bg);
}

.m-event-card {
  display: block;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  transition: background 0.15s;
}

.m-event-card:active {
  background: var(--surface-2);
}

.m-event-card__title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 6px;
}

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

.m-event-card__title a:hover {
  text-decoration: underline;
}

.m-event-card__meta {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.m-event-card__meta span + span::before {
  content: "•";
  margin: 0 6px;
  color: var(--text-tertiary);
}

.m-event-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.m-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.m-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.m-pill--category {
  background: var(--text);
  color: var(--bg);
}

.m-pill--free {
  background: var(--surface);
  color: var(--text);
}

.m-fav-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-tertiary);
  border-radius: 50%;
}

.m-fav-btn.active {
  color: var(--accent);
}

.m-fav-btn:active {
  background: var(--surface);
}

.m-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
}

.m-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Bottom sheet */
.m-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.m-sheet-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.m-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 101;
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px 16px calc(24px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.25s ease-out;
  max-height: 80vh;
  overflow-y: auto;
}

.m-sheet.open {
  transform: translateY(0);
}

.m-sheet--full {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
}

.m-sheet__handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.m-sheet__title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 16px;
}

.m-filter-group {
  margin-bottom: 20px;
}

.m-filter-group__label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.m-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.m-filter-chip {
  padding: 8px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  min-height: 36px;
}

.m-filter-chip.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.m-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-size: 16px;
  font-weight: 700;
  min-height: var(--tap);
}

.m-btn--secondary {
  background: var(--surface);
  color: var(--text);
}

/* Event page */
.m-event-page {
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}

.m-event-hero {
  position: relative;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.m-event-hero__back {
  position: absolute;
  top: 12px;
  left: 8px;
  z-index: 10;
}

.m-event-hero__fav {
  position: absolute;
  top: 12px;
  right: 8px;
  z-index: 10;
}

.m-event-hero__title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  margin: 40px 0 12px;
  letter-spacing: -0.03em;
}

.m-event-hero__meta {
  font-size: 15px;
  color: var(--text-secondary);
}

.m-event-section {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}

.m-event-section__label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.m-event-section__text {
  font-size: 16px;
  color: var(--text);
  white-space: pre-line;
}

.m-event-section__text a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.m-event-actions {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.m-event-actions__row {
  display: flex;
  gap: 10px;
}

.m-event-actions__row .m-btn {
  flex: 1;
}

/* Database */
.m-db-tabs {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
}

.m-db-tab {
  flex: 1;
  padding: 14px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
}

.m-db-tab.active {
  color: var(--text);
  border-color: var(--text);
}

.m-search {
  position: relative;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.m-search input {
  width: 100%;
  padding: 12px 40px 12px 16px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 15px;
  outline: none;
}

.m-search__clear {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
}

.m-db-list {
  padding-bottom: 100px;
}

.m-db-card {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.m-db-card__title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.m-db-card__meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.m-db-card__actions {
  display: flex;
  gap: 8px;
}

.m-db-card__actions .m-btn {
  flex: 1;
  padding: 10px;
  font-size: 14px;
}

.m-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.m-badge--approved {
  background: var(--text);
  color: var(--bg);
}

.m-badge--pending {
  background: var(--surface);
  color: var(--text-secondary);
}

.m-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-h) + 16px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 40;
}

/* Toast */
.m-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 20px);
  transform: translateX(-50%) translateY(100px);
  z-index: 200;
  background: var(--text);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.25s;
}

.m-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Calendar */
.m-calendar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.m-calendar__month {
  font-size: 17px;
  font-weight: 700;
  text-transform: capitalize;
}

.m-calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.m-calendar__weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  padding: 8px 0;
}

.m-calendar__day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  min-height: 44px;
}

.m-calendar__day:active {
  opacity: 0.7;
}

.m-calendar__day--padding {
  background: transparent;
  color: var(--text-tertiary);
}

.m-calendar__day--today {
  border: 1px solid var(--text);
}

.m-calendar__day--selected {
  background: var(--text);
  color: var(--bg);
}

/* Utils */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
