:root {
  --font-display: "DM Serif Display", Georgia, serif;
  --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --bg: #FAF7F2;
  --bg-card: #FFFFFF;
  --bg-overlay: rgba(42, 36, 28, 0.55);
  --text-primary: #2A241C;
  --text-secondary: #8C8279;
  --text-muted: #B5AEA6;
  --border: #E8E2DA;
  --border-light: #F0EBE4;
  --shadow-sm: 0 1px 3px rgba(42, 36, 28, 0.06);
  --shadow-md: 0 4px 20px rgba(42, 36, 28, 0.08);
  --shadow-lg: 0 12px 40px rgba(42, 36, 28, 0.12);
  --shadow-xl: 0 20px 60px rgba(42, 36, 28, 0.16);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle paper grain texture */
.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.3;
  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");
}

.hidden {
  display: none !important;
}

/* ============================================
   PASSWORD OVERLAY
   ============================================ */
#password-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: overlayIn 0.4s ease-out;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.password-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 3rem 2.5rem 2.5rem;
  box-shadow: var(--shadow-xl), 0 0 0 1px var(--border-light);
  text-align: center;
  max-width: 400px;
  width: 90%;
  animation: cardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

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

.password-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.password-card h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 0.375rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.password-card > p {
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
  font-size: 0.925rem;
}

.password-card form {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.input-wrap {
  position: relative;
}

.password-card input {
  width: 100%;
  padding: 0.875rem 1.125rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  background: var(--bg);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.password-card input::placeholder {
  color: var(--text-muted);
}

.password-card input:focus {
  border-color: var(--text-secondary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(140, 130, 121, 0.12);
}

.password-card button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  background: var(--text-primary);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.925rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
  letter-spacing: 0.01em;
}

.password-card button:hover {
  background: #1a1510;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.password-card button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.error {
  color: #dc2626;
  font-size: 0.85rem;
  margin-top: 0.75rem;
  font-weight: 500;
}

/* ============================================
   CALENDAR APP
   ============================================ */
#calendar-app {
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
  animation: appIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
}

.header-eyebrow {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

header h1 {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* Calendar Container */
.calendar-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md), 0 0 0 1px var(--border-light);
}

/* Navigation */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding: 0 0.25rem;
}

.calendar-nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.calendar-nav button:hover {
  background: var(--border-light);
  border-color: var(--text-muted);
}

.calendar-nav button:active {
  transform: scale(0.95);
}

#month-label {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* Calendar Grid */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.day-header {
  text-align: center;
  font-weight: 500;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0.25rem 0 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#calendar-days {
  display: contents;
}

/* Day Cells */
.day-cell {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  cursor: default;
  transition: transform 0.1s, box-shadow 0.1s;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.day-cell:not(.empty):hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-md);
  z-index: 2;
}

.day-cell.empty {
  background: transparent;
}

.day-cell.today {
  outline: 2.5px solid var(--text-primary);
  outline-offset: 1px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.day-cell .transition-indicator {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 0.5rem;
  opacity: 0.8;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-shadow: none;
  background: rgba(0, 0, 0, 0.2);
  padding: 0 3px;
  border-radius: 3px;
  line-height: 1.4;
}

/* ============================================
   LEGEND
   ============================================ */
.legend {
  text-align: center;
  margin-top: 1.5rem;
}

.legend-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
  font-style: italic;
}

.legend-items {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  display: inline-block;
  box-shadow: inset 0 -1px 2px rgba(0, 0, 0, 0.1);
}

.legend-color-split {
  background: linear-gradient(135deg, var(--text-muted) 50%, var(--border) 50%) !important;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-light);
}

footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
  #calendar-app {
    padding: 1.5rem 0.75rem 2rem;
  }

  header h1 {
    font-size: 1.75rem;
  }

  .calendar-container {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .calendar-grid {
    gap: 3px;
  }

  .day-header {
    font-size: 0.6rem;
    padding-bottom: 0.5rem;
  }

  .day-cell {
    font-size: 0.78rem;
    border-radius: 6px;
  }

  .day-cell:not(.empty):hover {
    transform: none;
    box-shadow: none;
  }

  .day-cell .transition-indicator {
    font-size: 0.4rem;
    bottom: 1px;
    right: 2px;
  }

  .calendar-nav button {
    width: 36px;
    height: 36px;
  }

  #month-label {
    font-size: 1.15rem;
  }

  .legend-items {
    gap: 1rem;
  }

  .legend-item {
    font-size: 0.8rem;
  }
}

@media (max-width: 380px) {
  .calendar-container {
    padding: 0.75rem;
  }

  .calendar-grid {
    gap: 2px;
  }

  .day-cell {
    font-size: 0.7rem;
    border-radius: 5px;
  }

  .day-cell .transition-indicator {
    display: none;
  }
}
