/* ═══════════════════════════════════════════════════════════════════
   NATALY'S PLANNER — STYLES
   Bright, colorful, fresh. Mobile-first responsive.
═══════════════════════════════════════════════════════════════════ */

/* ── TOKENS ─────────────────────────────────────────────────────── */
:root {
  --bg-1:        #fff5f9;
  --bg-2:        #f4e8ff;
  --bg-grad:     linear-gradient(135deg, #fff5f9 0%, #f4e8ff 60%, #e8f7ff 100%);
  --surface:     #ffffff;

  --pink:        #ff6b9d;
  --pink-d:      #e94d85;
  --violet:      #a78bfa;
  --violet-d:    #8b6af0;
  --mint:        #60d394;
  --mint-d:      #42b878;
  --sun:         #ffd166;
  --sun-d:       #f0b94a;
  --sky:         #60b8ff;
  --coral:       #ff8a80;

  --text:        #2b1840;
  --text2:       #5c4672;
  --muted:       #9a8bb0;
  --border:      rgba(167,139,250,0.25);
  --border2:     rgba(167,139,250,0.12);

  --shadow:      0 4px 24px rgba(255,107,157,0.12);
  --shadow2:     0 12px 40px rgba(167,139,250,0.22);
  --shadow-pink: 0 4px 14px rgba(255,107,157,0.45);

  --radius:      14px;
  --hh:          56px;
  --px-min:      1.5;
}

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

html, body {
  height: 100%;
  height: 100dvh;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; }

/* Buttons should never show iOS share/copy callout on long-press */
button, .btn {
  -webkit-touch-callout: none;
}

/* Safe-area padding on fixed/anchored elements so iPhone notch + home
   indicator don't overlap content. viewport-fit=cover in the <meta> tag
   makes these env() values meaningful. */

/* ═══════════════════════════════════════════════════════════════════
   LOGIN SCREEN
═══════════════════════════════════════════════════════════════════ */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: linear-gradient(135deg, #ff6b9d 0%, #a78bfa 50%, #60d394 100%);
  background-size: 200% 200%;
  animation: loginBgShift 14s ease-in-out infinite;
  z-index: 2000;
}

@keyframes loginBgShift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.login-card {
  background: rgba(255,255,255,0.95);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-radius: 28px;
  padding: 44px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 30px 60px rgba(43,24,64,0.28);
  text-align: center;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.9) translateY(18px); }
  to   { opacity: 1; transform: scale(1)   translateY(0);    }
}

.login-emoji {
  font-size: 3.4rem;
  line-height: 1;
  margin-bottom: 14px;
  display: inline-block;
  animation: floaty 3.5s ease-in-out infinite;
}

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-4px) rotate(2deg); }
}

.login-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 28px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.login-input {
  width: 100%;
  padding: 15px 18px;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: #fafaff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 14px;
  text-align: center;
  letter-spacing: 2px;
  font-weight: 600;
}
.login-input:focus {
  border-color: var(--pink);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255,107,157,0.16);
}

.login-btn {
  width: 100%;
  padding: 15px 22px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--pink) 0%, var(--violet) 100%);
  cursor: pointer;
  box-shadow: var(--shadow-pink);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  letter-spacing: 0.5px;
}
.login-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(255,107,157,0.55); }
.login-btn:active:not(:disabled) { transform: translateY(0); }
.login-btn:disabled { opacity: 0.6; cursor: wait; }

.login-error {
  margin-top: 12px;
  color: #c44040;
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 1em;
}

