/* 내 비서 — 스타일
   색: 푸른 기가 도는 연한 회녹색 종이 위에 남색 잉크, 포인트는 울트라마린.
   글꼴: 날짜 숫자만 명조(AppleMyungjo)로 크게, 나머지는 시스템 고딕. */

:root {
  --paper: #eef1ec;
  --card: #f8faf7;
  --ink: #1b2538;
  --muted: #5b6879;
  --line: #d3dad1;
  --accent: #3347d4;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --b0: #f3c9a9;
  --b1: #bde0ce;
  --b2: #cfc8f0;
  --b3: #f0e19b;
  --b4: #b9d8f1;
  --block-ink: #1b2538;
  --serif: "AppleMyungjo", "Nanum Myeongjo", "Noto Serif KR", serif;
  --sans: -apple-system, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12182a;
    --card: #1b2338;
    --ink: #e6eaf2;
    --muted: #9aa6bb;
    --line: #2a3450;
    --accent: #8a98ff;
    --accent-ink: #0f1530;
    --danger: #ff8a80;
    --b0: #6e4a33;
    --b1: #2f5b49;
    --b2: #4c4579;
    --b3: #6b5f22;
    --b4: #2e5677;
    --block-ink: #f1f4fa;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 레이아웃 ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
}

.top {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.today { display: flex; align-items: center; justify-content: space-between; }

.date {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 400;
}
.day {
  font-family: var(--serif);
  font-size: 56px;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.rest { font-size: 15px; color: var(--muted); }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--ink); }

/* ---------- 오늘 리본 ---------- */
.ribbon-toggle {
  appearance: none;
  display: block;
  width: 100%;
  padding: 10px 0 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.allday { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.allday:empty { display: none; }
.chip {
  font-size: 12px;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 5px;
  color: var(--block-ink);
}
.track {
  display: block;
  position: relative;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background-color: var(--card);
  background-image: linear-gradient(to right, var(--line) 1px, transparent 1px);
  background-size: 16.6667% 100%;
}
.block {
  position: absolute;
  height: 20px;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 11px;
  line-height: 20px;
  color: var(--block-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.b0 { background: var(--b0); } .b1 { background: var(--b1); } .b2 { background: var(--b2); }
.b3 { background: var(--b3); } .b4 { background: var(--b4); }
.now {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  border-radius: 1px;
  pointer-events: none;
}
.now::before {
  content: "";
  position: absolute;
  top: -3px;
  left: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.ticks { display: block; position: relative; height: 18px; margin-top: 2px; font-size: 11px; color: var(--muted); }
.ticks span { position: absolute; transform: translateX(-50%); }
.ribbon-summary { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }

.today-list { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--line); }
.today-list li {
  display: grid;
  grid-template-columns: 7.5em 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.today-list time { color: var(--muted); font-variant-numeric: tabular-nums; }
.today-list small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- 대화 ---------- */
.log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px 8px;
}
.msg { margin: 0 0 18px; }
.msg.user { display: flex; justify-content: flex-end; }
.bubble {
  max-width: 85%;
  padding: 9px 14px;
  border-radius: 18px 18px 4px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.bot .body { max-width: 62ch; overflow-wrap: anywhere; }
.body p { margin: 0 0 0.6em; }
.body p:last-child { margin-bottom: 0; }
.body ul, .body ol { margin: 0.2em 0 0.7em 1.2em; padding: 0; }
.body li { margin: 0.15em 0; }
.body .heading { font-weight: 700; }
.body code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; background: var(--card); padding: 1px 5px; border-radius: 4px; }
.body a { color: var(--accent); }
.msg.error .body { color: var(--danger); }
.status { font-size: 14px; color: var(--muted); margin-top: 2px; }
.msg.briefing .body { border-left: 3px solid var(--accent); padding-left: 12px; }
.msg.briefing .when { font-size: 13px; color: var(--muted); margin: 0 0 4px 15px; }

.confirm {
  max-width: 62ch;
  margin: 10px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.confirm p { margin: 0; }
.confirm .what { margin: 2px 0 10px; font-size: 14px; color: var(--muted); }
.confirm strong { color: var(--ink); }
.confirm .actions { display: flex; gap: 8px; }
.confirm.done { color: var(--muted); }

.empty { padding: 28px 0 0; }
.empty-title { margin: 0 0 14px; font-family: var(--serif); font-size: 24px; line-height: 1.3; }
.suggest { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }

/* ---------- 버튼 ---------- */
.btn {
  appearance: none;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.quiet { background: transparent; border-color: var(--line); color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ---------- 입력창 ---------- */
.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  font-size: 16px; /* iOS 자동 확대 방지 */
  line-height: 1.5;
  resize: none;
}
.composer textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
#sendBtn {
  appearance: none;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
#sendBtn:disabled { opacity: 0.35; cursor: default; }

/* ---------- 설정 시트 ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 15, 30, 0.45); }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 720px;
  max-height: 88dvh;
  margin: 0 auto;
  overflow-y: auto;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--card);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sheet h2 { margin: 0; font-family: var(--serif); font-size: 24px; font-weight: 400; }
.group { padding: 16px 0; border-top: 1px solid var(--line); }
.group:first-of-type { border-top: 0; }
.group h3 { margin: 0 0 4px; font-size: 16px; }
.group p { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.group .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.group .warn { color: var(--danger); }
.group input[type="time"] {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  font-size: 16px;
}
.switch { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(90vw, 460px);
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  text-align: center;
}

/* ---------- 로그인 ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { margin: 0 0 6px; font-family: var(--serif); font-size: 32px; font-weight: 400; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.login-card input[type="password"] {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  font-size: 16px;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.login-card .btn { width: 100%; min-height: 48px; }
.login-card .error { min-height: 1.4em; margin: 10px 0 0; color: var(--danger); font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
