:root {
  --bg-start: #edf4ff;
  --bg-end: #fff6e8;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #526077;
  --border: #d7dfeb;
  --accent: #0f766e;
  --accent-strong: #0c5e58;
  --danger: #b91c1c;
  --danger-strong: #991b1b;
  --chip-bg: #eefaf8;
  --chip-border: #bde6de;
  --font-body: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  --font-display: "Fraunces", "Georgia", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(70rem 28rem at -18% -12%, rgba(59, 130, 246, 0.15), transparent 60%),
    radial-gradient(55rem 30rem at 112% 0%, rgba(245, 158, 11, 0.12), transparent 62%),
    linear-gradient(150deg, var(--bg-start), var(--bg-end));
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-strong);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
}

.brand-block {
  display: grid;
  gap: 0.1rem;
}

.brand-title {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
  line-height: 1.1;
}

.brand-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.theme-toggle-btn {
  min-width: 104px;
}

.topbar-status {
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  padding: 0.5rem;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
}

.menu-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  background: #334155;
  border-radius: 2px;
}

.app-shell {
  max-width: 1160px;
  margin: 0 auto;
  min-height: calc(100vh - 70px);
  display: grid;
  gap: 1rem;
  padding: 1.2rem;
  align-content: start;
}

.app-shell.single-column {
  justify-items: center;
}

.app-shell.two-column {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

.narrow-panel {
  width: 100%;
  max-width: 560px;
}

.app {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.8rem;
}

.stack {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.control-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  margin: 0;
}

.settings-card .eyebrow {
  margin-bottom: 0.6rem;
}

.settings-card form + form {
  margin-top: 0.6rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.toolbar input[type="search"] {
  min-width: 200px;
  flex: 1 1 220px;
}

#invite-link {
  flex: 1 1 320px;
}

.danger-toolbar {
  justify-content: flex-start;
}

.pager {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.8rem;
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.calendar-month-label {
  font-family: var(--font-display);
  font-size: 1.02rem;
  color: #0f172a;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.38rem;
}

.calendar-weekday,
.calendar-day {
  border-radius: 10px;
  text-align: center;
}

.calendar-weekday {
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  background: #f5f7fb;
  border: 1px solid var(--border);
  padding: 0.42rem 0.2rem;
}

.calendar-day {
  border: 1px solid var(--border);
  background: #ffffff;
  color: #1f2937;
  font-size: 0.86rem;
  padding: 0.52rem 0.2rem;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.calendar-day:hover {
  border-color: #8fb8b1;
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.14);
}

.calendar-day.is-other-month {
  color: #94a3b8;
  background: #f8fafc;
}

.calendar-day.is-today {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
  font-weight: 700;
}

.calendar-day.is-selected {
  border-color: #0f766e;
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.2);
}

.calendar-day.has-events::after {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--event-dot, #0f766e);
  margin: 0.22rem auto 0;
}

.calendar-selected {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.compact-list {
  gap: 0.45rem;
}

.compact-list .card {
  padding: 0.62rem;
}

.event-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin-top: 0.12rem;
}

.event-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.48rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.74rem;
  font-weight: 700;
}

.event-tag.tag-day-off {
  background: #ecfdf5;
  color: #0f766e;
  border-color: #99f6e4;
}

.event-tag.tag-they-call-you-back {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.event-tag.tag-you-call-them-back {
  background: #f5f3ff;
  color: #6d28d9;
  border-color: #ddd6fe;
}

.event-tag.tag-creator {
  background: #f8fafc;
  color: #334155;
  border-color: #cbd5e1;
}

.hidden {
  display: none !important;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 1rem 0.95rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.07);
}

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #0f766e;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0 0 0.55rem;
  color: #0f172a;
  font-family: var(--font-display);
  font-weight: 700;
}

h1 {
  font-size: 1.35rem;
}

h2 {
  font-size: 1.15rem;
}

h3 {
  font-size: 1rem;
}

.form-grid,
.note-form {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.95rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #c8d2e2;
  border-radius: 10px;
  padding: 0.62rem 0.72rem;
  background: #fff;
  color: var(--ink);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.22);
  outline-offset: 1px;
  border-color: #0f766e;
}

textarea {
  resize: vertical;
}

button {
  border: 1px solid transparent;
  background: var(--accent);
  color: #ffffff;
  border-radius: 10px;
  padding: 0.62rem 0.85rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary-btn {
  border-color: var(--border);
  background: #ffffff;
  color: var(--ink);
}

button.secondary-btn:hover {
  border-color: #a4b2cb;
  background: #f8fafc;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.card {
  border: 1px solid var(--border);
  border-left: 4px solid rgba(15, 118, 110, 0.35);
  border-radius: 12px;
  padding: 0.78rem;
  display: grid;
  gap: 0.25rem;
  background: #ffffff;
}

.card strong {
  font-size: 1rem;
}

.note-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-message {
  margin-top: 0.2rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--chip-border);
  border-radius: 10px;
  background: var(--chip-bg);
}

.status-message.is-success {
  color: #0f766e;
}