.login-hint {
  margin-top: 20px;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.login-link {
  display: inline-block;
  margin-top: 14px;
  background: none;
  border: none;
  color: var(--violet-d);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.login-link:hover { color: var(--pink-d); background: rgba(167,139,250,0.08); }
.login-link:disabled { opacity: 0.6; cursor: wait; }

.login-info {
  margin-top: 12px;
  color: var(--mint-d);
  font-size: 0.82rem;
  font-weight: 700;
  min-height: 1em;
}

/* ═══════════════════════════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════════════════════════ */
.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ─────────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, #ff6b9d 0%, #c070e8 45%, #a78bfa 100%);
  color: white;
  padding: 0 24px;
  /* Respect iPhone notch / Dynamic Island — header grows a bit on devices with a top inset */
  padding-top: env(safe-area-inset-top);
  padding-left: calc(24px + env(safe-area-inset-left));
  padding-right: calc(24px + env(safe-area-inset-right));
  height: calc(68px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(167,139,250,0.30);
  position: relative;
  z-index: 100;
}

header::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(255,209,102,0.18) 0%, transparent 50%),
    radial-gradient(circle at 80% 40%, rgba(96,211,148,0.15) 0%, transparent 50%);
  pointer-events: none;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.22);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.header-brand h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1;
}

.header-brand p {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.82);
  font-weight: 500;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  margin-top: 3px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  position: relative;
}

/* ═══════════════════════════════════════════════════════════════════
   BRAND MENU — dropdown under "Nataly's Vida" title
   Contains Language + Sign out so the top header stays clean on mobile.
   Brand sits on the RIGHT of the header (flex source order). Dropdown
   anchors from the right edge so it lines up under the trigger.
═══════════════════════════════════════════════════════════════════ */
.brand-menu-trigger {
  background: none;
  border: none;
  color: inherit;
  padding: 2px 10px 2px 2px;
  cursor: pointer;
  font-family: inherit;
  border-radius: 16px;
  transition: background 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.brand-menu-trigger:hover { background: rgba(255,255,255,0.08); }
.brand-menu-trigger:active { transform: scale(0.98); }
.brand-menu-trigger:focus-visible {
  outline: 2px solid rgba(255,255,255,0.5);
  outline-offset: 2px;
}
.brand-menu-trigger .header-brand { cursor: pointer; }
.brand-menu-chevron {
  font-size: 0.7rem;
  opacity: 0.55;
  margin-left: 4px;
  align-self: center;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.brand-menu-trigger:hover .brand-menu-chevron { opacity: 0.9; }
.brand-menu-trigger[aria-expanded="true"] .brand-menu-chevron {
  transform: rotate(180deg);
  opacity: 1;
}
.brand-menu {
  position: absolute;
  top: 100%;
  right: 24px;
  left: auto;
  margin-top: 6px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(43,24,64,0.25);
  padding: 8px;
  min-width: 220px;
  z-index: 600;
  display: flex; flex-direction: column; gap: 2px;
  animation: brand-menu-in 0.18s ease;
}
.brand-menu[hidden] { display: none; }
@keyframes brand-menu-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.brand-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.12s ease;
}
.brand-menu-item:hover { background: var(--bg-2); }
.brand-menu-item .brand-menu-icon { font-size: 1.1rem; }
.brand-menu-danger { color: var(--pink-d); }
.brand-menu-danger:hover { background: rgba(255,107,157,0.1); }

.week-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 12px;
  padding: 5px 8px;
  margin-right: 4px;
}

.week-nav span {
  font-size: 0.78rem;
  color: white;
  font-weight: 700;
  min-width: 90px;
  text-align: center;
  letter-spacing: 0.2px;
}
.week-label-sub { font-weight: 500; opacity: 0.75; font-size: 0.82em; }

.week-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 8px;
  border-radius: 8px;
  transition: all 0.15s;
  font-family: inherit;
  line-height: 1;
}
.week-btn:hover { background: rgba(255,255,255,0.22); color: white; }

/* ── BUTTONS ─────────────────────────────────────────────────────── */
.btn {
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.18s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.btn-ghost {
  background: rgba(255,255,255,0.18);
  color: white;
  border: 1px solid rgba(255,255,255,0.28);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.btn-ghost:hover { background: rgba(255,255,255,0.28); }

.btn-add-event {
  background: linear-gradient(135deg, #ffd166 0%, #ff8a80 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(255,138,128,0.45);
  font-weight: 800;
}
.btn-add-event:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(255,138,128,0.60);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255,255,255,0.18);
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 1rem;
}
.btn-icon:hover { background: rgba(255,255,255,0.30); }

/* ── TOOLBAR ─────────────────────────────────────────────────────── */
.toolbar {
  background: rgba(255,255,255,0.80);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }

/* Planner action toolbar: same scrolling row pattern as .toolbar,
   with the dark-on-light btn-ghost override so buttons stay readable. */
.planner-actions .btn-ghost {
  background: var(--bg-1);
  color: var(--text2);
  border: 1.5px solid var(--border);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.planner-actions .btn-ghost:hover {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--violet);
}
.planner-actions .week-nav {
  background: var(--bg-1);
  border: 1.5px solid var(--border);
}
.planner-actions .week-nav span { color: var(--text); }
.planner-actions .week-btn { color: var(--text2); }
.planner-actions .week-btn:hover { background: var(--bg-2); }

.toolbar-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--muted);
  font-weight: 700;
  flex-shrink: 0;
}

.day-filter { display: flex; gap: 4px; flex-shrink: 0; }

.day-pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--text2);
  font-family: inherit;
  transition: all 0.15s;
  letter-spacing: 0.3px;
}
.day-pill.active {
  background: linear-gradient(135deg, var(--pink) 0%, var(--violet) 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(167,139,250,0.35);
}
.day-pill:hover:not(.active) { border-color: var(--violet); color: var(--violet-d); }

.toolbar-sep { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }

.view-toggle { display: flex; gap: 4px; flex-shrink: 0; }
.view-btn {
  padding: 5px 14px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--text2);
  font-family: inherit;
  transition: all 0.15s;
}
.view-btn.active {
  background: var(--mint);
  color: white;
  border-color: var(--mint);
}
.view-btn:hover:not(.active) { border-color: var(--mint); color: var(--mint-d); }

.toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.toolbar-icon-btn {
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.toolbar-icon-btn:hover { border-color: var(--violet); background: rgba(167,139,250,0.08); }

/* Colour legend inside the confirmModal */
.legend-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}
.legend-swatch {
  width: 20px; height: 20px; border-radius: 6px;
  border: 2px solid; flex-shrink: 0;
}
.legend-title { flex: 1; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-count { font-size: 0.8rem; color: var(--muted); font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); flex-shrink: 0; box-shadow: 0 0 0 3px rgba(96,211,148,0.22); }
.status-dot.saving { background: var(--sun); box-shadow: 0 0 0 3px rgba(255,209,102,0.25); }
.status-dot.error  { background: #c44040; box-shadow: 0 0 0 3px rgba(196,64,64,0.25); }
.status-text { font-size: 0.7rem; color: var(--muted); font-weight: 600; }

/* (banner removed — Phase 2 switched to direct editing + Defaults modal) */

/* ═══════════════════════════════════════════════════════════════════
   CALENDAR
═══════════════════════════════════════════════════════════════════ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Unified calendar layout: ONE scroll container wraps the time axis and
   the day grid; the day-header row sits above it and never scrolls.
   The time column scrolls with the events naturally (same container)
   — no JS scroll-sync needed. */
.calendar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  min-height: 0;
}

.days-header-row {
  display: grid;
  grid-template-columns: 68px 1fr;
  flex-shrink: 0;
  border-bottom: 1.5px solid var(--border);
  background: rgba(244,232,255,0.45);
  height: var(--hh);
  z-index: 2;
}

.days-header-row::before {
  content: 'Time';
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--muted);
  text-transform: uppercase;
  border-right: 1.5px solid var(--border);
  background: rgba(244,232,255,0.55);
}

.days-header-inner {
  /* JS sets grid-template-columns dynamically based on visibleDays().length */
  display: grid;
  height: 100%;
}

.calendar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  position: relative;
}
.calendar-scroll::-webkit-scrollbar { width: 6px; }
.calendar-scroll::-webkit-scrollbar-track { background: transparent; }
.calendar-scroll::-webkit-scrollbar-thumb { background: rgba(167,139,250,0.3); border-radius: 3px; }

