/* style.css - 최근 기록 가독성 개선 버전 */
:root{
  --bg: #0b1020;
  --panel: #121832;
  --muted: #8a94bf;
  --text: #e6e9f5;
  --primary: #6ea8fe;
  --primary-ghost: rgba(110,168,254,.15);
  --danger: #ff6b6b;
  --warn: #ffcc66;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --border: 1px solid rgba(255,255,255,.08);
  --input-bg: #0c1330;
  --input-bd: rgba(255,255,255,.12);
  --input-bd-focus: rgba(110,168,254,.65);
  /* 새롭게 추가된 토큰 */
  --success: #4ade80;
  --info: #93c5fd;
  --ring: rgba(110,168,254,.35);
}

*{ box-sizing:border-box }
html,body{ height:100% }
body{
  margin:0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Apple SD Gothic Neo, Noto Sans KR, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(110,168,254,.12), transparent 60%),
              linear-gradient(180deg, #0b1020 0%, #0b1020 100%);
  color:var(--text);
}

.card h2{ margin: 0 0 12px 0; font-size: 18px }
.card-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom: 10px }

.grid-form{
  display:grid; gap:12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 640px){
  .grid-form{ grid-template-columns: 1fr }
}
.field{ display:flex; flex-direction:column; gap:6px; font-size: 13px; color: var(--muted) }
.field-inline{ display:flex; align-items:center; gap:8px; color: var(--muted) }

