/* 토스 스타일 토큰 */
:root {
  --blue: #3182f6; --blue-dark: #1b64da; --blue-light: #e8f3ff;
  --gray-50: #f9fafb; --gray-100: #f2f4f6; --gray-200: #e5e8eb;
  --gray-300: #d1d6db; --gray-400: #b0b8c1; --gray-500: #8b95a1;
  --gray-600: #6b7684; --gray-700: #4e5968; --gray-800: #333d4b; --gray-900: #191f28;
  --green: #04b014; --red: #f04452;
  --radius-lg: 20px; --radius-sm: 12px;
  --shadow-card: 0 1px 3px rgba(0,23,51,.04), 0 6px 16px rgba(0,23,51,.06);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont,
    'Apple SD Gothic Neo', 'Segoe UI', sans-serif;
  background: var(--gray-100); color: var(--gray-900);
  line-height: 1.5; min-height: 100vh; -webkit-font-smoothing: antialiased;
}
.container { max-width: 720px; margin: 0 auto; padding: 40px 16px 80px; }

/* 헤더 */
.header { margin-bottom: 20px; padding: 0 4px; }
.header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.header-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.me-chip {
  border: none; background: var(--blue-light); color: var(--blue);
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  transition: background .15s ease;
}
.me-chip:hover { background: #d9ebff; }
.me-chip.is-me { background: var(--blue); color: #fff; }

.week-nav { display: flex; align-items: center; justify-content: center; gap: 10px; }
.nav-btn {
  width: 36px; height: 36px; border: none; border-radius: 50%;
  background: #fff; color: var(--gray-600); font-size: 20px; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow-card); transition: all .15s ease;
  display: flex; align-items: center; justify-content: center; font-family: inherit;
}
.nav-btn:hover { color: var(--blue); }
.week-label-wrap { text-align: center; min-width: 180px; }
.week-label { font-size: 16px; font-weight: 700; color: var(--gray-800); }
.today-btn {
  border: none; background: transparent; color: var(--blue);
  font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  padding: 2px 8px;
}
.header-hint { text-align: center; margin-top: 10px; font-size: 14px; font-weight: 600; color: var(--blue); min-height: 21px; }

/* 그리드 카드 */
.grid-card {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); overflow: hidden;
}
.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid { width: 100%; border-collapse: collapse; min-width: 560px; }
.grid th, .grid td { text-align: center; border-bottom: 1px solid var(--gray-100); }
.grid tr:last-child td { border-bottom: none; }

.grid thead th {
  padding: 14px 6px 10px; font-size: 13px; font-weight: 600; color: var(--gray-500);
  background: var(--gray-50);
}
.grid thead th .day-num { display: block; font-size: 15px; font-weight: 700; color: var(--gray-800); margin-top: 1px; }
.grid thead th.today { color: var(--blue); }
.grid thead th.today .day-num { color: var(--blue); }
.grid thead th.today::after { content: '오늘'; display: block; font-size: 10px; color: var(--blue); }

.grid .name-col {
  text-align: left; padding: 12px 8px 12px 16px; font-size: 14px; font-weight: 600;
  color: var(--gray-800); white-space: nowrap; position: sticky; left: 0; background: #fff;
}
.grid .name-col .me-badge {
  display: inline-block; margin-left: 5px; font-size: 10px; font-weight: 700;
  color: var(--blue); background: var(--blue-light); padding: 1px 6px; border-radius: 999px;
  vertical-align: 1px;
}

.cell {
  padding: 6px 4px; cursor: default; min-width: 76px;
}
.cell-inner {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; border-radius: 10px; padding: 7px 4px; min-height: 52px;
  transition: background .15s ease, box-shadow .15s ease;
}
.cell.mine .cell-inner { cursor: pointer; }
.cell.mine .cell-inner:hover { background: var(--blue-light); }
.cell.mine.empty .cell-inner { box-shadow: inset 0 0 0 1.5px dashed var(--gray-200); }
.cell.mine.empty .cell-inner::after { content: '+'; color: var(--gray-300); font-size: 18px; font-weight: 600; }
.cell.today-col .cell-inner { background: var(--gray-50); }
.cell.mine.today-col .cell-inner:hover { background: var(--blue-light); }

.cell .st-emoji { font-size: 17px; line-height: 1.2; }
.cell .st-label { font-size: 11px; font-weight: 600; color: var(--gray-600); }
.cell .st-memo {
  font-size: 10px; color: var(--gray-400); max-width: 72px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cell.st-available .st-label { color: var(--blue); }
.cell.st-available .cell-inner { background: var(--blue-light); }
.cell.st-vacation .cell-inner { background: #fff7e6; }
.cell.st-busy .cell-inner { background: var(--gray-100); }

/* 집계 행 */
.grid tfoot td { background: var(--gray-50); padding: 10px 4px 12px; }
.grid tfoot .name-col { background: var(--gray-50); font-size: 12px; color: var(--gray-500); font-weight: 600; }
.count { font-size: 14px; font-weight: 700; color: var(--gray-600); }
.count.best { color: var(--blue); }
.count.best::after { content: ' 👍'; font-size: 12px; }
.count-sub { display: block; font-size: 10px; color: var(--gray-400); font-weight: 500; }

.legend {
  margin-top: 14px; text-align: center; font-size: 12.5px; color: var(--gray-500); line-height: 1.7;
}

/* 모달 */
.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(25,31,40,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  animation: fade-in .18s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: var(--radius-lg); padding: 24px;
  width: 100%; max-width: 340px; box-shadow: 0 12px 40px rgba(0,23,51,.18);
  animation: pop-in .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop-in { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.modal-desc { font-size: 13.5px; color: var(--gray-500); margin-bottom: 16px; }

.name-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.name-options button {
  border: none; background: var(--gray-100); color: var(--gray-800);
  font-family: inherit; font-size: 15px; font-weight: 600;
  padding: 13px 8px; border-radius: var(--radius-sm); cursor: pointer;
  transition: all .15s ease;
}
.name-options button:hover { background: var(--blue-light); color: var(--blue); }

.status-options { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 12px; }
.status-options button {
  display: flex; align-items: center; gap: 10px;
  border: none; background: var(--gray-50); color: var(--gray-800);
  font-family: inherit; font-size: 15px; font-weight: 600;
  padding: 12px 14px; border-radius: var(--radius-sm); cursor: pointer;
  transition: all .15s ease; text-align: left;
}
.status-options button:hover { background: var(--blue-light); }
.status-options button.selected { background: var(--blue); color: #fff; }

.memo-input {
  width: 100%; border: 1.5px solid var(--gray-200); outline: none;
  font-family: inherit; font-size: 14px; padding: 11px 13px;
  border-radius: var(--radius-sm); color: var(--gray-900);
  transition: border-color .15s ease;
}
.memo-input:focus { border-color: var(--blue); }
.memo-input::placeholder { color: var(--gray-400); }

.modal-actions { display: flex; justify-content: space-between; margin-top: 14px; }
.btn-ghost {
  border: none; background: transparent; color: var(--gray-500);
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 12px; border-radius: 8px; cursor: pointer; transition: all .15s ease;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-700); }
#clear-btn:hover { background: #fdecee; color: var(--red); }

/* 토스트 */
.toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--gray-800); color: #fff; font-size: 14px; font-weight: 500;
  padding: 13px 22px; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,23,51,.2); opacity: 0;
  transition: all .25s cubic-bezier(.2,.8,.2,1); pointer-events: none;
  max-width: calc(100vw - 40px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (max-width: 480px) {
  .header-title { font-size: 20px; }
  .container { padding-top: 28px; }
}
