:root {
  --bg-1: #eef2ff;
  --bg-2: #fce7f3;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0f172a;
  --muted: #64748b;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08), 0 4px 8px rgba(15, 23, 42, 0.04);
  --radius: 14px;

  --indigo: #6366f1;
  --indigo-dark: #4f46e5;
  --indigo-soft: #eef2ff;

  --emerald: #10b981;
  --emerald-dark: #059669;
  --emerald-soft: #d1fae5;

  --amber: #f59e0b;
  --amber-dark: #d97706;
  --amber-soft: #fef3c7;

  --rose: #ec4899;
  --rose-dark: #db2777;
  --rose-soft: #fce7f3;

  --violet: #8b5cf6;
  --violet-dark: #7c3aed;
  --violet-soft: #ede9fe;

  --coral: #fb923c;
  --coral-dark: #ea580c;
  --coral-soft: #ffedd5;

  --danger: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

button {
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  width: 100%;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%);
  color: white;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: 500;
}
.btn-ghost:hover { color: var(--text); background: rgba(15, 23, 42, 0.05); }

.btn-danger {
  color: var(--danger);
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: 500;
}
.btn-danger:hover { background: #fef2f2; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- Auth screen ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.auth-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
}

.auth-card .subtitle {
  color: var(--muted);
  margin: 0 0 28px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  padding: 10px 12px;
  background: #fef2f2;
  border-radius: 6px;
  border: 1px solid #fecaca;
}

/* ---------- Dashboard layout ---------- */
.dashboard { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--indigo-dark) 0%, var(--violet-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.user-info strong { color: var(--text); }

.main {
  flex: 1;
  padding: 28px 32px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Grid layout ---------- */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 24px;
}

.grid-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

@media (max-width: 1024px) {
  .grid { grid-template-columns: 1fr; }
  .grid-bottom { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .main { padding: 16px; }
  .topbar { padding: 12px 16px; }
}

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

.panel-header {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.panel-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.panel-body { padding: 18px 22px; }

.panel-body.tight { padding: 14px 18px; }

.panel-body.scroll {
  max-height: 480px;
  overflow-y: auto;
}

/* Section themes */
.theme-indigo .panel-icon { background: var(--indigo-soft); color: var(--indigo-dark); }
.theme-indigo .panel-header { background: linear-gradient(90deg, var(--indigo-soft) 0%, transparent 70%); }

.theme-emerald .panel-icon { background: var(--emerald-soft); color: var(--emerald-dark); }
.theme-emerald .panel-header { background: linear-gradient(90deg, var(--emerald-soft) 0%, transparent 70%); }

.theme-amber .panel-icon { background: var(--amber-soft); color: var(--amber-dark); }
.theme-amber .panel-header { background: linear-gradient(90deg, var(--amber-soft) 0%, transparent 70%); }

.theme-rose .panel-icon { background: var(--rose-soft); color: var(--rose-dark); }
.theme-rose .panel-header { background: linear-gradient(90deg, var(--rose-soft) 0%, transparent 70%); }

.theme-violet .panel-icon { background: var(--violet-soft); color: var(--violet-dark); }
.theme-violet .panel-header { background: linear-gradient(90deg, var(--violet-soft) 0%, transparent 70%); }

.theme-coral .panel-icon { background: var(--coral-soft); color: var(--coral-dark); }
.theme-coral .panel-header { background: linear-gradient(90deg, var(--coral-soft) 0%, transparent 70%); }

/* ---------- Items ---------- */
.item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.item:last-child { border-bottom: none; padding-bottom: 0; }
.item:first-child { padding-top: 0; }

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}

.item-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.item-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.item-body {
  white-space: pre-wrap;
  color: #334155;
  font-size: 14px;
}

.item-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* Event item */
.event-item { display: flex; gap: 14px; }

.event-date-badge {
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--emerald) 0%, var(--emerald-dark) 100%);
  color: white;
  border-radius: 10px;
  padding: 8px 12px;
  text-align: center;
  min-width: 64px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.event-date-badge .day {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.event-date-badge .month {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  margin-top: 3px;
  opacity: 0.95;
}

.event-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* Record item */
.record-item {
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--coral-soft);
  background: linear-gradient(135deg, #fff 0%, var(--coral-soft) 100%);
  margin-bottom: 12px;
  position: relative;
}

.record-item:last-child { margin-bottom: 0; }

.record-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.record-trophy {
  font-size: 22px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(234, 88, 12, 0.3));
}

.record-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--coral-dark);
  flex: 1;
}

.record-meta {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 8px;
}

.record-meta strong { color: var(--coral-dark); }

.record-description {
  white-space: pre-wrap;
  font-size: 14px;
  color: #334155;
  margin-bottom: 14px;
}

.quote-card {
  background: white;
  border-left: 4px solid var(--coral);
  border-radius: 8px;
  padding: 12px 14px;
  position: relative;
  box-shadow: 0 2px 6px rgba(234, 88, 12, 0.08);
}