.calendar-inner {
  display: grid;
  grid-template-columns: 68px 1fr;
  min-height: 100%;
}

.time-axis {
  position: relative;
  background: rgba(244,232,255,0.55);
  border-right: 1.5px solid var(--border);
}

.time-tick {
  height: calc(var(--px-min) * 60 * 1px);
  position: relative;
}

.time-tick span {
  position: absolute;
  top: -9px;
  right: 9px;
  font-size: 0.66rem;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.day-head {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--text2);
  border-right: 1px solid var(--border);
  position: relative;
  transition: background 0.15s;
  gap: 2px;
}
.day-head:last-child { border-right: none; }

.day-head.today { background: linear-gradient(180deg, rgba(255,107,157,0.12) 0%, rgba(167,139,250,0.08) 100%); }
.day-head.today .day-name { color: var(--pink-d); }

.day-name { font-size: 0.7rem; font-weight: 800; letter-spacing: 1px; }
.day-date-num {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: 'Playfair Display', serif;
  color: var(--text);
  line-height: 1;
}
.day-head.today .day-date-num {
  background: linear-gradient(135deg, var(--pink) 0%, var(--violet) 100%);
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92rem;
  box-shadow: 0 2px 8px rgba(255,107,157,0.40);
}

.grid-body {
  /* JS sets grid-template-columns dynamically based on visibleDays().length */
  display: grid;
  position: relative;
  min-width: 0;
}

.day-col {
  border-right: 1px solid var(--border);
  position: relative;
  min-width: 0;
  cursor: pointer;
  touch-action: pan-y;
}
.day-col:last-child { border-right: none; }

.hour-line {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: var(--border);
  pointer-events: none;
  z-index: 1;
}
.half-line {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: var(--border2);
  pointer-events: none;
  z-index: 1;
  border-top: 1px dashed rgba(167,139,250,0.18);
}

.now-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: var(--pink);
  z-index: 8;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(255,107,157,0.5);
}
.now-line::before {
  content: '';
  position: absolute;
  left: -5px;
  top: -5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 0 3px rgba(255,107,157,0.25);
}

.drop-indicator {
  position: absolute;
  left: 3%;
  width: 94%;
  border: 2.5px dashed var(--violet);
  border-radius: 10px;
  background: rgba(167,139,250,0.14);
  pointer-events: none;
  z-index: 15;
  display: none;
}

/* ── EVENT CARDS ─────────────────────────────────────────────────── */
.event-card {
  position: absolute;
  left: 3%;
  width: 94%;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.75rem;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  border-left: 4px solid transparent;
  box-shadow: 0 2px 8px rgba(43,24,64,0.08);
  overflow: hidden;
  transition: box-shadow 0.15s, transform 0.1s, opacity 0.15s;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  touch-action: none;
}

.event-card:hover {
  box-shadow: 0 6px 20px rgba(43,24,64,0.18);
  transform: scale(1.015) translateY(-1px);
  z-index: 10;
}

.event-card.dragging {
  opacity: 0.55;
  cursor: grabbing;
  z-index: 20;
  transition: none;
}

/* Events that will be bumped by the in-flight drop — subtle dashed pulse */
.event-card.will-bump {
  outline: 2px dashed var(--violet);
  outline-offset: -2px;
  animation: pulse-bump 0.7s ease-in-out infinite alternate;
}
@keyframes pulse-bump {
  from { outline-color: var(--violet); }
  to   { outline-color: var(--pink); }
}

.event-card .ev-title {
  font-weight: 800;
  font-size: 0.74rem;
  line-height: 1.24;
  pointer-events: none;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  letter-spacing: 0.1px;
}

