:root {
  --tabbar-h: 62px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: linear-gradient(170deg, #fff5f8 0%, #ffe3ec 45%, #ffd0e0 100%);
  font-family: "Gowun Dodum", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  color: #6b2b41;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* 배경이 은은하게 숨쉬듯 밝아졌다 어두워진다 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.85), transparent 60%);
  animation: breathe 6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes breathe {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.75; }
}

#hearts {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

main {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(24px + env(safe-area-inset-top))
    calc(24px + env(safe-area-inset-right))
    calc(24px + var(--tabbar-h) + env(safe-area-inset-bottom))
    calc(24px + env(safe-area-inset-left));
  pointer-events: none;
}

section {
  text-align: center;
}

.greeting {
  font-size: clamp(1.4rem, 6vw, 2rem);
  color: #d67b9a;
  margin-bottom: 8px;
  opacity: 0;
  animation: rise 0.9s ease-out 0.1s forwards;
}

.couple {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3vw, 20px);
  font-size: clamp(2.4rem, 12vw, 4.5rem);
  font-weight: 400;
  line-height: 1.3;
  text-shadow: 0 2px 12px rgba(255, 255, 255, 0.8);
}

.name {
  opacity: 0;
  animation: rise 0.9s ease-out forwards;
}

.name:first-of-type { animation-delay: 0.3s; }
.name:last-of-type { animation-delay: 0.7s; }

.heart {
  color: #ff5a86;
  font-size: 0.85em;
  opacity: 0;
  animation: rise 0.6s ease-out 0.5s forwards, beat 1.2s ease-in-out 1.1s infinite;
  text-shadow: 0 0 18px rgba(255, 90, 134, 0.5);
}

.dday {
  font-size: clamp(1.3rem, 5.5vw, 1.9rem);
  color: #d67b9a;
  margin-top: 14px;
  opacity: 0;
  animation: rise 0.9s ease-out 1s forwards;
}

.hint {
  margin-top: 28px;
  font-size: clamp(0.85rem, 3.5vw, 1rem);
  color: #c98ba3;
  opacity: 0;
  animation: fadeInOut 3s ease-in-out 1.6s infinite;
}

/* ── 하단 탭바 ── */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 140, 175, 0.26);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 0 7px;
  color: #dba7be;
  text-decoration: none;
  font-size: 0.7rem;
}

.tabbar a[aria-current="page"] {
  color: #ff5a86;
}

.tabbar .ico {
  position: relative;
  display: block;
}

.tabbar svg {
  width: 22px;
  height: 22px;
  display: block;
}

/* 안 읽은 글이 있을 때만 켜지는 점 */
.tabbar .dot {
  position: absolute;
  top: -1px;
  right: -6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff5a86;
}

.tabbar .dot[hidden] {
  display: none;
}

/* ── 글 남기기 페이지 ── */
.page-notes {
  overflow-y: auto;
}

.page-notes textarea {
  user-select: text;
  -webkit-user-select: text;
}

.notes {
  display: block;
  height: auto;
  min-height: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding:
    calc(20px + env(safe-area-inset-top))
    calc(20px + env(safe-area-inset-right))
    calc(40px + var(--tabbar-h) + env(safe-area-inset-bottom))
    calc(20px + env(safe-area-inset-left));
  pointer-events: auto;
}

.notes-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.notes-header h1 {
  font-size: 1.5rem;
  font-weight: 400;
}

#noteForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 4px 18px rgba(233, 79, 124, 0.08);
}

.who {
  display: flex;
  gap: 8px;
}

.who input {
  position: absolute;
  opacity: 0;
}

.who span {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1.5px solid #f0a8c0;
  color: #b9557d;
  font-size: 0.95rem;
  cursor: pointer;
}

.who input:checked + span {
  background: #ff7ba1;
  border-color: #ff7ba1;
  color: #fff;
}

