*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #f8fafc;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #0f172a;
  --muted:         #64748b;
  --primary:       #10324f;
  --primary-hover: #1b486b;
  --primary-light: #e9eff4;
  --danger:        #dc2626;
  --success:       #16a34a;

  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04), 0 1px 3px rgba(15,23,42,0.05);
  --shadow-md: 0 2px 4px rgba(15,23,42,0.04), 0 4px 12px rgba(15,23,42,0.06);
  --shadow-lg: 0 4px 8px rgba(15,23,42,0.05), 0 10px 24px rgba(15,23,42,0.08);

  --r0-bg: #f1f5f9; --r0-text: #94a3b8; --r0-sel: #cbd5e1;
  --r1-bg: #fefce8; --r1-text: #a16207; --r1-sel: #fef08a;
  --r2-bg: #fff7ed; --r2-text: #c2410c; --r2-sel: #fed7aa;
  --r3-bg: #f0fdf4; --r3-text: #15803d; --r3-sel: #86efac;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  letter-spacing: -0.005em;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.container       { max-width: 680px;  margin: 0 auto; padding: 2rem 1.5rem; }
.container--wide { max-width: 1080px; margin: 0 auto; padding: 2rem 1.5rem; }

header { margin-bottom: 2rem; }

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.03em;
}
.logo-dots {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.13em;
  flex-shrink: 0;
}
.logo-dots i {
  width: 0.4em;
  height: 0.4em;
  border-radius: 50%;
}
.logo-dots i:nth-child(1) { background: #7fae57; } /* green */
.logo-dots i:nth-child(2) { background: #ea9434; } /* orange */
.logo-dots i:nth-child(3) { background: #79427a; } /* purple */
.logo-dots i:nth-child(4) { background: #309293; } /* teal */

.page-title { font-size: 1.125rem; font-weight: 600; margin-top: 0.2rem; }
.subtitle   { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
}

/* Form */
.field { margin-bottom: 1.25rem; }

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,50,79,0.18);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled)  { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: var(--shadow-md); }

.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); box-shadow: var(--shadow-sm); }

