:root {
  --bg: #0b1220;
  --panel: #111827;
  --panel-2: #1a2332;
  --border: rgba(148, 163, 184, 0.2);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #8b5cf6;
  --primary-2: #6366f1;
  --lan: #7c3aed;
  --dinner: #f59e0b;
  --other: #10b981;
  --danger: #f87171;
  --today: rgba(99, 102, 241, 0.2);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(900px 500px at 10% -10%, rgba(139, 92, 246, 0.22), transparent 55%),
    radial-gradient(700px 400px at 90% 0%, rgba(56, 189, 248, 0.12), transparent 50%),
    var(--bg);
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.tiny {
  font-size: 0.78rem;
}
.error {
  color: #fecaca;
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}
.spacer {
  flex: 1;
}

/* Layout */
.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
}
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}
.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}
.logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  background: linear-gradient(145deg, rgba(139, 92, 246, 0.4), rgba(99, 102, 241, 0.15));
  border: 1px solid rgba(167, 139, 250, 0.35);
}
.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.subtitle {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.pill {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}
.pill.editor {
  color: #ddd6fe;
  border-color: rgba(167, 139, 250, 0.45);
  background: rgba(139, 92, 246, 0.18);
}
.pill.guest {
  color: #cbd5e1;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 11px;
  padding: 0.5rem 0.9rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}
.btn:hover {
  background: rgba(255, 255, 255, 0.09);
}
.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}
.btn.ghost {
  background: transparent;
}
.btn.danger {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.4);
}
.btn.discord {
  background: #5865f2;
  border-color: transparent;
  color: #fff;
}
.btn.full {
  width: 100%;
}
.btn.icon {
  width: 2.4rem;
  padding-left: 0;
  padding-right: 0;
  font-size: 1.25rem;
  line-height: 1;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}
.toolbar-left,
.toolbar-right,
.toolbar-center {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.period-label {
  margin: 0 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 700;
  min-width: 10rem;
}
.view-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 11px;
  padding: 3px;
  border: 1px solid var(--border);
}
.view-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.85rem;
  border-radius: 9px;
  font-weight: 600;
  cursor: pointer;
}
.view-tab.is-active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
}
.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}
.chip.is-on {
  color: #fff;
  border-color: transparent;
  background: var(--lan);
}
.chip[data-type="dinner"].is-on {
  background: var(--dinner);
  color: #1c1917;
}
.chip[data-type="other"].is-on {
  background: var(--other);
  color: #052e1a;
}
.search {
  min-width: 180px;
  max-width: 260px;
  width: 100%;
  border: 1px solid var(--border);
  background: #0f172a;
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  color: var(--text);
}
.search:focus {
  outline: 2px solid rgba(139, 92, 246, 0.45);
  border-color: rgba(139, 92, 246, 0.5);
}
.host-tip {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(167, 139, 250, 0.35);
  color: #e9d5ff;
  font-size: 0.88rem;
  font-weight: 600;
}