/* Phase 32: 🔔 badge on Planner toolbar */
.reminder-badge {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: background 0.2s ease, transform 0.2s ease;
}
.reminder-badge.has-pending {
  background: linear-gradient(135deg, rgba(255,193,160,0.22), rgba(255,107,157,0.22));
  color: var(--pink-d, #d4468a);
  animation: rem-badge-pulse 6s ease-in-out infinite;
}
@keyframes rem-badge-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
@media (prefers-reduced-motion: reduce) {
  .reminder-badge.has-pending { animation: none !important; }
}

/* Phase 31: reminder chip in event card title */
.event-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  font-size: 0.72rem;
  opacity: 0.85;
  vertical-align: baseline;
}
.event-chip-reminder {
  filter: drop-shadow(0 0 2px rgba(255, 107, 157, 0.4));
}

.event-card .ev-time {
  font-size: 0.62rem;
  opacity: 0.75;
  font-weight: 700;
  margin-top: 2px;
  pointer-events: none;
  white-space: nowrap;
}

/* Duplicate button in the top-right of each event card */
.ev-copy-btn {
  position: absolute;
  top: 2px;
  right: 4px;
  background: rgba(255,255,255,0.55);
  border: none;
  font-size: 0.85rem;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.1s ease, background 0.15s ease;
  color: inherit;
  font-weight: 700;
  font-family: inherit;
  touch-action: manipulation;
}
.event-card:hover .ev-copy-btn,
.event-card.dragging .ev-copy-btn { opacity: 1; }
.ev-copy-btn:hover { background: white; transform: scale(1.12); }
@media (hover: none) {
  /* On touch there's no hover — keep it faintly visible so she knows it exists */
  .ev-copy-btn { opacity: 0.55; }
}

/* Pulse for a freshly-duplicated card */
.event-card.pulse-in {
  animation: pulse-in 1.2s ease-out;
}
@keyframes pulse-in {
  0%   { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(167,139,250,0.35); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(167,139,250,0); }
}

.resize-handle {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  height: 9px;
  cursor: ns-resize;
  background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.10));
  border-radius: 0 0 10px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.resize-handle::after {
  content: '⋯';
  font-size: 0.6rem;
  opacity: 0.55;
  letter-spacing: 1px;
}

/* ═══════════════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(43,24,64,0.55);
  z-index: 500;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 22px;
  padding: 32px;
  width: 460px;
  max-width: 95vw;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow2), 0 0 0 1px rgba(167,139,250,0.18);
  animation: modalIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Wide variant for the Defaults template editor — it needs room for a
   full 7-day grid */
.modal-xwide {
  width: min(1100px, 96vw);
  max-width: 96vw;
  padding: 28px 28px 24px;
}
.modal-sub {
  color: var(--text2);
  font-size: 0.85rem;
  margin: -6px 0 16px;
  line-height: 1.4;
}
.defaults-calendar {
  /* Contain the embedded calendar so it scrolls inside the modal */
  height: min(70dvh, 640px);
  display: flex;
  flex-direction: column;
}
.defaults-calendar .calendar-wrapper {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--border);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

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

.modal-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 34px; height: 34px;
  border: none;
  background: var(--bg-1);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.15s;
  font-family: inherit;
}
.modal-close:hover { background: var(--bg-2); color: var(--text); }

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
  margin-bottom: 8px;
}

.form-input, .form-select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  /* 16px minimum on iOS — smaller values trigger zoom-on-focus */
  font-size: 16px;
  color: var(--text);
  background: var(--bg-1);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--violet);
  background: white;
  box-shadow: 0 0 0 3px rgba(167,139,250,0.18);
}

.time-row { display: flex; gap: 12px; }
.time-row > div { flex: 1; }

.repeat-options { display: flex; gap: 8px; flex-wrap: wrap; }
.repeat-pill {
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 800;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--text2);
  font-family: inherit;
  transition: all 0.15s;
}
.repeat-pill.active {
  background: linear-gradient(135deg, var(--pink) 0%, var(--violet) 100%);
  color: white;
  border-color: transparent;
}

