@import url('https://fonts.googleapis.com/css2?family=Pretendard:wght@300;400;500;600;700;800&display=swap');

/* ===== RESET & BASE (2D Flat Theme) ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  /* Clean 2D Colors (Toss Inspired) */
  --bg: #FFFFFF;
  --surface: #F2F4F6;
  --surface2: #E5E8EB;
  --surface3: #D1D6DB;
  --border: #F2F4F6;
  --border-dark: #E5E8EB;

  --text-primary: #191F28;
  --text-secondary: #4E5968;
  --text-tertiary: #8B95A1;

  --accent: #3182F6;
  --accent-light: #E8F3FF;
  --danger: #F04452;
  --danger-light: #FEECEF;
  --success: #00BA54;
  --warn: #FFAD13;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  /* Minimal shadows for 2D look */
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);

  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

html,
body {
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
  background: var(--bg);
}

body.locked {
  overflow: hidden;
  height: 100dvh;
  position: fixed;
  width: 100%;
  left: 0;
}

/* Modern body lock fallback using :has() */
body:has(.popup-overlay.open) {
  overflow: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 0;
}

/* ===== PAGE TRANSITIONS ===== */
.page-wrapper {
  min-height: 100dvh;
  opacity: 0;
  animation: pageIn 0.4s ease forwards;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== NOTIFICATION (Top-Down) ===== */
.notif-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  background: white;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
  pointer-events: none;
  opacity: 0;
}

.notif-banner.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== BUTTON (2D Flat) ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.btn:active {
  transform: scale(0.96);
  opacity: 0.8;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text-secondary);
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-primary);
}

/* ===== INPUT (Flat) ===== */
.input {
  width: 100%;
  padding: 16px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
  position: relative;
  z-index: 1;
}

.input:focus {
  background: white;
  border-color: var(--accent);
}

.input.error {
  border-color: var(--danger);
  background: var(--danger-light);
}

.error-msg {
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
  display: none;
  animation: errorIn 0.3s ease forwards;
}

@keyframes errorIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== RESPONSIVE POPUP (Sheet on Mobile, Modal on Desktop) ===== */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.popup-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

.popup-sheet {
  position: fixed;
  z-index: 3000;
  background: white;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, visibility 0.4s;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  will-change: transform;
}

.popup-sheet.open {
  pointer-events: all;
  visibility: visible;
}

/* Calendar month slide */
.cal-grid {
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.cal-grid.slide-left {
  animation: slideLeft 0.3s ease forwards;
}

.cal-grid.slide-right {
  animation: slideRight 0.3s ease forwards;
}

@keyframes slideLeft {
  from {
    transform: translateX(20px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideRight {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Mobile: Bottom Sheet */
@media (max-width: 600px) {
  .popup-sheet {
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 8px 24px 32px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    max-height: 92dvh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    will-change: transform;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
  }

  .popup-sheet.open {
    transform: translateY(0);
    visibility: visible;
    pointer-events: all;
  }
}

/* Desktop: Centered Popup */
@media (min-width: 601px) {
  .popup-sheet {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -45%) scale(0.95);
    width: 90%;
    max-width: 400px;
    max-height: 90dvh;
    border-radius: var(--radius-lg);
    padding: 32px;
    opacity: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
  }

  .popup-sheet.open {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    visibility: visible;
    pointer-events: all;
  }

  .popup-handle {
    display: none;
  }
}

.popup-handle {
  width: 36px;
  height: 4px;
  background: var(--surface2);
  border-radius: 99px;
  margin: 4px auto 16px;
  flex-shrink: 0;
  cursor: grab;
}

.popup-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text-primary);
}

/* ===== CALENDAR (Clean 2D) ===== */
.calendar-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 10px;
  position: relative;
  z-index: 1;
}

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

.cal-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
  z-index: 1;
}

.cal-btn:hover {
  background: var(--surface2);
}

.cal-btn img {
  width: 20px;
  height: 20px;
}

.cal-btn.next img {
  transform: scaleX(-1);
}

.cal-month {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

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

.cal-day-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-align: center;
  padding-bottom: 12px;
}

.cal-date {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-primary);
}

.cal-date:hover {
  background: var(--surface2);
}

.cal-date.today {
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-light);
}

.cal-date.selected {
  background: var(--accent) !important;
  color: white !important;
  font-weight: 700;
}

.cal-date.disabled {
  opacity: 0.15;
  pointer-events: none;
}

.time-picker {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--surface2);
  position: relative;
  z-index: 1;
}

.time-col {
  flex: 1;
}

.time-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  display: block;
}

.time-select {
  width: 100%;
  padding: 12px;
  background: var(--surface2);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  appearance: none;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

/* ===== BANNER (Flat 2D) ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  border: 1px solid transparent;
  z-index: 1;
  /* Ensure relative positioning for z-index */
}

.card.cat-blue {
  --cat: #3182F6;
}

.card.cat-purple {
  --cat: #8B5CF6;
}

.card.cat-pink {
  --cat: #F43F5E;
}

.card.cat-orange {
  --cat: #FF9500;
}

