:root{
  --bg1:#0b1220;
  --bg2:#101b33;

  --text:#e7eefc;
  --muted:#a7b3cc;

  --border:rgba(255,255,255,.10);
  --shadow: 0 20px 60px rgba(0,0,0,.45);

  --red: rgba(239,68,68,1);
  --redSoft: rgba(239,68,68,.22);
  --redBorder: rgba(239,68,68,.72);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);

  /* Background outside card */
  background:
    radial-gradient(1200px 700px at 20% 10%, rgba(255,80,90,.26), transparent 60%),
    radial-gradient(900px 600px at 90% 30%, rgba(255,40,70,.18), transparent 55%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
}

.page{
  min-height:100%;
  display:grid;
  place-items:center;
  padding:28px 16px;
}

/* Calendar container */
.wrapper{
  width:min(520px, 100%);
  display:grid;
  grid-template-columns: repeat(7, minmax(44px, 1fr));
  gap:10px;

  padding:18px;
  border:1px solid var(--border);
  border-radius:18px;

  /* Solid card so gradients don't bleed into it */
  background: rgba(12, 18, 32, .96);

  box-shadow: var(--shadow);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Header */
.previous, .next{
  height:44px;
  width:44px;
  border-radius:14px;
  border:1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.04));
  color:var(--text);
  font-size:26px;
  line-height:1;
  display:grid;
  place-items:center;
  cursor:pointer;
  transition: transform .12s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
  box-shadow: 0 10px 25px rgba(0,0,0,.25);
}
.previous:hover, .next:hover{
  transform: translateY(-1px);
  border-color: rgba(255,80,90,.65);
  box-shadow: 0 14px 35px rgba(0,0,0,.35);
}
.previous:active, .next:active{ transform: translateY(0); }

.month{
  grid-column: span 5;
  height:44px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.06);
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding:6px 10px;
}
.month .month-name{
  font-weight:800;
  letter-spacing:.2px;
}
.month .month-year{
  margin-left:10px;
  color:var(--muted);
  font-weight:700;
  font-variant-numeric: tabular-nums;
}

/* Day names */
.day-of-week{
  height:38px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color:var(--muted);
  font-size:12px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* Date cells */
.date-number{
  height:52px;
  border-radius:14px;
  border:1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  display:flex;
  align-items:center;
  justify-content:center;
  user-select:none;

  font-weight:800;
  font-variant-numeric: tabular-nums;
  cursor:pointer;

  position:relative;

  transition: transform .12s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease, color .2s ease;
}

.date-number:hover{
  transform: translateY(-1px);
  background: linear-gradient(180deg, rgba(255,80,90,.22), rgba(255,255,255,.04));
  border-color: rgba(255,80,90,.45);
  box-shadow: 0 12px 28px rgba(0,0,0,.25);
}
.date-number:active{ transform: translateY(0); }

/* Weekend columns (Sun & Sat) - neutral */
.date-number.is-weekend{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
}

/* Other month numbers (more subtle / more transparent) */
.date-number.other-month{
  color: rgba(167,179,204,.28);
  background: rgba(255,255,255,.01);
  border-color: rgba(255,255,255,.07);
  box-shadow: none;
}
.date-number.other-month:hover{
  transform:none;
  border-color: rgba(255,255,255,.07);
  background: rgba(255,255,255,.01);
  box-shadow:none;
}

/* Today highlight (red) */
.today{
  border-color: var(--redBorder);
  box-shadow: 0 0 0 3px rgba(239,68,68,.22) inset;
  background: linear-gradient(180deg, var(--redSoft), rgba(255,255,255,.04));
  color: var(--text);
}

/* Dot indicator if reminder exists */
.has-note::after{
  content:"";
  position:absolute;
  right:10px;
  bottom:10px;
  width:7px;
  height:7px;
  border-radius:999px;
  background: rgba(239,68,68,.95);
  box-shadow: 0 0 0 3px rgba(239,68,68,.18);
}

/* Footer row */
.today-row{
  grid-column: 1 / -1;
  margin-top: 2px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--muted);
  font-weight:700;
  font-size:13px;
  display:flex;
  justify-content:center;
  letter-spacing:.2px;
}

