:root {
  --bg: #0d0d0d;
  --surface: #161616;
  --border: #2a2a2a;
  --accent: #c8f564;
  --accent2: #f5a623;
  --text: #f0ede6;
  --muted: #7a7a7a;
  --danger: #ff5f5f;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.5;
}

header {
  padding: 2rem 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.logo span { color: var(--accent); }

.tagline {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

main {
  max-width: 820px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

/* VIEWS */
.view { display: none; animation: fadeIn 0.4s ease; }
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* HERO */
.hero-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.04em;
  margin-bottom: 1.5rem;
}

.hero-title .accent { color: var(--accent); display: block; }

.hero-sub {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.7;
  max-width: 420px;
  margin-bottom: 3rem;
}

/* FORM ELEMENTS */
label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

input[type="text"], input[type="date"], input[type="time"], textarea, select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}

.field { margin-bottom: 1.5rem; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  border-radius: 4px;
  font-family: 'DM Mono', monospace;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #0d0d0d;
}

.btn-primary:hover { background: #b8e94e; transform: translateY(-1px); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* CARD */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.card-sub {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

/* TIME GRID */
.time-grid-wrapper { overflow-x: auto; margin: 1rem 0; }

.time-grid {
  display: grid;
  gap: 3px;
  min-width: 500px;
}

.time-grid-header {
  display: flex;
  gap: 3px;
}

.day-label {
  flex: 1;
  text-align: center;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 0.3rem;
}

.time-row {
  display: flex;
  align-items: center;
  gap: 3px;
}

.time-label {
  font-size: 0.6rem;
  color: var(--muted);
  width: 50px;
  text-align: right;
  padding-right: 8px;
  flex-shrink: 0;
}

.time-cell {
  flex: 1;
  height: 28px;
  border-radius: 3px;
  background: #1e1e1e;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.time-cell:hover { border-color: var(--accent); }
.time-cell.selected { background: var(--accent); border-color: var(--accent); }
.time-cell.partial { background: #5a7a20; border-color: #7ab030; }
.time-cell.full { background: var(--accent); border-color: var(--accent); }
.time-cell.best { box-shadow: 0 0 0 2px var(--accent2); }
.time-cell.readonly { cursor: default; }

/* RESPONSES */
.response-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}

.response-name { font-weight: 500; }
.response-slots { color: var(--muted); font-size: 0.7rem; }

/* SHARE BOX */
.share-box {
  background: #0a0a0a;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 1.2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
}

.share-url {
  flex: 1;
  font-size: 0.72rem;
  color: var(--accent);
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* RESULT */
.best-time-box {
  background: linear-gradient(135deg, #1a2a05, #0d1a00);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  margin: 2rem 0;
}

.best-time-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.best-time-value {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--accent);
}

.best-time-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

/* LEGEND */
.legend {
  display: flex;
  gap: 1.5rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  border: 1px solid var(--border);
}

/* NOTIFICATION */
.notif {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--accent);
  color: #0d0d0d;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 500;
  z-index: 100;
  transform: translateY(100px);
  transition: transform 0.3s ease;
}

.notif.show { transform: translateY(0); }

/* LOADING */
.loading {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid #0d0d0d;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* SECTION TITLE */
.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.section-sub {
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 2.5rem;
  line-height: 1.6;
}

hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

.pill {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 99px;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid var(--border);
  color: var(--muted);
  margin-left: 0.5rem;
}

.responses-count {
  font-family: 'Playfair Display', serif;
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-size: 0.8rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

@media (max-width: 600px) {
  header { padding: 1.5rem; }
  main { padding: 2rem 1rem; }
  .field-row { grid-template-columns: 1fr; }
}

/* GOOGLE AUTH */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0;
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-google {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
  justify-content: center;
}

.btn-google:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  animation: fadeIn 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
}

.modal-header .card-title { margin-bottom: 0; }

.modal-body { padding: 2rem; }

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: color 0.2s;
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

/* CALENDAR LINK URL BOX */
.cal-link-url {
  background: #0a0a0a;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  font-size: 0.7rem;
  color: var(--accent);
  word-break: break-all;
  line-height: 1.5;
}
