/* =============================================================
   우리 둘 캘린더 — 스타일 (모바일 퍼스트 · PWA · 다크모드)
   ============================================================= */

:root {
  --bg: #f5f3fb;
  --bg-soft: #efeafd;
  --surface: #ffffff;
  --surface-2: #f8f6ff;
  --text: #1c1a26;
  --muted: #7b7790;
  --line: #e8e3f4;
  --brand: #6c5ce7;
  --brand-soft: #ece8ff;
  --a: #6c5ce7;
  --b: #ff6b81;
  --us: #12b3a4;
  --danger: #e5484d;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 28px rgba(40, 28, 92, 0.08);
  --shadow-strong: 0 18px 48px rgba(40, 28, 92, 0.18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans KR", "Noto Sans SC", system-ui,
    sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14121c;
    --bg-soft: #1b1826;
    --surface: #1e1b29;
    --surface-2: #262234;
    --text: #f2efff;
    --muted: #a09bb6;
    --line: #2f2a40;
    --brand: #8f80ff;
    --brand-soft: #2a2444;
    --a: #9d90ff;
    --b: #ff8296;
    --us: #35c8ba;
    --danger: #ff6b6b;
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    --shadow-strong: 0 18px 48px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

input,
textarea,
select,
button {
  font-family: inherit;
}

.muted {
  color: var(--muted);
}

[hidden] {
  display: none !important;
}

/* ---------------- 화면 공통 ---------------- */

.screen {
  min-height: 100vh;
  min-height: 100dvh;
}

.screen-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.loading-heart {
  font-size: 34px;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.75;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

/* ---------------- 인증 화면 ---------------- */

.screen-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-soft) 0%, var(--bg) 60%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px 22px 22px;
  text-align: center;
}

.auth-logo {
  font-size: 34px;
  line-height: 1;
  margin-bottom: 8px;
}

.auth-title {
  font-size: 22px;
}

.auth-sub {
  margin-top: 6px;
  font-size: 14px;
  min-height: 20px;
}

.role-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 20px 0 16px;
}

.role-btn {
  padding: 12px 8px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.role-btn:active {
  transform: scale(0.98);
}

.role-btn.is-active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}

.auth-form {
  text-align: left;
}