.today-row strong{
  margin-left: 6px; /* space after "Today:" */
  color: var(--text);
  font-weight:800;
}

/* ===== Modal ===== */
.modal-backdrop{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.55);
  display:grid;
  place-items:center;
  padding: 20px;
  z-index: 1000;
}

/* ✅ FIX: hide modal when [hidden] attribute is present */
.modal-backdrop[hidden]{
  display:none;
}

.modal{
  width: min(520px, 100%);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(12, 18, 32, .98);
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
  overflow:hidden;
}

.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
}

.modal-title{
  font-weight: 900;
  letter-spacing:.2px;
}

.modal-close{
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  color: var(--text);
  cursor:pointer;
}
.modal-close:hover{
  border-color: rgba(239,68,68,.55);
  background: rgba(239,68,68,.10);
}

.modal-body{
  padding: 14px 16px 10px;
}

.modal-date{
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 10px;
}

.modal-label{
  display:block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.modal-textarea{
  width:100%;
  resize: vertical;
  min-height: 120px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  color: var(--text);
  padding: 12px 12px;
  outline: none;
  font-weight: 650;
  line-height: 1.35;
}
.modal-textarea:focus{
  border-color: rgba(239,68,68,.55);
  box-shadow: 0 0 0 3px rgba(239,68,68,.16);
}

.modal-hint{
  margin-top: 10px;
  color: rgba(167,179,204,.7);
  font-size: 12px;
  font-weight: 650;
}

.modal-actions{
  display:flex;
  gap:10px;
  align-items:center;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.spacer{ flex:1; }

.btn{
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 850;
  cursor:pointer;
  transition: transform .12s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.btn:hover{
  transform: translateY(-1px);
  border-color: rgba(255,80,90,.55);
  box-shadow: 0 12px 28px rgba(0,0,0,.25);
}
.btn:active{ transform: translateY(0); }

.btn-primary{
  border-color: rgba(239,68,68,.55);
  background: rgba(239,68,68,.16);
}
.btn-primary:hover{
  border-color: rgba(239,68,68,.75);
  background: rgba(239,68,68,.22);
}

.btn-secondary{
  background: rgba(255,255,255,.05);
}

.btn-ghost{
  background: rgba(255,255,255,.02);
  color: rgba(231,238,252,.85);
}

/* ===== Mobile centering & safe viewport ===== */

/* Use "small viewport height" on mobile so centering works better with browser bars */
.page{
  min-height: 100vh;
  min-height: 100svh;
}

/* Make modal always centered and readable on small screens */
.modal-backdrop{
  min-height: 100vh;
  min-height: 100svh;
}

.modal{
  max-height: calc(100svh - 40px);
  overflow: auto; /* if content is taller than screen */
  -webkit-overflow-scrolling: touch;
}

/* Phones */
@media (max-width: 480px){
  .page{
    padding: 16px 10px;
  }

  .wrapper{
    width: 100%;
    margin: 0 auto;   /* center horizontally */
    gap: 8px;
    padding: 14px;
    border-radius: 16px;
  }

  .date-number{
    height: 48px;
    border-radius: 12px;
  }

  .previous, .next, .month{
    height: 42px;
  }

  /* Modal: full width card, centered */
  .modal-backdrop{
    padding: 12px;
    place-items: center;
  }

  .modal{
    width: 100%;
    border-radius: 16px;
  }

  .modal-actions{
    flex-wrap: wrap; /* buttons won’t overflow */
  }

  .btn{
    flex: 1 1 120px;
  }
}

/* Very short screens (landscape phones) */
@media (max-height: 520px){
  .modal{
    max-height: calc(100svh - 24px);
  }
}