.card.cat-green {
  --cat: #00BA54;
}

.card.cat-red {
  --cat: #F04452;
}

.card.cat-teal {
  --cat: #00C7BE;
}

.banner {
  background: linear-gradient(135deg, var(--cat, #3182F6), color-mix(in srgb, var(--cat, #3182F6) 70%, white));
  color: white;
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  transition: all 0.2s;
}

.banner-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 12px;
  line-height: 1.3;
}

.banner-dday {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}

.banner-day-unit {
  font-size: 16px;
  font-weight: 600;
  margin-left: 4px;
  opacity: 0.9;
}

/* Slot Machine */
.slot-container {
  display: inline-flex;
  gap: 0;
}

.slot-digit {
  overflow: hidden;
  line-height: 1.2;
}

.slot-inner {
  animation: slotScroll 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slot-num {
  display: block;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@keyframes slotScroll {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(-100%);
  }
}

/* ===== INFO SECTIONS ===== */
.info-section {
  margin: 0 20px 32px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 18px 0;
  border-bottom: 1px solid var(--surface2);
  align-items: center;
}

.info-row:last-child {
  border-bottom: none;
}

.info-key {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.info-val {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-val img {
  width: 16px;
  height: 16px;
}

/* ===== ACTION SECTION ===== */
.action-section {
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-full {
  width: 100%;
  height: 56px;
  border-radius: var(--radius);
}

/* ===== FOOTER ===== */
.footer {
  margin-top: 60px;
  padding: 40px 20px 20px;
  text-align: center;
  color: var(--text-tertiary);
  border-top: 1px solid var(--surface2);
}

.footer-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 12px;
}

.footer-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.footer-logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.footer-name {
  font-weight: 700;
  color: var(--text-primary);
}

.footer-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: color 0.2s;
}

.footer-link:hover {
  color: color-mix(in srgb, var(--accent) 80%, black);
}

/* ===== FULLSCREEN OVERLAY ===== */
.fs-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 2500;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.fs-overlay.open {
  display: flex;
  opacity: 1;
  visibility: visible;
}

.fs-content {
  text-align: center;
  color: white;
}

.fs-dday {
  font-size: clamp(60px, 20vw, 200px);
  font-weight: 800;
  line-height: 1;
  margin-bottom: 24px;
  letter-spacing: -2px;
}

.fs-hms {
  display: flex;
  gap: clamp(20px, 10vw, 60px);
  justify-content: center;
  font-size: clamp(24px, 8vw, 80px);
}

.fs-hms-item {
  text-align: center;
}

.fs-hms-num {
  display: block;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: 8px;
}

.fs-hms-label {
  font-size: clamp(12px, 3vw, 20px);
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
}

.exit-fs-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s, opacity 0.3s ease-in-out;
  z-index: 3001;
  opacity: 1;
}

.exit-fs-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.exit-fs-btn.hide {
  opacity: 0;
  pointer-events: none;
}

.exit-fs-btn img {
  width: 24px;
  height: 24px;
}

body.fs-active {
  overflow: hidden;
}

/* ===== OVERFLOW MENU ===== */
.overflow-menu {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 8px 24px 32px;
  z-index: 3002;
  visibility: hidden;
  opacity: 0;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
  pointer-events: none;
}

.overflow-menu.open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

@media (min-width: 601px) {
  .overflow-menu {
    position: absolute;
    bottom: auto;
    left: auto;
    right: 0;
    top: 100%;
    background: white;
    border-radius: var(--radius);
    padding: 4px 0;
    margin-top: 8px;
    min-width: 120px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-8px) scale(0.9);
    visibility: hidden;
    opacity: 0;
  }

  .overflow-menu.open {
    transform: translateY(0) scale(1);
    visibility: visible;
    opacity: 1;
  }
}

.overflow-item {
  padding: 12px 20px;
  font-size: 15px;
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.overflow-item:hover {
  background: var(--surface);
}

.overflow-item:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.overflow-item:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ===== HERO SECTION ===== */
.hero {
  margin: 0 20px 24px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 40px 30px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: relative;
}

.hero-category {
  font-size: 13px;
  font-weight: 700;
  color: var(--cat);
  margin-bottom: 12px;
}

.hero-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 24px;
  line-height: 1.3;
}

.hero-dday-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 12px;
}

.hero-prefix {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-secondary);
}

.hero-num {
  font-size: 72px;
  font-weight: 800;
  color: var(--cat);
  letter-spacing: -3px;
}

.hero-hms {
  display: flex;
  gap: 16px;
}

.hero-hms-item {
  text-align: left;
}

.hero-hms-num {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
}

.hero-hms-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 2px;
}

.btn-max {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--surface2);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-max:hover {
  background: var(--border-dark);
}

.btn-max img {
  width: 20px;
  height: 20px;
  opacity: 0.6;
}

/* ===== NAV ===== */
.nav {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-back {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-back img {
  width: 24px;
  height: 24px;
}

.nav-title {
  font-size: 18px;
  font-weight: 700;
}

/* ===== DRAG SUPPORT ===== */
.popup-sheet.dragging {
  transition: none;
}
