/* ===========================
   Family Schedule - styles
   Base tone matches tokens.css (Terracotta & Cream).
   Event items use the terracotta accent, to-do items use the green
   "success" tone — reusing the platform's "one color per kind of thing"
   pattern to tell the two item types apart at a glance.
   =========================== */

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

/* Some elements below (e.g. .form-group) set an explicit `display`, which
   would otherwise out-specificity the browser's default `[hidden] { display: none }`
   rule and leave them visible even when JS sets `.hidden = true`. */
[hidden] {
  display: none !important;
}

:root {
  color-scheme: light;

  --bg: #FAF4EC;
  --card: #FFFFFF;
  --border: #EDE2D4;
  --divider: #F4EBDF;
  --ink: #3D3229;
  --text-2: #6B5F51;
  --muted: #8C7F70;
  --faint: #B5A794;
  --error: #C0392B;

  --accent: #D9704C;
  --accent-hover: #C25B39;
  --accent-tint: #F8E4DA;
  --accent-line: #E8C9BB;

  --success: #2E9E54;
  --success-tint: #F0FAF3;
  --success-hover: #DDF4E4;

  --work: #D64545;
  --work-tint: #FBE3E1;
  --work-line: #F0BDB8;

  --shadow-card: 0 2px 10px rgba(60, 40, 20, 0.06);
  --shadow-modal: 0 24px 60px rgba(60, 40, 20, 0.30);
  --modal-scrim: rgba(61, 50, 41, 0.40);
  --focus-ring: 0 0 0 3px rgba(217, 112, 76, 0.15);

  --radius-card: 20px;
  --radius-pill: 999px;

  --font: "Nunito", sans-serif;
}

body {
  font-family: var(--font);
  margin: 0;
  padding: 40px 20px 64px;
  background: var(--bg);
  color: var(--ink);
}

header, main {
  max-width: 680px;
  margin: 0 auto;
}

h1, h2 {
  margin: 0;
}

p {
  color: var(--text-2);
  line-height: 1.5;
}

button {
  font-family: var(--font);
  cursor: pointer;
}

/* ---- Sign-in gate ---- */

.gate {
  max-width: 420px;
  margin: 80px auto;
  text-align: center;
  padding: 0 20px;
}

.gate-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin-bottom: 16px;
}

.gate h1 {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 12px;
}

.gate button {
  margin-top: 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 700;
}

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

/* ---- Header ---- */

.app-header {
  max-width: 680px;
  margin: 0 auto 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.app-header h1 {
  font-size: 26px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 14px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  padding: 6px 0;
  text-decoration: underline;
}

.link-btn:hover {
  color: var(--ink);
}

.danger-link {
  color: var(--error);
}

.loading-indicator {
  text-align: center;
  color: var(--muted);
}

/* ---- Form basics ---- */

.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-weight: 700;
  font-size: 14px;
}

.form-group small {
  color: var(--muted);
  font-size: 13px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

input[type="text"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--ink);
  background: var(--card);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.form-actions {
  display: flex;
  gap: 12px;
}

button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 700;
}

button[type="submit"]:hover {
  background: var(--accent-hover);
}

.secondary-btn {
  background: var(--card);
  color: var(--accent-hover);
  border: 1.5px solid var(--accent-line);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 700;
}

.secondary-btn:hover {
  background: var(--accent-tint);
}

.error-text {
  color: var(--error);
  font-size: 14px;
  font-weight: 600;
}

/* ---- Onboarding ---- */

.onboarding-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
}

.tab-btn.active {
  background: var(--accent-tint);
  border-color: var(--accent-line);
  color: var(--accent-hover);
}

.onboarding-form {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.join-preview {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: var(--shadow-card);
  margin-top: 16px;
}

.join-preview-intro {
  margin: 0 0 4px;
  font-size: 13px;
}

.join-preview-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 4px;
}

.join-preview-members {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 16px;
}

.join-preview-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---- Family banner ---- */

.family-banner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 12px;
}

.family-banner-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.family-banner h2 {
  font-size: 20px;
  font-weight: 800;
}

.family-banner-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.members-row {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 14px;
  margin-top: 2px;
  border-top: 1px solid var(--divider);
}

.members-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.member-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--divider);
  border-radius: var(--radius-pill);
  padding: 4px 6px 4px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}