.pin-input {
  letter-spacing: 0.5em;
  font-size: 22px;
  text-align: center;
  padding-left: calc(0.5em + 12px);
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px; /* iOS 확대 방지 */
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

textarea {
  resize: vertical;
  min-height: 76px;
  line-height: 1.5;
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 2px 0 10px;
}

.lang-link {
  margin-top: 14px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------------- 버튼 ---------------- */

.btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, #8f7bff 100%);
  color: #fff;
  box-shadow: 0 8px 20px rgba(108, 92, 231, 0.28);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1.5px solid var(--line);
}

.btn-danger {
  background: rgba(229, 72, 77, 0.1);
  color: var(--danger);
}

.btn[disabled] {
  opacity: 0.55;
  pointer-events: none;
}

.icon-btn {
  border: 0;
  background: var(--surface-2);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
}

.chip {
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}

.chip-ghost {
  background: var(--surface-2);
  color: var(--muted);
}

/* ---------------- 상단 바 ---------------- */

.screen-app {
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: calc(96px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-mark {
  font-size: 22px;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  font-size: 16.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text p {
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.main {
  padding: 14px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------------- 디데이 배너 ---------------- */

.dday-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #6c5ce7 0%, #a06bff 55%, #ff7a94 100%);
  color: #fff;
  box-shadow: 0 14px 32px rgba(108, 92, 231, 0.28);
}

.dday-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dday-caption {
  font-size: 11.5px;
  font-weight: 600;
  opacity: 0.85;
  letter-spacing: 0.04em;
}

.dday-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.dday-right {
  text-align: right;
  min-width: 0;
}

.dday-label {
  font-size: 14px;
  font-weight: 650;
}

.dday-range {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  margin-top: 2px;
}

/* ---------------- 캘린더 ---------------- */

.calendar-card {
  padding: 14px 12px 10px;
}

.cal-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 10px;
}

.month-label {
  flex: 1;
  text-align: center;
  font-size: 16px;
}

.nav-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

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

.weekdays span {
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.weekdays span.is-sun {
  color: var(--b);
}

.weekdays span.is-sat {
  color: var(--brand);
}

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

.day-cell {
  position: relative;
  border: 0;
  background: none;
  border-radius: 12px;
  padding: 6px 0 5px;
  min-height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}

.day-cell:active {
  background: var(--surface-2);
}

.day-num {
  font-size: 14px;
  font-weight: 600;
  width: 28px;
  height: 28px;
  line-height: 28px;
  border-radius: 50%;
  text-align: center;
}

.day-cell.is-outside .day-num {
  color: var(--muted);
  opacity: 0.5;
}

.day-cell.is-sun .day-num {
  color: var(--b);
}

.day-cell.is-sat .day-num {
  color: var(--brand);
}

.day-cell.is-today .day-num {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 750;
}

.day-cell.is-selected {
  background: var(--brand-soft);
}

.day-cell.is-selected .day-num {
  background: var(--brand);
  color: #fff;
}

.dots {
  display: flex;
  gap: 3px;
  height: 5px;
  align-items: center;
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
}

.dot-a {
  background: var(--a);
}

.dot-b {
  background: var(--b);
}

.dot-us {
  background: var(--us);
}

.legend {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 8px 0 2px;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------------- 하단 일정 리스트 ---------------- */

.day-card {
  padding: 14px 14px 8px;
}

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.day-head h3 {
  font-size: 15.5px;
}

.day-head span {
  font-size: 12px;
}

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-item {
  display: flex;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.1s;
}

.event-item:active {
  transform: scale(0.994);
}

.event-bar {
  width: 4px;
  border-radius: 999px;
  flex-shrink: 0;
  background: var(--us);
}

.event-item.kind-a .event-bar {
  background: var(--a);
}

.event-item.kind-b .event-bar {
  background: var(--b);
}

.event-item.kind-us .event-bar {
  background: var(--us);
}

.event-main {
  min-width: 0;
  flex: 1;
}

.event-title {
  font-size: 14.5px;
  font-weight: 650;
  word-break: break-word;
}

.event-alt {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 1px;
  word-break: break-word;
}

.event-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.event-memo {
  font-size: 12.5px;
  color: var(--text);
  opacity: 0.78;
  margin-top: 5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.event-kind-tag {
  align-self: flex-start;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  white-space: nowrap;
}

.empty {
  padding: 14px 4px 18px;
  text-align: center;
  font-size: 13px;
}

/* ---------------- FAB ---------------- */

.fab {
  position: fixed;
  right: max(18px, calc(50% - 280px + 18px));
  bottom: calc(20px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, var(--brand) 0%, #9a7bff 100%);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  box-shadow: 0 12px 26px rgba(108, 92, 231, 0.42);
  cursor: pointer;
  z-index: 30;
}

.fab:active {
  transform: scale(0.95);
}

/* ---------------- 모달 ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 14, 34, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-strong);
  padding-bottom: calc(14px + var(--safe-bottom));
  animation: sheet-up 0.22s ease-out;
}

@keyframes sheet-up {
  from {
    transform: translateY(16px);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sheet-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}

.sheet-head h2 {
  font-size: 17px;
}

.sheet-body {
  padding: 14px 16px 4px;
}

.sheet-body .field {
  margin-bottom: 12px;
}

.section-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.04em;
  margin: 16px 0 8px;
}

.section-title:first-child {
  margin-top: 2px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.datetime-row {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 4px;
}

.seg-btn {
  border: 0;
  background: transparent;
  padding: 9px 4px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seg-btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(40, 28, 92, 0.12);
}

.seg-btn[data-kind="a"].is-active {
  color: var(--a);
}

.seg-btn[data-kind="b"].is-active {
  color: var(--b);
}

.seg-btn[data-kind="us"].is-active {
  color: var(--us);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 10px;
}

.switch {
  width: 46px;
  height: 27px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--line);
  border-radius: 999px;
  position: relative;
  outline: none;
  cursor: pointer;
  transition: background 0.18s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s;
}

.switch:checked {
  background: var(--brand);
}

.switch:checked::after {
  transform: translateX(19px);
}

.hint {
  font-size: 11.5px;
  line-height: 1.5;
  margin: 2px 0 10px;
}

.sheet-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 0 6px;
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

.sheet-actions .btn {
  flex: 0 0 auto;
}

.sheet-actions .btn-primary {
  flex: 1;
}

/* ---------------- 토스트 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(28, 26, 38, 0.92);
  color: #fff;
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 200;
  max-width: 82vw;
  text-align: center;
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 6px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ---------------- 큰 화면 ---------------- */

@media (min-width: 620px) {
  .main {
    padding: 18px 20px 0;
  }
  .day-cell {
    min-height: 54px;
  }
  .day-num {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
