:root {
  color-scheme: light;
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --text: #202124;
  --muted: #62635f;
  --line: #ddded8;
  --primary: #0b6b5f;
  --primary-strong: #084d45;
  --accent: #c57f1f;
  --blue: #2457a6;
  --danger: #b42318;
  --success: #13795b;
  --shadow: 0 18px 40px rgba(32, 33, 36, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(11, 107, 95, 0.1), transparent 32rem),
    linear-gradient(315deg, rgba(197, 127, 31, 0.12), transparent 28rem),
    var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 72px;
  padding: 0.8rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 246, 242, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  flex: 0 0 auto;
}

.brand-mark svg {
  width: 25px;
  height: 25px;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  margin-top: 0.15rem;
  color: var(--muted);
}

[hidden] {
  display: none !important;
}

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

.auth-status {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0.7rem 0.8rem;
  outline: none;
}

.field textarea {
  resize: vertical;
  line-height: 1.45;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 107, 95, 0.14);
}

.app-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

.login-shell {
  display: grid;
  width: min(460px, calc(100% - 2rem));
  min-height: calc(100vh - 104px);
  margin: 0 auto;
  place-items: center stretch;
  padding: 2rem 0;
}

.login-card {
  display: grid;
  gap: 1rem;
  padding: clamp(1rem, 4vw, 1.4rem);
}

.view-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(132px, 1fr));
  gap: 0.35rem;
  padding: 0.35rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.tab-button,
.primary-button,
.secondary-button,
.danger-button,
.success-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  color: var(--text);
  background: transparent;
  font-weight: 800;
  text-decoration: none;
}

.tab-button {
  min-width: 132px;
}

.tab-button span {
  white-space: nowrap;
}

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

.primary-button,
.success-button {
  background: var(--primary);
  color: #fff;
}

.primary-button:hover,
.success-button:hover {
  background: var(--primary-strong);
}

button:disabled,
.primary-button:disabled,
.success-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  border-color: var(--line);
  background: var(--surface);
}

.secondary-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

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

.icon-button {
  width: 40px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--primary);
  font-size: 0.77rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 3rem);
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.35rem;
}

h3 {
  margin: 0;
  font-size: 1rem;
}

.event-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 1rem;
  align-items: start;
}

.event-list {
  display: grid;
  gap: 0.8rem;
}

.event-card,
.event-detail,
.editor-grid,
.rsvp-card,
.calendar-sync,
.login-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.event-card {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
}

.event-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 107, 95, 0.14), var(--shadow);
}

.event-card.cancelled {
  border-color: rgba(180, 35, 24, 0.45);
  background: rgba(255, 255, 255, 0.72);
}

.event-card button {
  text-align: left;
}

.event-card-main {
  display: grid;
  gap: 0.35rem;
  border: 0;
  background: transparent;
  padding: 0;
}

.event-meta,
.invite-meta,
.rsvp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.invite-error {
  margin: 0;
  border-left: 3px solid var(--danger);
  padding: 0.45rem 0.65rem;
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
  font-size: 0.86rem;
  line-height: 1.35;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 28px;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.pill.accepted {
  background: rgba(19, 121, 91, 0.12);
  color: var(--success);
}

.pill.declined {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

.pill.cancelled {
  background: rgba(180, 35, 24, 0.16);
  color: var(--danger);
}

.pill.pending {
  background: rgba(197, 127, 31, 0.16);
  color: #805214;
}

.event-detail {
  position: sticky;
  top: 92px;
  min-height: 360px;
  padding: 1rem;
}

.detail-stack {
  display: grid;
  gap: 1rem;
}

.detail-header {
  display: grid;
  gap: 0.5rem;
}

.detail-actions,
.invite-actions,
.rsvp-actions,
.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.invite-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.invite-list {
  display: grid;
  gap: 0.65rem;
}

.invite-item {
  display: grid;
  gap: 0.45rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.invite-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.link-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 0.45rem;
}

.link-field input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  background: var(--surface-2);
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 1rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.span-2 {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.calendar-sync {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 480px);
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
  padding: 1rem;
}

.sync-copy {
  margin: 0.4rem 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.sync-panel {
  display: grid;
  width: 100%;
  gap: 0.75rem;
}

.sync-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.rsvp-panel {
  max-width: 760px;
}

.invite-shell {
  display: grid;
  width: min(760px, calc(100% - 2rem));
  min-height: calc(100vh - 92px);
  margin: 0 auto;
  padding: clamp(1.25rem, 5vw, 4rem) 0;
  place-items: start stretch;
}

.invite-topbar {
  justify-content: center;
}

.rsvp-card {
  display: grid;
  gap: 1rem;
  padding: clamp(1rem, 3vw, 1.5rem);
}

.invite-card {
  width: 100%;
}

.rsvp-card .status-line {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  background: var(--surface-2);
  font-weight: 900;
}

.calendar-options {
  display: grid;
  gap: 0.75rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.empty-state,
.loading-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  align-content: center;
  gap: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.empty-state svg,
.loading-state svg {
  width: 42px;
  height: 42px;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  max-width: min(380px, calc(100% - 2rem));
  transform: translateY(1rem);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: #202124;
  color: #fff;
  padding: 0.8rem 0.95rem;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 840px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-actions {
    justify-content: space-between;
  }

  .view-tabs {
    width: 100%;
  }

  .event-layout,
  .editor-grid,
  .calendar-sync {
    grid-template-columns: 1fr;
  }

  .event-detail {
    position: static;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 1rem, 1180px);
    margin-top: 1rem;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button span,
  .secondary-button span,
  .danger-button span,
  .success-button span {
    display: none;
  }

  .view-tabs {
    grid-template-columns: minmax(0, 1fr) minmax(88px, auto);
  }

  .tab-button {
    min-width: 0;
    padding-inline: 0.8rem;
  }

  .tab-button,
  .primary-button,
  .secondary-button,
  .danger-button,
  .success-button {
    min-width: 44px;
  }
}