#noteText {
  border: none;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  padding: 12px;
  font-family: inherit;
  font-size: 1rem;
  color: #6b2b41;
  resize: none;
  outline: none;
}

#noteSubmit {
  border: none;
  border-radius: 999px;
  padding: 10px;
  background: #ff5a86;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

#noteSubmit:disabled {
  opacity: 0.5;
}

.notes-status {
  margin: 14px 4px 6px;
  font-size: 0.9rem;
  color: #c98ba3;
}

.note-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.note-list li {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 14px;
  padding: 12px 14px;
}

.note-list .meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #c9769a;
  margin-bottom: 4px;
}

.note-list .msg {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

/* ── 스페인어 단어장 페이지 ── */
.page-voca {
  overflow-y: auto;
}

/* display 규칙이 hidden 속성을 덮어쓰지 않도록 */
.voca [hidden] {
  display: none !important;
}

.voca {
  display: block;
  height: auto;
  min-height: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding:
    calc(20px + env(safe-area-inset-top))
    calc(20px + env(safe-area-inset-right))
    calc(40px + var(--tabbar-h) + env(safe-area-inset-bottom))
    calc(20px + env(safe-area-inset-left));
  pointer-events: auto;
}

.voca-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 40px;
}

.voca-status {
  text-align: center;
  font-size: 0.95rem;
  color: #c98ba3;
  margin-bottom: 10px;
}

.voca-mode {
  border: none;
  border-radius: 999px;
  padding: 14px;
  background: #ff5a86;
  color: #fff;
  font-family: inherit;
  font-size: 1.05rem;
  cursor: pointer;
}

.voca-mode:disabled {
  opacity: 0.4;
}

.voca-mode.ghost {
  background: rgba(255, 255, 255, 0.7);
  color: #b9557d;
  border: 1.5px solid #f0a8c0;
}

.voca-progress {
  text-align: center;
  font-size: 0.9rem;
  color: #c98ba3;
  margin: 6px 0 12px;
}

.voca-card {
  position: relative;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 18px;
  padding: 26px 18px;
  text-align: center;
  box-shadow: 0 4px 18px rgba(233, 79, 124, 0.08);
}

.voca-fail-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ffdce3;
  color: #c22e55;
  font-size: 0.78rem;
}

.voca-word {
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  color: #b9557d;
  word-break: break-word;
}

.voca-hint {
  margin-top: 12px;
  font-size: 1rem;
  line-height: 1.5;
  color: #6b2b41;
  word-break: keep-all;
}

.voca-hint-btn {
  margin-top: 14px;
  border: 1.5px solid #f0a8c0;
  border-radius: 999px;
  padding: 6px 16px;
  background: none;
  color: #b9557d;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.voca-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.voca-option {
  border: none;
  border-radius: 14px;
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.8);
  color: #6b2b41;
  font-family: inherit;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  word-break: keep-all;
}

.voca-option.correct {
  background: #d3f2dd;
  color: #1d7a43;
}

.voca-option.wrong {
  background: #ffdce3;
  color: #c22e55;
}

.voca-feedback {
  text-align: center;
  margin-top: 14px;
  min-height: 1.4em;
  color: #b9557d;
}