.btn-danger { background: transparent; color: var(--danger); border: 1px solid #fca5a5; }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }

.btn-warn { background: var(--danger); color: #fff; box-shadow: var(--shadow-sm); }
.btn-warn:hover:not(:disabled) { background: #b91c1c; box-shadow: var(--shadow-md); }

.btn-success { background: var(--success); color: #fff; box-shadow: var(--shadow-sm); }
.btn-success:hover:not(:disabled) { background: #15803d; box-shadow: var(--shadow-md); }

.btn-solve { background: var(--success); color: #fff; padding: 0.625rem 1.75rem; font-size: 1rem; box-shadow: var(--shadow-sm); }
.btn-solve:hover:not(:disabled) { background: #15803d; box-shadow: var(--shadow-md); }

.btn-sm { padding: 0.25rem 0.625rem; font-size: 0.8125rem; }

/* Slot rows */
.slot-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.slot-row input { flex: 1; }
.slot-row .slot-date  { flex: 2; min-width: 140px; }
.slot-row .slot-start,
.slot-row .slot-end   { flex: 1; min-width: 105px; }
.slot-row .slot-dash  { color: var(--muted); padding: 0 0.125rem; }

/* Share box */
.share-box { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.share-url {
  flex: 1;
  font-family: monospace;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  background: #fef08a;
  border: 1px solid #eab308;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Response grid */
.grid-scroll { overflow-x: auto; }

.response-grid {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 0.875rem;
}

.response-grid th {
  background: var(--bg);
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  text-align: center;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
}

.response-grid th:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 2;
}

.response-grid td {
  padding: 0.375rem 0.5rem;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
  min-width: 88px;
}

.response-grid td:first-child {
  text-align: left;
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--surface);
  border-right: 2px solid var(--border);
}

.response-grid tr:last-child td { border-bottom: none; }

/* Rating cell */
.rating-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.rating-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 5px;
  font-weight: 700;
  font-size: 0.9rem;
}

.r0 { background: var(--r0-bg); color: var(--r0-text); }
.r1 { background: var(--r1-bg); color: var(--r1-text); }
.r2 { background: var(--r2-bg); color: var(--r2-text); }
.r3 { background: var(--r3-bg); color: var(--r3-text); }

.cell-assigned .rating-badge {
  outline: 2.5px solid var(--primary);
  outline-offset: 1px;
}

/* Solve section */
.solve-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.5rem 0 1.5rem;
}

/* Results table */
.result-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.result-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.result-table td:first-child { font-weight: 500; width: 38%; }
.result-table tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-muted   { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

/* Rating widget (join page) */
.rating-option { display: none; }

.rating-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 4.25rem;
  padding: 0.4rem 0.25rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 2px solid transparent;
  user-select: none;
  gap: 0.1rem;
  transition: border-color 0.1s;
}
.rating-label .r-num  { font-size: 1rem; font-weight: 700; }
.rating-label .r-desc { font-size: 0.6875rem; }

.rating-option[value="0"] + .rating-label { background: var(--r0-bg); color: var(--r0-text); }
.rating-option[value="1"] + .rating-label { background: var(--r1-bg); color: var(--r1-text); }
.rating-option[value="2"] + .rating-label { background: var(--r2-bg); color: var(--r2-text); }
.rating-option[value="3"] + .rating-label { background: var(--r3-bg); color: var(--r3-text); }

.rating-option[value="0"]:checked + .rating-label { border-color: var(--r0-text); background: var(--r0-sel); }
.rating-option[value="1"]:checked + .rating-label { border-color: var(--r1-text); background: var(--r1-sel); }
.rating-option[value="2"]:checked + .rating-label { border-color: var(--r2-text); background: var(--r2-sel); }
.rating-option[value="3"]:checked + .rating-label { border-color: var(--r3-text); background: var(--r3-sel); }

.rating-group { display: flex; gap: 0.3rem; flex-wrap: wrap; }

.slot-rating-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.5rem;
  margin: 0 -0.5rem;
  border-bottom: 1px solid var(--border);
  border-radius: 6px;
  gap: 1rem;
  transition: background 0.15s ease;
}
.slot-rating-row:hover { background: var(--primary-light); }
.slot-rating-row:last-child { border-bottom: none; }
.slot-name { font-weight: 500; min-width: 110px; }

.new-slot-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 9999px;
  vertical-align: middle;
}

.slot-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  min-width: 110px;
}

/* Heat bar — shows how many prior participants can make each slot. */
.slot-heat {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
  font-size: 0.7rem;
  color: var(--muted);
}
.heat-bar-track {
  position: relative;
  width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 9999px;
  overflow: hidden;
}
.heat-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  border-radius: 9999px;
  transform-origin: left center;
  animation: heat-grow 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes heat-grow {
  from { transform: scaleX(0); opacity: 0.4; }
  to   { transform: scaleX(1); opacity: 1; }
}
.heat-count { white-space: nowrap; }
.slot-heat.heat-empty .heat-bar-track { background: transparent; }

/* Live dot */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  animation: livepulse 2s infinite;
  vertical-align: middle;
  margin-right: 0.3rem;
}
@keyframes livepulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* Status messages */
.status-msg { padding: 0.75rem 1rem; border-radius: 6px; font-size: 0.875rem; margin-top: 1rem; }
.status-error   { background: #fef2f2; color: var(--danger);  border: 1px solid #fca5a5; }
.status-success { background: #f0fdf4; color: var(--success); border: 1px solid #86efac; }
.status-info    { background: var(--primary-light); color: var(--primary); border: 1px solid #b8cce0; }

/* Utility */
.flex        { display: flex; }
.items-center { align-items: center; }
.gap-2       { gap: 0.5rem; }
.gap-3       { gap: 0.75rem; }
.mt-1        { margin-top: 0.25rem; }
.mt-2        { margin-top: 0.5rem; }
.mt-4        { margin-top: 1rem; }
.mb-4        { margin-bottom: 1rem; }
.text-sm     { font-size: 0.875rem; }
.text-muted  { color: var(--muted); }
.font-600    { font-weight: 600; }
.hidden      { display: none !important; }
.empty-state { text-align: center; padding: 2rem; color: var(--muted); font-size: 0.875rem; }

/* Support footer */
.support-footer {
  text-align: center;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.support-footer a { color: var(--primary); text-decoration: none; font-weight: 500; }
.support-footer a:hover { text-decoration: underline; }

/* Google button */
.btn-google {
  width: 100%;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  justify-content: center;
  gap: 0.625rem;
  font-weight: 500;
}
.btn-google:hover { background: #f8f9fa; border-color: #c6c9cc; }

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: var(--muted);
  font-size: 0.875rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Events list */
.event-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}
.event-row:last-child { border-bottom: none; }

@media (max-width: 560px) {
  .slot-rating-row { flex-direction: column; align-items: flex-start; }
  .rating-label { width: 3.5rem; }
  .solve-section { flex-direction: column; align-items: flex-start; }
}