/* Main grid */
.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 980px) {
  .main {
    grid-template-columns: 1fr;
  }
  .toolbar-right {
    width: 100%;
  }
  .search {
    max-width: none;
    flex: 1;
  }
}
.cal-wrap,
.panel {
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.cal-wrap {
  padding: 0.85rem;
  min-height: 640px;
}
.cal-status {
  color: var(--muted);
  padding: 0.5rem;
}
.calendar {
  width: 100%;
}

/* Month view */
.month-dows {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 4px;
}
.dow {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.35rem 0;
}
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.day-cell {
  min-height: 110px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.day-cell.muted-day {
  opacity: 0.45;
}
.day-cell.today {
  background: var(--today);
  border-color: rgba(129, 140, 248, 0.55);
}
.day-cell.drop-target {
  outline: 2px solid #a78bfa;
  background: rgba(139, 92, 246, 0.2);
}
.day-num {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0.1rem 0.2rem;
}
.day-events {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 0;
}
.more {
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.1rem 0.25rem;
}

/* Event chips */
.evt {
  appearance: none;
  border: none;
  border-radius: 7px;
  text-align: left;
  padding: 0.25rem 0.35rem;
  cursor: pointer;
  color: #fff;
  background: var(--lan);
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  overflow: hidden;
  font-size: 0.72rem;
  line-height: 1.2;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.evt.type-dinner {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #1c1917;
}
.evt.type-other {
  background: linear-gradient(135deg, #059669, #34d399);
  color: #052e1a;
}
.evt.type-lan {
  background: linear-gradient(135deg, #7c3aed, #6366f1);
}
.evt:hover {
  filter: brightness(1.08);
}
.evt.dragging {
  opacity: 0.35;
}
.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.92;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  border-radius: 7px;
  transform: translate(-9999px, -9999px);
}
.day-num {
  cursor: default;
  user-select: none;
}
.cal-wrap.can-edit .day-num {
  cursor: pointer;
}
.cal-wrap.can-edit .day-num:hover {
  color: #c4b5fd;
}
.evt-time {
  font-weight: 700;
  opacity: 0.9;
  font-size: 0.68rem;
}
.evt-title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.evt-loc,
.evt-rem {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
  font-size: 0.65rem;
}
.evt.block {
  padding: 0.45rem 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
}
.evt.block .evt-time {
  font-size: 0.72rem;
}
.evt.block .evt-title {
  font-size: 0.85rem;
}

/* Week */
.week-dows,
.week-cols {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.week-dow {
  text-align: center;
  padding: 0.4rem;
  color: var(--muted);
}
.week-dow .wd {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}
.week-dow .wn {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.week-dow.today .wn {
  color: #c4b5fd;
}
.week-col {
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.4rem;
  background: rgba(255, 255, 255, 0.02);
}
.week-col.today {
  background: var(--today);
}
.week-col.drop-target {
  outline: 2px solid #a78bfa;
}
.week-empty {
  color: var(--muted);
  text-align: center;
  padding: 1rem 0;
  font-size: 0.85rem;
}

/* List */
.list-view {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.list-row {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  width: 100%;
}
.list-row:hover {
  border-color: rgba(167, 139, 250, 0.45);
}
.list-title {
  font-weight: 700;
  font-size: 1rem;
}
.list-when,
.list-meta,
.list-desc,
.list-rem {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 0.15rem;
}
.list-rem {
  color: #c4b5fd;
}
.badge {
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  background: rgba(139, 92, 246, 0.25);
  color: #ddd6fe;
}
.type-dinner .badge {
  background: rgba(245, 158, 11, 0.25);
  color: #fde68a;
}
.type-other .badge {
  background: rgba(16, 185, 129, 0.25);
  color: #a7f3d0;
}

/* Sidebar */
.panel {
  padding: 0.9rem 1rem 1rem;
}
.panel + .panel {
  margin-top: 1rem;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.65rem;
}
.panel h3 {
  margin: 0;
  font-size: 1rem;
}
.event-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 480px;
  overflow: auto;
}
.event-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
}
.event-card:hover {
  border-color: rgba(167, 139, 250, 0.45);
}
.card-title {
  font-weight: 700;
  margin-top: 0.2rem;
}
.card-when,
.card-meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.15rem;
}
.card-rem {
  color: #c4b5fd;
  font-size: 0.78rem;
  margin-top: 0.25rem;
}
.empty-card {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  color: var(--muted);
  list-style: none;
}
.help ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Dialogs */
.dialog {
  border: none;
  padding: 0;
  background: transparent;
  color: inherit;
  max-width: min(560px, calc(100vw - 1.5rem));
  width: 100%;
}
.dialog.wide,
.dialog-card.wide {
  max-width: min(620px, calc(100vw - 1.5rem));
}
.dialog::backdrop {
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(5px);
}
.dialog-card {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.1rem 1.2rem 1.2rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.dialog-head h2 {
  margin: 0;
  font-size: 1.15rem;
}
.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.15rem 0.4rem;
  border-radius: 8px;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
}
@media (max-width: 560px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .day-cell {
    min-height: 84px;
  }
  .evt-time {
    display: none;
  }
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.field.full {
  grid-column: 1 / -1;
}
.field input,
.field select,
.field textarea {
  color: #fff;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid rgba(139, 92, 246, 0.45);
  border-color: rgba(139, 92, 246, 0.5);
}
.field select {
  color-scheme: dark;
  background-color: #1e293b;
}
.field select option {
  color: #0f172a;
  background: #f8fafc;
}
.field input[type="datetime-local"] {
  color-scheme: dark;
  cursor: pointer;
}
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}
.event-extras {
  margin-top: 0.85rem;
}
.reminder-badge {
  margin: 0 0 0.55rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(167, 139, 250, 0.35);
  color: #e9d5ff;
  font-size: 0.88rem;
  font-weight: 600;
}
.export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.export-row .btn {
  font-size: 0.82rem;
  padding: 0.45rem 0.7rem;
}