.voca-next {
  display: block;
  margin: 10px auto 0;
  border: none;
  border-radius: 999px;
  padding: 11px 30px;
  background: #ff5a86;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

/* 자리는 유지한 채 숨긴다 (답 고르기 전의 다음 문제 버튼) */
.voca-next.hold {
  visibility: hidden;
}

.voca-result {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.voca-score {
  font-size: 1.9rem;
  color: #b9557d;
}

.voca-wrong-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.voca-wrong-list li {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 12px;
  padding: 10px 14px;
  text-align: left;
  font-size: 0.95rem;
}

.voca-book-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.voca-book {
  border: none;
  border-radius: 18px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.8);
  color: #6b2b41;
  font-family: inherit;
  font-size: 1.02rem;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(233, 79, 124, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.voca-book .book-title {
  display: block;
}

.voca-book .book-meta {
  display: block;
  font-size: 0.82rem;
  color: #c98ba3;
  margin-top: 4px;
}

.voca-book .chevron {
  color: #b9557d;
  font-size: 1.1rem;
}

.voca-units {
  margin-top: 24px;
}

.voca-units-title {
  text-align: center;
  font-size: 1.6rem;
  color: #b9557d;
  margin-bottom: 4px;
}

.voca-units-sub {
  text-align: center;
  font-size: 0.88rem;
  color: #c98ba3;
  margin-bottom: 18px;
}

.book-random {
  display: block;
  width: 100%;
  margin: 14px 0 20px;
}

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

.unit-btn {
  border: none;
  border-radius: 14px;
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.8);
  color: #b9557d;
  font-family: inherit;
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.unit-btn small {
  font-size: 0.68rem;
  color: #c98ba3;
}

.unit-back {
  display: block;
  width: 100%;
  margin-top: 22px;
}

.voca-scope {
  display: inline-block;
  background: #ffdce3;
  color: #c22e55;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.78rem;
  margin-right: 6px;
}

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

@keyframes beat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.18); }
  40% { transform: scale(1); }
  60% { transform: scale(1.12); }
}

@keyframes fadeInOut {
  0%, 100% { opacity: 0; }
  50% { opacity: 0.9; }
}

/* ── 하고 싶은 것 페이지 ── */
.page-todo {
  overflow-y: auto;
}

.todo {
  display: block;
  height: auto;
  min-height: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding:
    calc(20px + env(safe-area-inset-top))
    calc(20px + env(safe-area-inset-right))
    calc(20px + var(--tabbar-h) + env(safe-area-inset-bottom))
    calc(20px + env(safe-area-inset-left));
  pointer-events: auto;
}

/* 전역 section 규칙이 가운데 정렬이라 목록에서는 되돌린다 */
.todo section {
  text-align: left;
}

.todo-status {
  margin: 14px 4px 6px;
  font-size: 0.9rem;
  color: #c98ba3;
}

.todo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.todo-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255, 255, 255, 0.62);
  border-radius: 12px;
  padding: 11px 12px;
}

.todo-row.done {
  background: rgba(255, 255, 255, 0.32);
}

.todo-tick {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  padding: 0;
  border: 1.7px solid #f0a2bf;
  border-radius: 50%;
  background: none;
  color: #fff;
  font-size: 0.8rem;
  line-height: 19px;
  cursor: pointer;
}

.todo-row.done .todo-tick {
  background: #ff7ba8;
  border-color: #ff7ba8;
}

.todo-row.done .todo-tick::after {
  content: "✓";
}

.todo-text {
  line-height: 1.35;
  word-break: break-word;
}

.todo-row.done .todo-text {
  text-decoration: line-through;
  color: #c295a6;
}

.todo-meta {
  font-size: 0.78rem;
  color: #c58fa5;
  margin-top: 3px;
}

.todo-meta.warn {
  color: #c2564f;
}

.todo-memory {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 13px 14px;
  border: none;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  font-family: inherit;
  color: #6b2b41;
  text-align: left;
  cursor: pointer;
}

/* display를 지정하면 hidden 속성이 무시되므로 따로 되돌린다 */
.todo-memory[hidden] {
  display: none;
}

.memory-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.95rem;
}

.memory-head em {
  font-style: normal;
  color: #c58fa5;
  font-size: 0.85rem;
}

.memory-go {
  margin-left: auto;
  color: #c58fa5;
}

.memory-peek {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 9px;
}

.memory-peek li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
  color: #b98da0;
}

.memory-peek li span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-add {
  position: sticky;
  bottom: env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 241, 246, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.todo-add-row {
  display: flex;
  gap: 8px;
}

#todoText {
  flex: 1;
  min-width: 0;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  padding: 12px;
  font-family: inherit;
  font-size: 1rem;
  color: #6b2b41;
  outline: none;
}

