/* 마일로라이브러리 공통 스타일 — PC(/)·폰(/m)·도서관 요약(/library)이 함께 쓴다. */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --line: #e6e1d8;
  --text: #22201c;
  --muted: #77716a;
  --accent: #2f6fdf;
  --accent-ink: #ffffff;
  --star: #d99a00;
  --danger: #c9372c;
  --shadow: 0 1px 2px rgba(40, 30, 10, .05), 0 6px 18px rgba(40, 30, 10, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --surface: #1d2024; --surface-2: #23272c; --line: #31363d;
    --text: #e8e6e1; --muted: #9a9790; --accent: #6b9bff; --accent-ink: #0f1420;
    --star: #f0b52a; --danger: #ff7a6e;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171a; --surface: #1d2024; --surface-2: #23272c; --line: #31363d;
  --text: #e8e6e1; --muted: #9a9790; --accent: #6b9bff; --accent-ink: #0f1420;
  --star: #f0b52a; --danger: #ff7a6e;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-y: scroll; }  /* 스크롤바 자리 고정 — 탭마다 폭이 흔들리지 않게 */
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14.5px/1.55 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
        "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  word-break: keep-all; overflow-wrap: anywhere;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 6px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 14.5px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.back { display: inline-block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}

button, .btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); border-radius: 10px; padding: 8px 14px; cursor: pointer;
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* 영역 표시 — 색 점 + 이름 */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600;
  cursor: pointer; user-select: none; color: var(--text);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); }
.chip.on { background: var(--c); border-color: var(--c); color: #fff; }
.chip.on .dot { background: #fff; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  color: var(--c, var(--muted));
}
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--muted)); }
.star { color: var(--star); }

/* 기록 한 줄 */
.log { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.log:first-child { border-top: 0; }
.log .bar { width: 3px; border-radius: 3px; background: var(--c); flex: none; }
.log .body { flex: 1; min-width: 0; }
.log .meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.log .text { white-space: pre-wrap; }
.daygrp { font-size: 12px; font-weight: 700; color: var(--muted); margin: 14px 0 2px; }
.daygrp:first-child { margin-top: 0; }

/* 목표 한 줄 */
.goal { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.goal:first-child { border-top: 0; }
.goal .chk {
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--c, var(--line));
  flex: none; margin-top: 1px; cursor: pointer; background: transparent; padding: 0;
  display: grid; place-items: center; color: #fff; font-size: 12px; line-height: 1;
}
.goal.done .chk { background: var(--c); }
.goal.done .gtitle { text-decoration: line-through; color: var(--muted); }
.goal .gdetail { font-size: 12.5px; color: var(--muted); }

/* 정리 노트 */
.note h3 { display: flex; justify-content: space-between; gap: 8px; }
.note .nbody { white-space: pre-wrap; font-size: 13.5px; }
.note .src { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* 30일 기록 띠 */
.streak { display: grid; grid-template-columns: repeat(30, 1fr); gap: 3px; }
.streak i { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line); }
.streak i.l1 { background: color-mix(in srgb, var(--accent) 35%, transparent); border-color: transparent; }
.streak i.l2 { background: color-mix(in srgb, var(--accent) 65%, transparent); border-color: transparent; }
.streak i.l3 { background: var(--accent); border-color: transparent; }
.streak i.today { outline: 2px solid var(--text); outline-offset: 1px; }

/* 기록 입력 묶음 */
.composer .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.composer .row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.composer .row input[type=date] { width: auto; }
.composer .startoggle { border-radius: 999px; }
.composer .startoggle.on { color: var(--star); border-color: var(--star); }
.composer .grow { flex: 1; }

.empty { color: var(--muted); font-size: 13px; padding: 10px 0; }

/* 시트(폰)·모달(PC) 공통 */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); display: none; z-index: 50;
  align-items: flex-end; justify-content: center;
}
.overlay.open { display: flex; }
.sheet {
  background: var(--surface); width: min(560px, 100%); max-height: 88vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 760px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 18px; }
}
.sheet .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.sheet label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text);
  color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60;
}
.toast.show { opacity: 1; }
