@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');

/* ══════════════ Variables ══════════════ */
:root {
  --bg: #f4f3ef;
  --bg-warm: #eae8e3;
  --surface: #ffffff;
  --text: #1c1c1e;
  --text2: #48484a;
  --text3: #8e8e93;
  --text4: #c7c7cc;
  --border: #e5e5ea;
  --hover: rgba(0,0,0,.03);
  --pri: #2655d4;
  --pri-light: #eef2ff;
  --pri-dark: #1e44ab;
  --pri-subtle: rgba(38,85,212,.08);
  --ok: #34c759;
  --ok-light: #eafbef;
  --warn: #ff9500;
  --warn-light: #fff6e8;
  --err: #ff3b30;
  --err-light: #fff0ef;
  --morning: #ff9f0a;
  --daytime: #007aff;
  --evening: #af52de;
  --night: #636366;
  --r: 16px;
  --r-sm: 12px;
  --r-xs: 8px;
  --sh: 0 1px 2px rgba(0,0,0,.03), 0 2px 6px rgba(0,0,0,.02);
  --sh-md: 0 2px 8px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.03);
  --ease: cubic-bezier(.22,1,.36,1);
}

/* ══════════════ Reset ══════════════ */
*,*::before,*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Pretendard Variable','Pretendard',-apple-system,BlinkMacSystemFont,system-ui,sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  letter-spacing: -0.01em;
  overflow-x: hidden;
}
html { overflow-x: hidden; width: 100vw; }

/* ══════════════ Layout ══════════════ */
.layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.sidebar, .sidebar-right { display: none; }

.app {
  width: 100%;
  max-width: 540px;
  padding: 0 0 100px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ══════════════ Top Bar ══════════════ */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(244,243,239,.8);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.top-bar h1 {
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.03em;
}

/* ══════════════ Bottom Nav ══════════════ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid rgba(0,0,0,.06);
  display: flex;
  z-index: 50;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom,0));
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 6px;
  font-size: 10px;
  font-weight: 550;
  color: var(--text3);
  border: none;
  background: none;
  cursor: pointer;
  transition: color .2s var(--ease);
  font-family: inherit;
  border-radius: var(--r-xs);
}
.nav-item.active { color: var(--pri); }
.nav-item svg { width: 22px; height: 22px; }

.desk-nav {
  display: none;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.desk-nav .nav-item {
  flex: none;
  flex-direction: row;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}
.desk-nav .nav-item.active {
  background: var(--pri-subtle);
  color: var(--pri);
}
.desk-nav .nav-item svg { width: 16px; height: 16px; }

/* ══════════════ Date Selector ══════════════ */
.date-sel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 24px 16px;
}
.date-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  transition: all .2s var(--ease);
  box-shadow: var(--sh);
}
.date-btn:hover { border-color: var(--text4); }
.date-btn:active { transform: scale(.93); }
.date-txt {
  font-size: 17px;
  font-weight: 650;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--r-xs);
  letter-spacing: -0.02em;
  transition: background .15s;
}
.date-txt:hover { background: var(--hover); }
.badge-today {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--pri);
  background: var(--pri-light);
  padding: 2px 10px;
  border-radius: 6px;
  margin-left: 8px;
}

/* ══════════════ Views ══════════════ */
.view { display: none; overflow-x: hidden; }
.view.active { display: block; }
.sec { padding: 0 20px; }

/* ══════════════ Progress Card ══════════════ */
.progress-card {
  background: var(--surface);
  border-radius: var(--r);
  padding: 22px 24px;
  box-shadow: var(--sh);
  margin-bottom: 20px;
  border: 1px solid rgba(0,0,0,.04);
}
.prog-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}
.prog-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.prog-count {
  font-size: 15px;
  font-weight: 700;
  color: var(--pri);
}
.prog-count span { color: var(--text4); font-weight: 500; }
.prog-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-warm);
  border-radius: 3px;
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  background: linear-gradient(90deg,var(--pri),#5b8dee);
  border-radius: 3px;
  transition: width .6s var(--ease);
}
.prog-pct {
  margin-top: 10px;
  text-align: right;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* ══════════════ Buttons ══════════════ */
.btn-add {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--pri);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(38,85,212,.25);
  transition: all .2s var(--ease);
}
.btn-add:hover {
  box-shadow: 0 4px 16px rgba(38,85,212,.3);
  transform: translateY(-1px);
}
.btn-add:active { transform: scale(.97) translateY(0); }

.btn-sm {
  padding: 8px 16px;
  border: none;
  border-radius: var(--r-xs);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.btn-edit { background: var(--bg); color: var(--text2); }
.btn-edit:hover { background: var(--bg-warm); }
.btn-del { background: var(--err-light); color: var(--err); }

/* ══════════════ Empty & Toast ══════════════ */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text3);
  font-size: 14px;
  font-weight: 450;
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 550;
  opacity: 0;
  transition: all .3s var(--ease);
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ══════════════ Responsive: Desktop ══════════════ */
@media (min-width: 768px) {
  .bottom-nav { display: none; }
  .desk-nav { display: flex; }
  .app { padding-bottom: 40px; }
}

/* Mobile memo FAB */
.fab-memo {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  right: 20px;
  bottom: calc(72px + env(safe-area-inset-bottom,0));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--pri);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(38,85,212,.35);
  z-index: 49;
  transition: all .2s var(--ease);
}
.fab-memo:active { transform: scale(.9); }

/* Close button inside sidebar-right (mobile) */
.sbr-close {
  display: none;
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text2);
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.sbr-close:hover { background: var(--bg-warm); color: var(--text); }
.sidebar-right.mobile-show .sbr-close { display: flex; }

/* Mobile: sidebar-right as full-screen overlay */
.sidebar-right.mobile-show {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  background: var(--bg);
  padding-bottom: calc(62px + env(safe-area-inset-bottom,0));
  width: 100%;
  min-width: 100%;
}

/* Desktop: show both sidebars */
@media (min-width: 1100px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    width: 300px;
    min-width: 300px;
    height: 100vh;
    position: sticky;
    top: 0;
    border-right: 1px solid var(--border);
    background: var(--surface);
    overflow-y: auto;
  }
  .sidebar-right {
    display: flex;
    flex-direction: column;
    width: 380px;
    min-width: 380px;
    height: 100vh;
    position: sticky;
    top: 0;
    border-left: 1px solid var(--border);
    background: var(--surface);
    overflow-y: auto;
  }
  .fab-memo { display: none; }
  .sidebar-right.mobile-show { position: sticky; padding-bottom: 0; z-index: auto; }
  .main-area { flex: 1; min-width: 0; align-items: center; }
  .app { max-width: 640px; }
  .top-bar h1 { display: none; }
}

/* ══════════════ Scrollbar ══════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text4); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }
