/* ─── reset & vars ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --purple : #8B008B;
  --blue   : #0055bb;
  --red    : #cc0000;
  --orange : #cc4400;
  --green  : #006633;
  --gray   : #666;
  --sun-bg : #fff0f0;
  --sat-bg : #f0f0ff;
  --border : #d0d0d0;
  --hol-bg : #ffe8e8;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background: #f0f0f0;
  min-height: 100vh;
  font-size: 14px;
}
.hidden { display: none !important; }
a { color: var(--purple); text-decoration: none; }

/* ─── login / register ──────────────────────────────────────────────────── */
#login-screen, #register-screen {
  display: flex; align-items: flex-start; justify-content: center;
  min-height: 100vh; padding: 40px 16px;
}
.auth-box {
  background: white; border-radius: 14px;
  padding: 32px 24px; width: 100%; max-width: 360px;
  box-shadow: 0 3px 24px rgba(0,0,0,.13);
}
.auth-box h1 {
  text-align: center; color: var(--purple);
  font-size: 22px; margin-bottom: 6px;
}
.auth-box .subtitle {
  text-align: center; color: #888; font-size: 12px; margin-bottom: 22px;
}
.auth-box input, .auth-box select {
  display: block; width: 100%;
  padding: 10px 12px; margin-bottom: 10px;
  border: 1px solid #ccc; border-radius: 7px; font-size: 15px;
}
.auth-box input:focus, .auth-box select:focus {
  outline: 2px solid var(--purple); border-color: transparent;
}
.auth-box .btn-primary {
  display: block; width: 100%; padding: 12px;
  background: var(--purple); color: white;
  border: none; border-radius: 7px; font-size: 16px;
  cursor: pointer; margin-top: 6px; font-weight: bold;
}
.auth-box .btn-primary:active { opacity: .85; }
.auth-link { text-align: center; margin-top: 14px; font-size: 13px; color: #555; }
.auth-link a { font-weight: bold; }
.notice-box {
  background: #fff8e8; border: 1px solid #f0c040;
  border-radius: 7px; padding: 10px 12px;
  font-size: 12px; color: #664400; line-height: 1.7;
  margin-bottom: 12px;
}

/* ─── app header ────────────────────────────────────────────────────────── */
.app-header {
  background: var(--purple); color: white;
  padding: 8px 12px 6px; position: sticky; top: 0; z-index: 50;
}
.header-row1 {
  display: flex; justify-content: space-between; align-items: center;
}
.header-row1 .app-title { font-size: 16px; font-weight: bold; }
.header-row1 .btn-menu {
  background: none; border: none; color: white;
  font-size: 22px; cursor: pointer; padding: 2px 6px; line-height: 1;
}
.header-stats {
  font-size: 12px; color: rgba(255,255,255,.9); margin-top: 3px;
}
.header-nickname {
  font-size: 12px; color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.15);
  padding: 2px 8px; border-radius: 10px;
}

/* ─── month navigation ──────────────────────────────────────────────────── */
.month-nav {
  display: flex; align-items: center;
  background: white; padding: 7px 8px;
  border-bottom: 1px solid var(--border);
}
.month-nav .nav-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: #444; color: white; border: none;
  font-size: 13px; cursor: pointer; flex-shrink: 0;
}
.month-nav .nav-btn:active { background: #222; }
#month-label {
  flex: 1; text-align: center; font-size: 18px; font-weight: bold;
  border: 1px solid #ccc; border-radius: 5px;
  padding: 5px 10px; margin: 0 8px;
}