.quote-text {
  font-style: italic;
  font-size: 13px;
  color: #475569;
  line-height: 1.5;
  margin: 0;
}

.quote-text::before {
  content: '"';
  font-size: 28px;
  color: var(--coral);
  font-family: Georgia, serif;
  line-height: 0;
  position: relative;
  top: 8px;
  margin-right: 2px;
}

.quote-author {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--coral-dark);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quote-reroll {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--coral-soft);
  color: var(--coral-dark);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.6;
  transition: opacity 0.15s, transform 0.3s;
}

.quote-card:hover .quote-reroll { opacity: 1; }
.quote-reroll:hover { transform: rotate(180deg); }

/* ---------- Celebration (confetti + dancers) ---------- */
.celebration-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 14px;
  top: -24px;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes confetti-fall {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--drift, 0), 110vh) rotate(var(--rotate, 720deg)); opacity: 0.85; }
}

.dancers-wrap {
  position: fixed;
  bottom: 90px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 10000;
  animation: celebration-fade 4.5s ease-out forwards;
}

@keyframes celebration-fade {
  0%   { opacity: 0; transform: translateY(40px) scale(0.6); }
  12%  { opacity: 1; transform: translateY(0) scale(1.05); }
  18%  { transform: translateY(0) scale(1); }
  82%  { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-30px) scale(1.05); }
}

.celebration-message {
  font-size: 32px;
  font-weight: 800;
  color: var(--coral-dark);
  background: white;
  padding: 14px 32px;
  border-radius: 100px;
  box-shadow: 0 12px 36px rgba(234, 88, 12, 0.35),
              0 0 0 4px var(--coral-soft);
  margin-bottom: 18px;
  white-space: nowrap;
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
}

.dancers {
  display: flex;
  gap: 0;
  font-size: 92px;
  line-height: 1;
  animation: pair-sway 1.3s ease-in-out infinite;
  transform-origin: center bottom;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.18));
}

@keyframes pair-sway {
  0%   { transform: rotate(-7deg); }
  50%  { transform: rotate(7deg); }
  100% { transform: rotate(-7deg); }
}

.dancer {
  display: inline-block;
  animation: dancer-bounce 0.65s ease-in-out infinite alternate;
}

.dancer.lead {
  animation-delay: 0.32s;
}

@keyframes dancer-bounce {
  0%   { transform: translateY(0) rotate(-4deg); }
  100% { transform: translateY(-16px) rotate(4deg); }
}

@media (max-width: 600px) {
  .celebration-message { font-size: 22px; padding: 10px 20px; }
  .dancers { font-size: 64px; }
}

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 6px;
}

.status-planned { background: var(--indigo-soft); color: var(--indigo-dark); }
.status-active, .status-in-progress { background: var(--amber-soft); color: var(--amber-dark); }
.status-on-hold { background: #fee2e2; color: #b91c1c; }
.status-completed { background: var(--emerald-soft); color: var(--emerald-dark); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 30px 16px;
  color: var(--muted);
  font-size: 13px;
}

.empty-icon { font-size: 28px; margin-bottom: 8px; opacity: 0.5; }

/* ---------- Form ---------- */
.inline-form {
  padding: 16px 22px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}

/* ---------- Chat ---------- */
.chat-panel { display: flex; flex-direction: column; min-height: 520px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  background: var(--surface-2);
  max-height: 480px;
  min-height: 340px;
}

.chat-message {
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.chat-message:last-child { margin-bottom: 0; }

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--violet) 0%, var(--rose) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.chat-bubble {
  flex: 1;
  min-width: 0;
}

.chat-bubble-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.chat-bubble-author {
  font-weight: 700;
  font-size: 13px;
  color: var(--violet-dark);
}

.chat-bubble-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.chat-bubble-text {
  background: white;
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 12px;
  border-top-left-radius: 4px;
  font-size: 13px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chat-message.own .chat-avatar {
  background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%);
}

.chat-message.own .chat-bubble-author { color: var(--indigo-dark); }

.chat-message.own .chat-bubble-text {
  background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%);
  color: white;
  border-color: transparent;
}

.chat-delete {
  opacity: 0;
  font-size: 11px;
  color: var(--danger);
  transition: opacity 0.15s;
  margin-left: 6px;
}

.chat-message:hover .chat-delete { opacity: 1; }

.chat-input-row {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  background: var(--surface);
}

.chat-input-row input { border-radius: 20px; padding: 10px 16px; }

.chat-send {
  background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%);
  color: white;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
  transition: transform 0.1s;
}

.chat-send:hover { transform: scale(1.05); }
.chat-send:active { transform: scale(0.95); }

.chat-empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 13px;
}

/* scrollbar */
.chat-messages::-webkit-scrollbar,
.panel-body.scroll::-webkit-scrollbar { width: 8px; }

.chat-messages::-webkit-scrollbar-thumb,
.panel-body.scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.panel-body.scroll::-webkit-scrollbar-thumb:hover { background: var(--muted); }