#todoSubmit {
  flex: none;
  width: 46px;
  border: none;
  border-radius: 12px;
  background: #ff5a86;
  color: #fff;
  font-family: inherit;
  font-size: 1.3rem;
  cursor: pointer;
}

.todo-done-title {
  text-align: center;
  font-size: 1.3rem;
  color: #b9557d;
  margin-bottom: 14px;
}

.todo-back {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 11px;
  border: 1.5px solid #f0a8c0;
  border-radius: 999px;
  background: none;
  font-family: inherit;
  font-size: 1rem;
  color: #b9557d;
  cursor: pointer;
}

/* ── 달력 페이지 ── */
.page-cal {
  overflow-y: auto;
}

.cal {
  display: block;
  height: auto;
  min-height: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding:
    calc(12px + env(safe-area-inset-top))
    calc(10px + env(safe-area-inset-right))
    calc(16px + var(--tabbar-h) + env(safe-area-inset-bottom))
    calc(10px + env(safe-area-inset-left));
  pointer-events: auto;
}

/* 사진과 색 태그가 많아서 분홍 배경 위에 그대로 두면 서로 싸운다. 흰 카드에 올린다 */
.cal-card {
  position: relative; /* .cal-flash 가 카드 기준으로 뜬다 */
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 140, 175, 0.22);
  border-radius: 20px;
  box-shadow: 0 4px 16px -8px rgba(180, 80, 120, 0.28);
  overflow: hidden;
}

.cal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 13px 9px;
}

/* « ‹ 2026년 9월 › » 를 한 덩어리로 둔다. 겹화살표는 1년씩 건너뛴다 */
.cal-nav {
  display: flex;
  align-items: center;
  gap: 1px;
}

.cal-mv {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 1.1rem;
  color: #c9a0b4;
  cursor: pointer;
  padding: 2px 5px;
}

.cal-mon {
  font-size: 0.95rem;
  color: #3f3438;
  padding: 0 3px;
  white-space: nowrap;
}

/* 이번 달에서는 눌러도 달라질 게 없으니 흐리게 두고 막는다 */
.cal-today {
  margin-left: auto;
  border: 1.3px solid #ffc2d5;
  border-radius: 999px;
  background: #fff;
  font-family: inherit;
  font-size: 0.75rem;
  color: #c2456f;
  padding: 4px 11px;
  cursor: pointer;
  transition: opacity 0.18s;
}

.cal-today:disabled {
  opacity: 0.32;
  cursor: default;
}

/* 새로고침. 오늘 버튼과 같은 테두리의 동그라미. 읽는 동안에는 막히지만 흐려지지 않고
   화살표가 돈다 — 흐려지면 "누를 수 없음" 으로 읽혀서 받는 중이라는 게 안 보인다 */
.cal-refresh {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1.3px solid #ffc2d5;
  border-radius: 50%;
  background: #fff;
  color: #c2456f;
  padding: 0;
  cursor: pointer;
}

.cal-refresh svg {
  width: 15px;
  height: 15px;
}

.cal-refresh:disabled {
  cursor: default;
}

.cal-refresh[aria-busy="true"] svg {
  animation: calSpin 0.9s linear infinite;
}

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

/* 움직임을 줄인 기기에서는 돌리지 않고 흐리게만 해서 받는 중임을 알린다 */
@media (prefers-reduced-motion: reduce) {
  .cal-refresh[aria-busy="true"] svg { animation: none; }
  .cal-refresh[aria-busy="true"] { opacity: 0.5; }
}

/* "방금 새로 받았어요" 같은 짧은 알림. 격자를 밀어내지 않게 카드 위에 띄운다 */
.cal-flash {
  position: absolute;
  top: 46px;
  left: 50%;
  z-index: 2;
  transform: translate(-50%, -4px);
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(63, 52, 56, 0.86);
  color: #fff;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, transform 0.2s, visibility 0s 0.2s;
}