/* ─── calendar grid ─────────────────────────────────────────────────────── */
.cal-container { background: white; }
.dow-header {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
}
.dow-cell {
  text-align: center; padding: 5px 0;
  font-size: 12px; font-weight: bold; color: #444;
}
.dow-cell.sun { color: var(--red);  background: #ffe0e0; }
.dow-cell.sat { color: var(--blue); background: #dde8ff; }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 1px; background: var(--border);
}
.day-cell {
  background: white; min-height: 72px; padding: 2px 3px 26px;
  position: relative; cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.day-cell:active { filter: brightness(.93); }
.day-cell.sun-col { background: var(--sun-bg); }
.day-cell.sat-col { background: var(--sat-bg); }
.day-cell.hol-col { background: var(--hol-bg); }
.day-cell.today   { outline: 2px solid var(--purple); outline-offset: -2px; }
.day-cell.empty   { background: #f5f5f5; cursor: default; pointer-events: none; }

/* 수동수정 표시 */
.day-cell.modified::before {
  content: ''; position: absolute; top: 0; left: 0;
  border-top: 7px solid #f90; border-right: 7px solid transparent;
}

/* 날짜 숫자 */
.cell-daynum {
  display: block;
  font-size: 11px; font-weight: bold; color: #333; line-height: 1.4;
}
.day-cell.sun-col .cell-daynum, .day-cell.hol-col .cell-daynum { color: var(--red); }
.day-cell.sat-col .cell-daynum { color: var(--blue); }

/* 노선번호 — 날짜 바로 아래 */
.cell-busno {
  display: block;
  font-size: 10px; color: #660099; font-weight: bold; line-height: 1.3;
}

/* 공휴일명 — 우상단 절대위치 */
.cell-hname {
  position: absolute; top: 2px; right: 3px;
  font-size: 8px; color: var(--red);
  white-space: nowrap; overflow: hidden; max-width: 55%;
  text-align: right;
}

/* 근무유형 */
.cell-wt {
  text-align: center; font-size: 17px; font-weight: bold;
  line-height: 1.1; margin: 1px 0;
}
.wt-전  { color: #0066cc; }
.wt-후  { color: #007722; }
.wt-휴무 { color: var(--red); font-size: 15px; }
.wt-운휴 { color: var(--red); font-size: 15px; }

/* 출발시간 — 우하단 절대위치 */
.cell-time {
  position: absolute; bottom: 2px; right: 3px;
  font-size: 11px; color: #333; font-weight: bold;
}

/* 메모 — 시간 바로 위 절대위치 */
.cell-memo {
  position: absolute; bottom: 15px; right: 3px;
  font-size: 11px; color: #333; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 90%;
}

/* ─── bottom-sheet modal ────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end;
}
.modal-bg {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.46);
}
.modal-sheet {
  position: relative; width: 100%;
  background: white; border-radius: 18px 18px 0 0;
  max-height: 88vh; overflow-y: auto;
  animation: slideUp .22s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: white; z-index: 1;
}
.modal-head .modal-title { font-size: 16px; font-weight: bold; }
.btn-close {
  background: none; border: none; font-size: 20px;
  color: #555; cursor: pointer; padding: 2px 6px;
}
.modal-body { padding: 12px 16px 28px; }

.cur-info {
  background: #f7f2ff; border-radius: 8px;
  padding: 10px 14px; margin-bottom: 14px;
  font-size: 13px; line-height: 1.7;
}
.cur-info .big-wt { font-size: 26px; font-weight: bold; display: inline-block; margin-left: 6px; }

.sec-title { font-size: 12px; font-weight: bold; color: #777; margin-bottom: 8px; }
.sec-block { margin-bottom: 16px; }

.input-row {
  display: flex; align-items: center; margin-bottom: 9px; gap: 8px;
}
.input-row label { width: 68px; font-size: 13px; color: #555; flex-shrink: 0; }
.input-row input, .ov-select {
  flex: 1; padding: 8px 10px;
  border: 1px solid #ccc; border-radius: 6px; font-size: 14px;
}
.input-row input:focus, .ov-select:focus { outline: 2px solid var(--purple); border-color: transparent; }

.btn-action {
  display: block; width: 100%; padding: 11px;
  border: none; border-radius: 8px; font-size: 15px;
  cursor: pointer; margin-bottom: 8px; font-weight: bold;
}
.btn-primary  { background: var(--purple); color: white; }
.btn-default  { background: #eee; color: #333; }
.btn-danger   { background: #d00; color: white; }
.btn-action:active { opacity: .82; }

/* ─── pattern picker modal ──────────────────────────────────────────────── */
#anchor-modal .modal-sheet { max-height: 92vh; }
.pattern-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px; padding: 4px 0;
}
.pat-item {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 4px; text-align: center; cursor: pointer;
}
.pat-item:active { background: #f0e8ff; }
.pat-bus  { font-size: 10px; color: #660099; font-weight: bold; }
.pat-wt   { font-size: 18px; font-weight: bold; }
.pat-idx  { font-size: 9px; color: #aaa; margin-top: 1px; }

/* ─── menu drawer ───────────────────────────────────────────────────────── */
#menu-drawer .modal-sheet { border-radius: 0 0 18px 18px; max-height: 60vh; top: 0; }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; font-size: 15px;
}
.menu-item:active { background: #f5f5f5; }
.menu-icon { font-size: 20px; width: 28px; text-align: center; }

/* ─── loading ───────────────────────────────────────────────────────────── */
.loading {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(255,255,255,.6);
  display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid #ddd; border-top-color: var(--purple);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── iOS 홈화면 추가 안내 배너 ─────────────────────────────────────────── */
.ios-hint {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 300;
  padding: 0 12px 8px;
  animation: slideUp .3s ease;
}
.ios-hint-body {
  background: #1c1c1e; color: white;
  border-radius: 14px; padding: 14px 14px 14px 12px;
  display: flex; align-items: flex-start; gap: 10px;
  box-shadow: 0 -2px 20px rgba(0,0,0,.3);
}
.ios-hint-icon { font-size: 28px; flex-shrink: 0; line-height: 1; }
.ios-hint-text { flex: 1; font-size: 13px; line-height: 1.6; }
.ios-hint-text strong { font-size: 14px; }
.ios-share-icon {
  display: inline-block;
  background: #555; border-radius: 4px;
  padding: 1px 5px; font-size: 12px;
}
.ios-hint-close {
  background: #444; border: none; color: white;
  width: 24px; height: 24px; border-radius: 50%;
  font-size: 12px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.ios-hint-arrow {
  text-align: center; color: #1c1c1e;
  font-size: 18px; line-height: 1; margin-top: -2px;
}
.ios-hint-warn {
  display: inline-block;
  color: #ffcc00; font-size: 12px; line-height: 1.5;
  margin: 3px 0 4px;
}

/* ─── 데이터 삭제 경고 ──────────────────────────────────────────────────── */
.clear-warn {
  background: #fff0f0; border: 1px solid #ffcccc;
  border-radius: 8px; padding: 10px 12px;
  font-size: 12px; color: #c00; line-height: 1.7;
  margin: 14px 0 16px;
}