.day-checkboxes { display: flex; gap: 6px; flex-wrap: wrap; }
.day-cb-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  border: 1.5px solid var(--border);
  color: var(--text2);
  background: white;
  transition: all 0.15s;
  user-select: none;
  min-width: 48px;
}
.day-cb-label input { display: none; }
.day-cb-label.checked {
  background: linear-gradient(135deg, var(--mint) 0%, #3cb878 100%);
  color: white;
  border-color: transparent;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.swatch {
  aspect-ratio: 1;
  border-radius: 10px;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
  position: relative;
}
.swatch:hover { transform: scale(1.15); }
.swatch.selected {
  border-color: var(--text);
  transform: scale(1.1);
}

/* Live preview of the auto-assigned colour as you type a new title */
.swatch.preview {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
  opacity: 0.9;
}
.swatch.preview.selected { outline: none; }

.form-hint {
  font-weight: 500;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0.3px;
  margin-left: 6px;
}
.swatch.selected::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: rgba(43,24,64,0.80);
  font-weight: 900;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.btn-modal-ghost {
  background: var(--bg-1);
  color: var(--text2);
  border: none;
}
.btn-modal-ghost:hover { background: var(--bg-2); }

.btn-modal-primary {
  background: linear-gradient(135deg, var(--pink) 0%, var(--violet) 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(167,139,250,0.40);
}
.btn-modal-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(167,139,250,0.55); }

.btn-modal-danger { background: #fff0f0; color: #c44040; border: none; margin-right: auto; }
.btn-modal-danger:hover { background: #ffe0e0; }

/* Shared modal size class — used by goal modal, categories modal, etc. */
.modal-wide { width: min(640px, 96vw); }

/* ═══════════════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: calc(28px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 13px 22px;
  background: linear-gradient(135deg, var(--text) 0%, var(--text2) 100%);
  color: white;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: var(--shadow2);
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.toast { gap: 14px; align-items: center; pointer-events: none; }
.toast.show { pointer-events: auto; }
.toast-action {
  background: rgba(255,255,255,0.22);
  border: none;
  color: white;
  padding: 4px 12px;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
  font-size: 0.78rem;
  font-family: inherit;
  letter-spacing: 0.3px;
}
.toast-action:hover { background: rgba(255,255,255,0.35); }

/* ═══════════════════════════════════════════════════════════════════
   EMPTY HINT
═══════════════════════════════════════════════════════════════════ */
.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
@media (hover: hover) {
  .day-col:hover .empty-hint { opacity: 1; }
}
.empty-hint span {
  font-size: 0.72rem;
  color: var(--violet);
  background: rgba(167,139,250,0.14);
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: 800;
  border: 1.5px dashed rgba(167,139,250,0.40);
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE — ≤900px
═══════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  header {
    padding: 0 14px;
    height: 60px;
  }
  .header-brand h1 { font-size: 1.2rem; white-space: nowrap; }
  .header-brand p { display: none; }
  .brand-icon { width: 34px; height: 34px; font-size: 1rem; }
  .brand-menu-trigger { padding: 2px 6px 2px 2px; min-width: 0; }
  .brand-menu-trigger .header-brand { gap: 8px; min-width: 0; }
  .brand-menu-chevron { margin-left: 2px; }
  .brand-menu { right: 14px; }
  .header-actions .btn span.btn-label { display: none; }
  .btn-ghost { padding: 8px 10px; }
  .week-nav { padding: 4px 4px; margin-right: 2px; }
  .week-nav span { min-width: 74px; font-size: 0.72rem; }

  .toolbar {
    padding: 8px 14px;
    gap: 10px;
  }
  .toolbar-label { display: none; }
  .view-toggle { display: none; }
  .toolbar-sep { display: none; }
  .toolbar-right .status-text { display: none; }

  /* banner removed */

  /* Shrink the time axis gutter on tablets */
  .days-header-row,
  .calendar-inner { grid-template-columns: 52px 1fr; }
  .time-tick span { font-size: 0.6rem; right: 6px; }

  .day-col { min-width: 0; }
  .day-name { font-size: 0.62rem; letter-spacing: 0.5px; }
  .day-date-num { font-size: 1rem; }
  .day-head.today .day-date-num { width: 26px; height: 26px; font-size: 0.82rem; }

  .event-card { padding: 5px 8px; }
  .event-card .ev-title { font-size: 0.7rem; }
  .event-card .ev-time { font-size: 0.56rem; }
}

/* ═══════════════════════════════════════════════════════════════════
   PHONES — ≤600px
═══════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  header { padding: 0 10px; }
  .header-brand h1 { font-size: 1rem; }
  .header-brand { gap: 8px; }
  .brand-icon { width: 28px; height: 28px; font-size: 0.85rem; }
  .brand-menu-trigger { padding: 2px 4px; }
  .brand-menu { right: 10px; min-width: 200px; }
  .btn-add-event { padding: 8px 12px; font-size: 0.72rem; }
  .week-nav span { min-width: 62px; font-size: 0.66rem; }

  .toolbar { padding: 6px 10px; gap: 8px; }
  .day-pill { padding: 5px 10px; font-size: 0.68rem; }

  /* Modal becomes bottom sheet */
  .modal-overlay { align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: 100vw;
    border-radius: 22px 22px 0 0;
    padding: 24px 20px 28px;
    max-height: 92dvh;
    animation: sheetIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  }
  @keyframes sheetIn {
    from { opacity: 0; transform: translateY(60px); }
    to   { opacity: 1; transform: translateY(0);    }
  }
  .modal-header h2 { font-size: 1.3rem; }
  .form-group { margin-bottom: 16px; }
  .swatch-grid { grid-template-columns: repeat(8, 1fr); }
  .modal-footer { flex-direction: column-reverse; align-items: stretch; }
  .modal-footer .btn { justify-content: center; padding: 13px; }
  .btn-modal-danger { margin-right: 0; }

  /* Even narrower on phones */
  .days-header-row,
  .calendar-inner { grid-template-columns: 46px 1fr; }
  /* banner-btn removed */
}

/* ═══════════════════════════════════════════════════════════════════
   PRINT
═══════════════════════════════════════════════════════════════════ */
@media print {
  body { background: white !important; overflow: auto; height: auto; }
  header, .toolbar { display: none !important; }
  .login-screen, #resetScreen, .modal-overlay, .toast { display: none !important; }
  .main { overflow: auto; }
  .calendar-wrapper { overflow: visible; box-shadow: none !important; border-radius: 0 !important; }
  .calendar-scroll { overflow: visible !important; }
  .grid-body { overflow: visible; height: auto; }
  .event-card { box-shadow: none !important; page-break-inside: avoid !important; }
  .ev-copy-btn, .resize-handle, .drop-indicator, .empty-hint, .now-line { display: none !important; }
  .calendar-scroll::-webkit-scrollbar,
  .grid-body::-webkit-scrollbar { display: none !important; }
  @page { size: A4 landscape; margin: 10mm; }
  .login-screen { display: none !important; }
}

/* ── Reduced motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   5-PILL SECTION TOGGLE
═══════════════════════════════════════════════════════════════════ */
.section-toggle {
  display: inline-flex;
  background: rgba(255,255,255,0.22);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
  flex-shrink: 0;
}
.section-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.88);
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.2px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.section-btn .pill-label { font-weight: 800; }
.section-btn:hover {
  color: white;
  background: rgba(255,255,255,0.15);
}
.section-btn.active {
  background: white;
  color: var(--pink-d);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.section-planner,
.section-home,
.section-budget,
.section-savings,
.section-mood {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.home-loading {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-style: italic;
}

/* Narrow: icons only */
@media (max-width: 900px) {
  .section-btn .pill-label { display: none; }
  .section-btn { padding: 8px 10px; font-size: 1rem; }
}
@media (max-width: 420px) {
  .section-toggle { padding: 3px; }
  .section-btn { padding: 6px 8px; }
}

/* When the whole app is pushed into one of the non-planner sections,
   we add a little breathing padding on the body so custom section content
   can control its own layout. */
body.in-home,
body.in-budget,
body.in-savings,
body.in-mood {
  /* reserved for per-section theming hooks */
}

/* ═══════════════════════════════════════════════════════════════════
   PRINT (Phase 21)
═══════════════════════════════════════════════════════════════════ */
@media print {
  body { background: white !important; color: black !important; }
  .app-header, .section-btn, .btn, .li-drawer, .quick-mood-fab, .quick-mood-popover,
  .modal-overlay, .drawer-backdrop, .manifest-btn, .manif-add-btn, .mood-start-btn,
  .cat-card[disabled], .cat-card-footer, .mood-entry-edit, .mood-metrics-caveat,
  .budget-toolbar, .manif-toolbar, .mood-toolbar { display: none !important; }
  .section-planner, .section-budget, .section-savings, .section-mood, .section-home {
    display: block !important;
    padding: 20px !important;
    box-shadow: none !important;
  }
  .dash-hero, .manif-hero, .mood-metrics, .dash-stat, .goal-card, .cat-card, .mood-entry {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    page-break-inside: avoid !important;
  }
  .dash-hero-bg, .manif-hero-bg { display: none !important; }
  .ring-progress, .manifest-btn { animation: none !important; }
  @page { margin: 1.2cm; }
}

/* ═══════════════════════════════════════════════════════════════════
   GLOBAL REDUCED-MOTION AUDIT (Phase 21)
═══════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .manifest-btn { animation: none !important; }
  .dash-hero-bg, .manif-hero-bg { background: var(--surface) !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   REMINDER COACHING CARD (iPhone first-run)
═══════════════════════════════════════════════════════════════════ */
.reminder-coach-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(40, 20, 60, 0);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.28s ease, background 0.28s ease;
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
}
.reminder-coach-overlay.open {
  opacity: 1;
  background: rgba(40, 20, 60, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.reminder-coach-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 28px 26px;
  max-width: 380px; width: 100%;
  box-shadow: 0 24px 64px rgba(167, 139, 250, 0.45);
  transform: translateY(16px);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.reminder-coach-overlay.open .reminder-coach-card { transform: translateY(0); }
.reminder-coach-emoji { font-size: 2.4rem; text-align: center; margin-bottom: 8px; }
.reminder-coach-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem; font-weight: 700; color: var(--text);
  text-align: center; margin: 0 0 18px;
  letter-spacing: -0.3px; line-height: 1.25;
}
.reminder-coach-steps {
  padding: 0 0 0 24px; margin: 0 0 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.reminder-coach-steps li {
  font-size: 0.92rem; color: var(--text); line-height: 1.45;
}
.reminder-coach-hint {
  font-size: 0.82rem; color: var(--muted); font-style: italic;
  text-align: center; margin: 0 0 20px;
}
.reminder-coach-btn {
  width: 100%; padding: 14px 20px;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  color: white; border: none; border-radius: 14px;
  font-family: inherit; font-size: 0.95rem; font-weight: 800;
  cursor: pointer;
}
@media (prefers-reduced-motion: reduce) {
  .reminder-coach-overlay,
  .reminder-coach-card { transition: none !important; transform: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   MODAL-SLIM + money-input utilities (used by goalRingModal)
═══════════════════════════════════════════════════════════════════ */
.modal.modal-slim {
  max-width: 420px;
  width: min(420px, 94vw);
}
.modal-body {
  padding: 18px 22px 8px;
}
.modal-lead {
  color: var(--muted, #8a8299);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 14px;
}
.modal-hint {
  color: var(--muted, #8a8299);
  font-size: 0.82rem;
  line-height: 1.45;
  margin: 12px 0 0;
  font-style: italic;
}
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-input-money {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-1, #faf5fc);
  border: 1.5px solid var(--border, #e8dff2);
  border-radius: 12px;
  padding: 0 14px;
  transition: border-color 0.15s ease;
}
.form-input-money:focus-within {
  border-color: var(--violet, #8b7dd8);
}
.form-input-money-prefix {
  color: var(--muted, #8a8299);
  font-weight: 700;
  font-size: 1rem;
}
.form-input-money-field {
  border: none !important;
  background: none !important;
  flex: 1;
  padding: 12px 0;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.form-input-money-field:focus {
  outline: none;
}