/* 입력 요소 공통 */
.field input[type="text"],
.field input[type="number"],
.field textarea,
.field select{
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--input-bd);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  appearance: none;
  min-height: 42px;
}
.field textarea{
  min-height: 60px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

.field input[type="text"]::placeholder,
.field input[type="number"]::placeholder{ color: #99a3d1; opacity:.6 }

.field input[type="text"]:focus-visible,
.field input[type="number"]:focus-visible,
.field textarea:focus-visible,
.field select:focus-visible{
  border-color: var(--input-bd-focus);
  box-shadow: 0 0 0 3px var(--ring);
}

/* 셀렉트 드롭다운 아이콘(간단히) */
.field select{
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(1em + 2px), calc(100% - 13px) calc(1em + 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

/* 체크박스 */
.ck{ width: 18px; height: 18px; accent-color: var(--primary); }
.ck:focus-visible{ outline: none; box-shadow: 0 0 0 3px var(--ring); border-radius: 4px }
.field-inline span{ user-select:none }

/* 버튼 */
.btn{
  border: var(--border);
  color: var(--text);
  background: transparent;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
}
.btn:hover{ background: rgba(255,255,255,.05) }
.btn.primary{ background: var(--primary); border-color: transparent; color:#0b1020; font-weight:600 }
.btn.primary:hover{ filter: brightness(1.05) }
.btn.ghost{ background: var(--primary-ghost); border-color: transparent; color: var(--primary) }
.btn.ghost.danger{ background: rgba(255,107,107,.16); color:#ff9b9b }
.btn.wide{ grid-column: 1 / -1 }

/* 리스트 - 가독성 개선 */
.list{ list-style:none; padding:0; margin:0; display:grid; gap:8px }
.list-item{
  display:grid; gap:6px; padding:12px; border-radius:12px;
  border: var(--border);
  background: rgba(255,255,255,.02)
}
.item-main{ display:flex; align-items:center; gap:10px }
.item-main .who{ font-weight:600 }
.item-main .temp{ font-variant-numeric: tabular-nums; opacity:.95 }
.item-main .flags{ margin-left:auto; display:flex; gap:6px }

/* 최근 기록 날짜/시간 가독성 개선 */
.item-sub{ 
  font-size: 14px;           /* 12px -> 14px 크게 */
  color: var(--text);         /* muted -> text 색상 */
  opacity: 0.85;              /* 약간의 투명도 */
  font-weight: 500;           /* 더 굵게 */
  letter-spacing: 0.5px;      /* 자간 늘림 */
  background: rgba(255,255,255,0.04);  /* 배경 추가 */
  padding: 4px 8px;           /* 패딩 추가 */
  border-radius: 6px;         /* 둥글게 */
  margin-top: 4px;            /* 위 간격 */
}
.item-memo{
  font-size: 13px;
  color: var(--muted);
  background: rgba(255,255,255,.04);
  padding: 8px 10px;
  border-radius: 8px;
  line-height: 1.5;
  margin-top: 6px;
  white-space: pre-wrap;
}


.item-actions{ display:flex; gap:8px }

.chip{
  display:inline-flex; align-items:center;
  background: var(--primary-ghost); color: var(--primary);
  border-radius:999px; padding:4px 10px; font-size:12px;
  border: 1px solid rgba(110,168,254,.35);
}
.chip.memo{ background: rgba(147,197,253,.20); color: var(--info); border-color: rgba(147,197,253,.45); }
.chip.warn{ background: rgba(255,204,102,.15); color: var(--warn); border-color: rgba(255,204,102,.35) }

/* 모달 */
.modal{
  border: none; border-radius: 16px; padding: 16px 16px 12px; width: 420px; max-width: calc(100% - 24px);
  background: var(--panel); color: var(--text);
}
.modal::backdrop{ background: rgba(0,0,0,.45) }
.modal h3{ margin: 0 0 10px 0 }
.modal label{ display:flex; flex-direction:column; gap:6px; margin-bottom:10px; color: var(--muted) }
.modal menu{ display:flex; justify-content:flex-end; gap:10px; margin: 8px 0 0 0; padding:0 }

/* ===== Utilities & Effects ===== */

/* 간격 유틸 */
.mt-8{ margin-top: 8px } .mt-12{ margin-top: 12px } .mt-16{ margin-top: 16px }
.mb-8{ margin-bottom: 8px } .mb-12{ margin-bottom: 12px } .mb-16{ margin-bottom: 16px }

/* Pills(빠른 선택) */
.pills{ display:flex; flex-wrap:wrap; gap:8px }
.pill{
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.pill:hover{ background: rgba(255,255,255,.06) }
.pill.active{ border-color: var(--input-bd-focus); box-shadow: 0 0 0 3px var(--ring) }

/* Toast */
.toast-wrap{
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  display: grid; gap: 8px;
}
.toast{
  padding: 10px 12px; border-radius: 10px; color: #0b1020; font-weight: 600;
  box-shadow: var(--shadow);
}
.toast.ok{ background: var(--success) }
.toast.err{ background: var(--danger) }

/* Skeleton */
@keyframes shimmer {
  0% { background-position: -450px 0 }
  100% { background-position: 450px 0 }
}
.skel{
  border-radius: 12px; height: 64px; border: var(--border);
  background: linear-gradient(90deg, rgba(255,255,255,.06) 25%, rgba(255,255,255,.12) 37%, rgba(255,255,255,.06) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite;
}

/* Empty state */
.empty{
  border: var(--border); border-radius: 12px; padding: 24px; text-align: center;
  color: var(--muted); background: rgba(255,255,255,.02);
}

/* 요약 카드용 */
.card.mini{ padding:12px }
#summary-cards{ grid-template-columns: repeat(4, minmax(0,1fr)) }
@media (max-width: 640px){ #summary-cards{ grid-template-columns: repeat(2, minmax(0,1fr)) } }
#summary-cards strong{ display:block; color: var(--muted); margin-bottom: 6px }
#summary-cards div{ font-variant-numeric: tabular-nums; }

/* ==== Desktop polish ==== */
@media (min-width: 1024px){
  .container{
    max-width: 1160px; /* PC에서 카드 폭을 넉넉하게 */
  }
  /* 폼 그리드: PC에서 여유가 있으니 칼럼 간격을 넓힘 */
  .grid-form{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 18px;
    row-gap: 12px;
  }
  /* 전체폭이 필요한 요소에 .full 적용 */
  .full{ grid-column: 1 / -1 }
}

/* 라디오 그룹 */
.group{ gap: 10px }
.group legend{ font-size: 13px; color: var(--muted); margin-right: 8px }
.radio{ display:inline-flex; align-items:center; gap:6px; margin-right: 10px }
.radio input{ accent-color: var(--primary) }

/* 칩 색상: 해열제 종류별 */
.chip.ibu{ background: rgba(110,168,254,.18); color: var(--primary); border-color: rgba(110,168,254,.38) }   /* 부르펜 */
.chip.tyl{ background: rgba(255,204,102,.18); color: var(--warn); border-color: rgba(255,204,102,.38) }   /* 타이레놀 */

/* fieldset 기본 테두리 제거 */
fieldset{ border:0; margin:0; padding:0 }

/* 세그먼트 그룹 */
.seg-group{
  display:flex; align-items:center; flex-wrap:wrap; gap:8px;
}
.seg-group legend{
  font-size:13px; color:var(--muted); margin-right:8px
}
.seg-item{
  position:relative; display:inline-flex; align-items:center;
}
.seg-item input{
  position:absolute; opacity:0; pointer-events:none;
}
.seg-item span{
  display:inline-block;
  padding:8px 12px; border-radius:999px;
  background: var(--input-bg);
  border: 1px solid var(--input-bd);
  color: var(--text); font-size:12px;
  transition: all .15s ease;
}
.seg-item span:hover{ background: rgba(255,255,255,.04) }
.seg-item input:focus-visible + span{
  box-shadow: 0 0 0 3px rgba(110,168,254,.25); border-color: var(--input-bd-focus);
}
.seg-item input:checked + span{
  background: var(--primary-ghost); color: var(--primary);
  border-color: var(--input-bd-focus);
}

#avgChart, #countChart{ width:100%; min-height: 320px; }
.chart-box { position: relative; width: 100%; min-height: 340px; }
#avgChart, #countChart { width: 100%; height: 100%; }
.legend-hint { margin-top: 8px; color: var(--muted); font-size: 12px; }

.status-grid { display:grid; grid-template-columns: repeat(3, minmax(220px,1fr)); gap:12px; }
.status-card { padding:12px; border:1px solid var(--input-bd); border-radius:12px; background: var(--panel); }
.status-card .name { font-weight:600; margin-bottom:6px; }
.status-card .chip { margin-left:6px; }
.grid-3 { display:grid; grid-template-columns: repeat(3, minmax(220px,1fr)); gap:16px; }
.chart-box { position:relative; width:100%; min-height: 240px; }
.person-box canvas { width: 100%; height: 200px; }
.table { width:100%; border-collapse: collapse; }
.table th, .table td { padding:8px 10px; border-bottom: 1px dashed var(--input-bd); text-align:left; }

a.link{ color: var(--link); text-decoration: none; }
a.link:hover{ text-decoration: underline; opacity:.9; }

/* 칩 색상: 상태 배지용 */
.chip{ display:inline-block; padding:2px 8px; border-radius:999px; font-size:12px; }
.chip.ok{ background: #2a785a33; color:#9be3c2; border:1px solid #2a785a55; }
.chip.info{ background:#ffcc6633; color:#ffd79a; border:1px solid #ffcc6670; }
.chip.warn{ background:#ff7b9e33; color:#ffb3c3; border:1px solid #ff7b9e66; }