.member-chip-remove {
  background: none;
  border: none;
  color: var(--faint);
  font-size: 11px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.member-chip-remove:hover {
  color: var(--error);
  background: rgba(192, 57, 43, 0.08);
}

.invite-code-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-tint);
  border-radius: var(--radius-pill);
  padding: 6px 6px 6px 16px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--accent-hover);
}

.icon-btn {
  background: var(--card);
  border: none;
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-hover);
}

.icon-btn:hover {
  background: var(--accent-hover);
  color: #fff;
}

.notify-status {
  font-size: 13px;
  margin: 0 0 20px;
  color: var(--muted);
}

.notify-status--ok {
  color: var(--success);
}

.notify-status--alert {
  color: var(--error);
}

/* ---- Add item form ---- */

#add-item-section {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}

.type-toggle {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  font-weight: 700;
  font-size: 14px;
}

.type-toggle label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* ---- Item list ---- */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 800;
}

.item-card {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  border-left: 4px solid var(--accent);
}

.item-card--todo {
  border-left-color: var(--success);
}

.item-card--done .item-title {
  text-decoration: line-through;
  color: var(--faint);
}

.item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.item-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  color: var(--accent-hover);
  margin-bottom: 8px;
}

.item-badge--todo {
  background: var(--success-tint);
  color: var(--success);
}

.item-badge--category {
  margin-left: 6px;
}

.item-badge--work {
  background: var(--work-tint);
  color: var(--work);
}

.item-badge--private {
  background: var(--success-tint);
  color: var(--success);
}

.item-title {
  font-size: 17px;
  font-weight: 800;
  margin: 0 0 4px;
}

.item-meta {
  font-size: 13px;
  color: var(--text-2);
  margin: 0 0 4px;
}

.item-memo {
  font-size: 14px;
  color: var(--text-2);
  margin: 8px 0 0;
  white-space: pre-wrap;
}

.item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--divider);
}

.item-added-by {
  font-size: 12px;
  color: var(--faint);
}

.item-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.item-done-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}

.item-icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
}

.item-icon-btn:hover {
  color: var(--ink);
  background: var(--divider);
}

.item-icon-btn--danger:hover {
  color: var(--error);
  background: rgba(192, 57, 43, 0.08);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

/* ---- Usage guide ---- */

.usage-guide {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 16px 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}

.usage-guide summary {
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
}

.usage-guide ul {
  margin: 12px 0 4px;
  padding-left: 20px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.6;
}

/* ---- Calendar ---- */

.category-toggle {
  margin-bottom: 16px;
}

#calendar-section {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.calendar-nav h2 {
  font-size: 16px;
  font-weight: 800;
}

.calendar-nav .icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.calendar-nav .icon-btn:disabled:hover {
  background: var(--card);
  color: var(--accent-hover);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-cell {
  min-height: 74px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  padding: 3px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
}

.calendar-cell:hover {
  border-color: var(--accent-line);
}

.calendar-cell--blank {
  visibility: hidden;
  cursor: default;
  border: none;
  min-height: 0;
}

.calendar-day-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  flex-shrink: 0;
  padding: 0 2px;
}

/* Multiple items on the same day stack as separate colored bands (instead of
   one flat color for the whole cell) so overlapping schedules stay legible
   instead of collapsing into a single tint + "+N". */
.calendar-day-items {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.calendar-item-stripe {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 9px;
  line-height: 1.2;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-item-stripe--work {
  background: var(--work-tint);
}

.calendar-item-stripe--private {
  background: var(--success-tint);
}

.calendar-day-more-stripe {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: var(--divider);
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
}

.calendar-legend {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

.calendar-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.calendar-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
}

.calendar-legend-swatch--work {
  background: var(--work);
}

.calendar-legend-swatch--private {
  background: var(--success);
}

/* ---- Day detail modal ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-box {
  background: var(--bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-modal);
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 22px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 800;
}

/* ---- Mobile ---- */

@media (max-width: 520px) {
  body {
    padding: 24px 16px 48px;
  }

  .app-header {
    flex-direction: column;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .family-banner {
    flex-direction: column;
  }

  .family-banner-actions {
    width: 100%;
  }

  .form-actions {
    flex-direction: column;
  }

  button[type="submit"],
  .secondary-btn {
    width: 100%;
  }

  #calendar-section {
    padding: 16px;
  }

  .calendar-cell {
    min-height: 56px;
  }

  .calendar-item-stripe,
  .calendar-day-more-stripe {
    font-size: 7px;
  }

  .calendar-grid {
    gap: 3px;
  }
}