.cal-flash.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition: opacity 0.2s, transform 0.2s;
}

/* 누가 넣은 일정인지 색으로 구분한다. 눌러서 끄면 그 사람 일정만 숨는다 */
.cal-who {
  display: flex;
  gap: 5px;
  padding: 0 13px 10px;
}

.cal-who button {
  flex: 1;
  border-radius: 999px;
  background: #fff;
  font-family: inherit;
  font-size: 0.78rem;
  padding: 5px 0;
  cursor: pointer;
}

.cal-who button[data-w="희찬"] { border: 1.3px solid #ffc2d5; color: #c2456f; }
.cal-who button[data-w="유주"] { border: 1.3px solid #bcd5f5; color: #4a6fa5; }
.cal-who button[data-w="우리"] { border: 1.3px solid #f2dca8; color: #9a7433; }

.cal-who button[aria-pressed="false"] {
  opacity: 0.34;
}

.cal-dow {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  padding: 0 8px 4px;
}

.cal-dow i {
  font-style: normal;
  font-size: 0.7rem;
  color: #8a7a80;
  text-align: center;
}

.cal-dow i:first-child { color: #e8748f; }
.cal-dow i:last-child { color: #7aa8e0; }

.cal-status {
  font-size: 0.85rem;
  color: #c98ba3;
  text-align: center;
  padding: 18px 12px 22px;
}

.cal-gridwrap {
  padding: 0 8px 10px;
}

/* 1fr 은 "내용보다 좁아지지 않는다" 는 뜻이라, 긴 일정 이름이 있는 요일 칸만 넓어지고
   사진(칸 너비의 정사각형)도 칸마다 크기가 달라졌다. minmax(0, …) 로 일곱 칸을 똑같이 나누고
   넘치는 일정 이름은 .cal-tag 가 … 로 줄인다. 요일 머리줄도 같은 폭이어야 열이 맞는다 */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px 2px;
}

/* 칸 안은 위에서 아래로 날짜 → 일정 → 사진 순서로 쌓인다 */
.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  min-height: 46px;
}

.cal-cell.out {
  pointer-events: none;
}

.cal-d {
  flex: none;
  font-size: 0.72rem;
  color: #3f3438;
  text-align: center;
  line-height: 17px;
  height: 17px;
}

.cal-cell.sun .cal-d { color: #e8748f; }
.cal-cell.sat .cal-d { color: #7aa8e0; }
.cal-cell.out .cal-d { color: #cfc6c9; }

.cal-cell.today .cal-d { color: #fff; }

.cal-cell.today .cal-d span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #2c2427;
}

.cal-tag {
  flex: none;
  font-size: 0.44rem;
  line-height: 1.5;
  border-radius: 3px;
  padding: 1px 2px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-tag.me { background: #ffe3ec; color: #c2456f; }
.cal-tag.you { background: #dde9fb; color: #4a6fa5; }
.cal-tag.us { background: #fdf0d6; color: #8d6a2c; }
.cal-tag.anniv { background: #ffd3e1; color: #c2456f; }

/* 사진은 칸 맨 아래에 정사각형으로 박힌다 */
.cal-photo {
  margin-top: auto;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 240, 246, 0.6);
}

.cal-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── 그 날 시트 ── */
.cal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: rgba(80, 30, 55, 0.25);
}

.cal-backdrop[hidden] { display: none; }

.cal-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  max-height: 88vh;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: rgba(255, 251, 253, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 24px 24px 0 0;
  border-top: 1px solid rgba(255, 140, 175, 0.3);
  box-shadow: 0 -10px 40px -14px rgba(180, 80, 120, 0.4);
  padding: 10px 18px calc(28px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.cal-sheet[hidden] { display: none; }
.cal-sheet.open { transform: translateY(0); }

.cal-grip {
  flex: none;
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 140, 175, 0.5);
  margin: 0 auto 11px;
}

.cal-sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  color: #b9557d;
  margin-bottom: 10px;
}

.cal-sheet-head button {
  margin-left: auto;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 1.1rem;
  color: #d693ac;
  cursor: pointer;
}

.cal-sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* 정사각을 가로폭에 맞추면 아이폰에서 354px을 먹어 일정과 입력칸이 화면 밖으로 밀린다.
   한 변을 화면 높이 기준으로 묶어서 시트가 항상 한 화면에 들어오게 한다. */
/* 사진이 여러 장이라 가로 스크롤에 스냅을 걸어 캐러셀로 쓴다.
   직접 드래그를 구현하는 것보다 관성과 터치 처리가 브라우저 몫이라 안정적이다. */
.cal-carousel {
  display: flex;
  width: 34vh;
  width: 34dvh;
  max-width: 100%;
  margin: 0 auto 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  border-radius: 15px;
  border: 1px solid rgba(255, 140, 175, 0.25);
  scrollbar-width: none;
}

.cal-carousel::-webkit-scrollbar { display: none; }

.cal-slide {
  flex: 0 0 100%;
  aspect-ratio: 1;
  scroll-snap-align: center;
}

.cal-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cal-dots {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin-bottom: 11px;
}

.cal-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 140, 175, 0.45);
}

.cal-dots i.on {
  background: #ff5a86;
}

.cal-sheet-photo {
  border-radius: 15px;
  margin: 0 auto 12px;
}

/* 사진이 있을 때만 정사각형을 다 쓴다. 빈 자리까지 크면 일정과 입력이 화면 밖으로 밀린다 */
.cal-sheet-photo.empty {
  aspect-ratio: auto;
  height: 76px;
  background: rgba(255, 255, 255, 0.6);
  border: 1.5px dashed rgba(255, 140, 175, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  color: #d094ad;
}

.cal-evlist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
}

.cal-evlist li {
  display: flex;
  gap: 9px;
  align-items: center;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 140, 175, 0.2);
  border-radius: 13px;
  padding: 9px 13px;
  font-size: 0.95rem;
}

.cal-evlist li.anniv {
  background: rgba(255, 143, 179, 0.16);
  border-color: rgba(255, 90, 134, 0.3);
  color: #c2456f;
}

/* 아직 시트에 반영 안 된 줄 */
.cal-evlist li.pending { opacity: 0.55; }

.cal-evlist li .who-tag {
  margin-left: auto;
  font-size: 0.75rem;
  color: #d8a3b8;
}

.cal-ev-empty {
  background: none !important;
  border: none !important;
  color: #cf9ab2;
  font-size: 0.88rem;
  padding: 2px 4px !important;
}

.cal-sheet-status {
  font-size: 0.82rem;
  color: #c98ba3;
  margin: 0 4px 8px;
}

.cal-add {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.62);
  border-radius: 16px;
  padding: 13px;
}

.cal-add-row {
  display: flex;
  gap: 8px;
}

.cal-add-row input {
  flex: 1;
  min-width: 0;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
  color: #6b2b41;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.cal-add-row button {
  flex: none;
  width: 42px;
  border: none;
  border-radius: 12px;
  background: #ff5a86;
  color: #fff;
  font-family: inherit;
  font-size: 1.1rem;
  cursor: pointer;
}

.cal-anniv {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: #b9557d;
  cursor: pointer;
}

.cal-anniv input {
  accent-color: #ff5a86;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ── 홈: 가장 가까운 기념일 칩 ── */
.anniv-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 5px 15px;
  border-radius: 999px;
  background: rgba(255, 143, 179, 0.2);
  border: 1px solid rgba(255, 90, 134, 0.3);
  color: #c2456f;
  font-size: clamp(0.8rem, 3.4vw, 0.95rem);
  text-decoration: none;
  pointer-events: auto;
}

.anniv-chip[hidden] { display: none; }

/* 사진 자리를 눌러서 고른다 */
button.cal-sheet-photo {
  width: 34vh;
  width: 34dvh;
  max-width: 100%;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  display: block;
}

/* 사진이 없을 때는 낮은 띠라 가로를 다 써도 된다 */
button.cal-sheet-photo.empty {
  width: 100%;
  display: flex;
}

.cal-photo-bar {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
}

.cal-photo-bar button {
  flex: 1;
  border: 1px solid rgba(255, 140, 175, 0.35);
  background: rgba(255, 255, 255, 0.7);
  color: #b9557d;
  font-family: inherit;
  font-size: 0.8rem;
  border-radius: 11px;
  padding: 7px 0;
  cursor: pointer;
}

.cal-photo-bar button.danger {
  color: #c2456f;
  border-color: rgba(255, 90, 134, 0.35);
}

.cal-ev-del {
  flex: none;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.85rem;
  color: #dba7be;
  cursor: pointer;
  padding: 2px 0 2px 4px;
}

/* ── 잠금 화면 ──
   등록되지 않은(기기 토큰이 없는) 기기에서 페이지 전체를 덮는다. 탭바(4)와 달력 시트(6)보다 위에 둔다 */
.gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  /* 가운데 정렬은 .gate-card 의 margin: auto 로 한다. align-items: center 는 카드가 화면보다
     크면(가로로 눕힌 작은 폰) 위아래가 잘려 스크롤로도 못 닿는다. margin: auto 는 넘치면 위부터 스크롤된다 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding:
    calc(24px + env(safe-area-inset-top))
    calc(24px + env(safe-area-inset-right))
    calc(24px + env(safe-area-inset-bottom))
    calc(24px + env(safe-area-inset-left));
  background: linear-gradient(170deg, #fff5f8 0%, #ffe3ec 45%, #ffd0e0 100%);
}

.gate-card {
  width: 100%;
  max-width: 320px;
  margin: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 22px 24px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 34px rgba(233, 79, 124, 0.16);
  text-align: center;
}

.gate-heart {
  font-size: 34px;
  color: #ff5a86;
  line-height: 1;
}

.gate-card h2 {
  font-size: 20px;
  font-weight: normal;
  color: #6b2b41;
}

.gate-dots {
  display: flex;
  gap: 12px;
  margin: 2px 0 0;
}

.gate-dots i {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid #ff85a8;
  transition: background 0.12s ease;
}

.gate-dots i.on {
  background: #ff5a86;
  border-color: #ff5a86;
}

.gate-dots.shake {
  animation: gate-shake 0.36s ease;
}

@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.gate-msg {
  min-height: 1.4em;
  font-size: 13px;
  color: #a35a74;
}

.gate-pad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 12px 18px;
  margin-top: 4px;
}

.gate-pad button {
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 8px rgba(233, 79, 124, 0.12);
  font: inherit;
  font-size: 24px;
  color: #6b2b41;
  cursor: pointer;
}

.gate-pad button:active {
  background: #ffd0e0;
}

.gate-pad button[data-k="⌫"] {
  background: transparent;
  box-shadow: none;
  font-size: 22px;
}

.gate-pad button.blank {
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .gate-dots.shake { animation: none; }
}

/* 가로로 눕힌 폰처럼 낮은 화면에서는 키를 줄여 스크롤 없이 한 화면에 들어오게 한다 */
@media (max-height: 520px) {
  .gate-card { gap: 8px; padding: 16px 18px; }
  .gate-heart { font-size: 26px; }
  .gate-pad { grid-template-columns: repeat(3, 52px); gap: 8px 16px; margin-top: 0; }
  .gate-pad button { width: 52px; height: 52px; font-size: 20px; }
}