.status-message.is-error {
  color: #b91c1c;
  border-color: #f2c6c6;
  background: #fef2f2;
}

.card .actions {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.contact-action-btn {
  padding: 0.45rem 0.62rem;
  font-size: 0.82rem;
}

.member-actions select {
  min-width: 120px;
}

.delete-btn {
  background: var(--danger);
  border-color: transparent;
  color: #ffffff;
  padding: 0.52rem 0.68rem;
  font-size: 0.85rem;
}

.delete-btn:hover {
  background: var(--danger-strong);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.5rem 0.76rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.nav-link:hover {
  border-color: #9fb0cb;
  color: var(--ink);
}

.nav-link[aria-current="page"] {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
}

body.theme-dark {
  --bg-start: #09111f;
  --bg-end: #0f172a;
  --panel: #111827;
  --ink: #e5e7eb;
  --muted: #94a3b8;
  --border: #334155;
  --accent: #14b8a6;
  --accent-strong: #0f9488;
  --danger: #dc2626;
  --danger-strong: #b91c1c;
  --chip-bg: #0b1220;
  --chip-border: #334155;
}

body.theme-dark {
  background:
    radial-gradient(70rem 28rem at -18% -12%, rgba(45, 212, 191, 0.11), transparent 58%),
    radial-gradient(55rem 30rem at 112% 0%, rgba(37, 99, 235, 0.1), transparent 60%),
    linear-gradient(150deg, var(--bg-start), var(--bg-end));
}

body.theme-dark .topbar {
  background: rgba(15, 23, 42, 0.9);
}

body.theme-dark .brand-title,
body.theme-dark h1,
body.theme-dark h2,
body.theme-dark h3 {
  color: #f8fafc;
}

body.theme-dark .menu-toggle {
  background: #0b1220;
  border-color: #334155;
}

body.theme-dark .menu-toggle span {
  background: #cbd5e1;
}

body.theme-dark .panel,
body.theme-dark .control-card,
body.theme-dark .card {
  background: #0f172a;
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.5);
}

body.theme-dark .calendar-weekday {
  background: #0b1220;
  color: #cbd5e1;
}

body.theme-dark .calendar-month-label {
  color: #ffffff;
}

body.theme-dark .calendar-day {
  background: #111827;
  color: #e2e8f0;
}

body.theme-dark .calendar-day.is-other-month {
  background: #0b1220;
  color: #64748b;
}

body.theme-dark .calendar-day:hover {
  border-color: #2dd4bf;
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.3);
}

body.theme-dark .calendar-day.is-selected {
  border-color: #14b8a6;
  box-shadow: inset 0 0 0 2px rgba(45, 212, 191, 0.28);
}

body.theme-dark .calendar-day.is-today {
  background: #14b8a6;
  border-color: #14b8a6;
  color: #06201e;
}

body.theme-dark .event-tag.tag-day-off {
  background: #052e2b;
  color: #8ff3e8;
  border-color: #115e59;
}

body.theme-dark .event-tag.tag-they-call-you-back {
  background: #172554;
  color: #bfdbfe;
  border-color: #1d4ed8;
}

body.theme-dark .event-tag.tag-you-call-them-back {
  background: #2e1065;
  color: #ddd6fe;
  border-color: #7c3aed;
}

body.theme-dark .event-tag.tag-creator {
  background: #0b1220;
  color: #cbd5e1;
  border-color: #334155;
}

body.theme-dark input,
body.theme-dark textarea,
body.theme-dark select {
  border-color: #334155;
  background: #0b1220;
  color: #e2e8f0;
}

body.theme-dark .status-message {
  background: #0b1220;
  border-color: #334155;
}

body.theme-dark .status-message.is-error {
  color: #fecaca;
  border-color: #7f1d1d;
  background: #2a0e12;
}

body.theme-dark button.secondary-btn,
body.theme-dark .nav-link,
body.theme-dark .contact-action-btn {
  border-color: #334155;
  background: #0b1220;
  color: #e2e8f0;
}

body.theme-dark button.secondary-btn:hover,
body.theme-dark .nav-link:hover,
body.theme-dark .contact-action-btn:hover {
  border-color: #475569;
  background: #111827;
}

body.theme-dark .topbar-actions {
  background: #0f172a;
  border-color: #334155;
}

body.theme-dark .nav-link[aria-current="page"] {
  background: #14b8a6;
  border-color: #14b8a6;
  color: #06201e;
}

@media (max-width: 980px) {
  .app-shell.two-column {
    grid-template-columns: 1fr;
  }

  .brand-subtitle {
    display: none;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    padding: 0.75rem 0.85rem;
  }

  .topbar-right {
    width: auto;
    justify-content: flex-end;
    position: relative;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .topbar-actions {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 0.55rem);
    min-width: 240px;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 16px 28px rgba(15, 23, 42, 0.16);
    z-index: 30;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions.menu-open {
    display: flex;
  }

  .topbar-actions .nav-link,
  .topbar-actions button {
    width: 100%;
    justify-content: flex-start;
  }

  .app-shell {
    padding: 0.9rem;
  }

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

  .pager {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
