:root{
  --bg: #0f172a;
  --card: #1b2942;
  --card-hover: #233453;
  --line: #2b3b58;
  --text: #eef2f8;
  --muted: #8b9ab3;
  --accent: #5cc8c0;
  --accent-soft: rgba(92,200,192,0.16);
}

@media (prefers-color-scheme: light){
  :root{
    --bg: #f6f8fb;
    --card: #ffffff;
    --card-hover: #eef2f7;
    --line: #e2e8f0;
    --text: #1f2937;
    --muted: #6b7686;
    --accent: #0d9488;
    --accent-soft: rgba(13,148,136,0.10);
  }
}

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

html, body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
  transition: background 0.2s ease, color 0.2s ease;
  overscroll-behavior-y: none;
}

/* 상단 앱바 */
.appbar{
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 14px) 20px 10px;
  border-bottom: 1px solid var(--line);
}

.appbar .eyebrow{
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 4px;
}

.appbar h1{
  font-size: 20px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.01em;
}

.appbar .back{
  display:inline-flex;
  align-items:center;
  gap: 4px;
  color: var(--muted);
  text-decoration:none;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

/* 콘텐츠 영역 */
main{
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 20px calc(90px + env(safe-area-inset-bottom));
}

.sub{
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 24px;
  line-height: 1.6;
}

/* 하단 탭바 */
.tabbar{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display:flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}

.tabbar a{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 3px;
  text-decoration:none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 0;
  border-radius: 10px;
  transition: background 0.15s ease, color 0.15s ease;
}

.tabbar a .tab-icon{ font-size: 21px; }

.tabbar a.active{ color: var(--accent); }

.tabbar a:active{ background: var(--accent-soft); transform: scale(0.96); }

.section-label{
  margin: 36px 0 12px;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.section-label:first-of-type{ margin-top: 0; }

/* 날씨 카드 (작게 + 전체 영역 클릭 가능) */
.weather-link{
  display:block;
  text-decoration:none;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  transition: background 0.15s ease;
}
.weather-link:active{ background: var(--card-hover); }

.weather-card{
  display:flex;
  align-items:center;
  gap: 12px;
}

.weather-card .icon{
  font-size: 26px;
  width: 34px;
  text-align:center;
}

.weather-card .info .temp{
  font-size: 18px;
  font-weight: 800;
}

.weather-card .info .desc{
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.weather-card .info .place{
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.weekly-strip{
  display:flex;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  overflow-x:auto;
}

.weekly-strip .day{
  flex: 1;
  min-width: 40px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
}

.weekly-strip .day .dname{ font-weight: 700; }
.weekly-strip .day .dicon{ font-size: 16px; }
.weekly-strip .day .drange{ font-size: 10px; color: var(--text); white-space:nowrap; }
.weekly-strip .day .drange .lo{ color: var(--muted); }

/* 캘린더 임베드 (참고용, 더 이상 사용하지 않음) */
.cal-wrap{
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
}

.cal-wrap iframe{
  width: 100%;
  border: 0;
  display:block;
}
.cal-wrap iframe.agenda{ height: 320px; }
.cal-wrap iframe.month{ height: 560px; }

.cal-more{
  display:block;
  text-align:center;
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  text-decoration:none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.cal-more:hover{ background: var(--card-hover); border-color: var(--accent); }
.cal-more:active{ background: var(--card-hover); transform: scale(0.98); }

/* 다가오는 일정 목록 */
.agenda-list{
  display:flex;
  flex-direction:column;
  gap: 8px;
}

.agenda-item{
  display:flex;
  align-items:center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.agenda-item .date-chip{
  flex-shrink:0;
  width: 46px;
  text-align:center;
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 6px 0;
  color: var(--accent);
  font-weight: 800;
}

.agenda-item .date-chip .dow{
  font-size: 10px;
  font-weight: 700;
  opacity: 0.85;
}

.agenda-item .date-chip .day{
  font-size: 16px;
  line-height: 1.1;
}

.agenda-item .ev-title{
  font-size: 14px;
  font-weight: 700;
}

.agenda-item .ev-time{
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.agenda-empty, .agenda-loading{
  color: var(--muted);
  font-size: 13px;
  text-align:center;
  padding: 24px 0;
}

/* 월간 캘린더 그리드 */
.cal-nav{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 12px;
}

.cal-nav button{
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  font-size: 16px;
  font-weight: 700;
}
.cal-nav button:active{ background: var(--card-hover); transform: scale(0.95); }

.cal-nav .label{
  font-size: 16px;
  font-weight: 800;
}

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

.cal-grid .dow{
  text-align:center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding-bottom: 6px;
}

.cal-cell{
  aspect-ratio: 1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  border-radius: 10px;
  font-size: 13px;
  position:relative;
  color: var(--text);
}

.cal-cell.muted{ color: var(--muted); opacity: 0.45; }
.cal-cell.today{ background: var(--accent-soft); font-weight: 800; color: var(--accent); }
.cal-cell.selected{ outline: 2px solid var(--accent); }

.cal-cell .dot{
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 2px;
}

.day-events{
  margin-top: 18px;
  display:flex;
  flex-direction:column;
  gap: 8px;
}

/* 일정 추가 폼 */
.add-event-form{
  display:flex;
  flex-direction:column;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.add-event-form input{
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
}

.add-event-form input::-webkit-calendar-picker-indicator{
  filter: var(--icon-filter, none);
}

.add-event-form .row{
  display:flex;
  gap: 8px;
}

.add-event-form .row input{ flex: 1; }

.add-event-form button{
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  font-weight: 800;
}

.add-event-form button:active{ transform: scale(0.98); }

.add-event-msg{
  font-size: 12px;
  min-height: 14px;
}
.add-event-msg.success{ color: var(--accent); }
.add-event-msg.error{ color: #e8916b; }

/* 링크 카드 2열 그리드 */
.grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid a{
  display:flex;
  flex-direction:column;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 14px;
  text-decoration:none;
  color: var(--text);
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.grid a:hover, .grid a:focus-visible{
  background: var(--card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  outline:none;
}

.grid a:active{
  background: var(--card-hover);
  transform: scale(0.97);
}

.grid .icon-badge{
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 20px;
}

.grid .title{
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.grid .desc{
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

footer{
  margin-top: 44px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}
