/* 다챙이 - AI 일기 에이전트 (다크 테마, 가챙이/투챙이 톤) */
:root {
  --bg: #0b1020;
  --bg-surface: #131a2e;
  --bg-elevated: #1b2440;
  --border: #2a3556;
  --text-primary: #e7ecf6;
  --text-secondary: #b6c0d8;
  --text-muted: #8090ad;
  --accent: #8b5cf6;
  --accent2: #3b82f6;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(139,92,246,0.15), transparent), var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
code { background: var(--bg-elevated); padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* 로그인 */
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 40px 36px; max-width: 420px; width: 100%; text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.login-card .logo { font-size: 52px; }
.login-card h1 { margin: 12px 0 4px; font-size: 24px; }
.login-card p { color: var(--text-muted); font-size: 14px; line-height: 1.6; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 10px; padding: 11px 18px; font-weight: 700; font-size: 14px;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-ghost { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-secondary); }
.btn-block { width: 100%; }

/* 앱 레이아웃 (사이드바 + 메인) */
#app { min-height: 100vh; }
.layout { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar {
  width: 260px; flex: none; background: var(--bg-surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh;
}
.side-logo { font-size: 18px; font-weight: 800; display: flex; align-items: center; gap: 8px; padding: 6px 8px 14px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-item { text-align: left; background: transparent; border: none; color: var(--text-secondary); padding: 10px 12px; border-radius: 9px; font-size: 14px; font-weight: 600; }
.side-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.side-item.active { background: var(--bg-elevated); color: var(--text-primary); box-shadow: inset 3px 0 0 var(--accent); }
.side-sec { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-muted); padding: 16px 10px 6px; font-weight: 700; }
.side-search { width: 100%; margin: 4px 2px 8px; padding: 8px 12px; font-size: 13px; }
.month-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.month-block { display: flex; flex-direction: column; }
.month-item { text-align: left; background: transparent; border: none; color: var(--text-secondary); padding: 8px 12px; border-radius: 8px; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; cursor: pointer; align-items: center; }
.month-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.month-item.active { background: var(--bg-elevated); color: var(--text-primary); }
.month-item .cnt { color: var(--text-muted); font-size: 12px; }
.month-caret { display: inline-block; width: 14px; font-size: 10px; color: var(--text-muted); }
.date-sub { display: none; flex-direction: column; gap: 1px; margin: 1px 0 3px 14px; padding-left: 8px; border-left: 1px solid var(--border); }
.date-sub.open { display: flex; }
.date-item { text-align: left; background: transparent; border: none; color: var(--text-muted); padding: 5px 10px; border-radius: 7px; font-size: 12.5px; cursor: pointer; }
.date-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.date-item.active { background: var(--bg-elevated); color: var(--text-primary); box-shadow: inset 2px 0 0 var(--accent); }

/* 달력 그리드 */
.cal { margin-bottom: 16px; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { margin-bottom: 6px; }
.cal-head div { text-align: center; font-size: 11px; color: var(--text-muted); font-weight: 700; }
.cal-head div:first-child { color: var(--red); }
.cal-cell { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; font-size: 13px; border-radius: 8px; border: 1px solid transparent; color: var(--text-muted); }
.cal-cell.empty { border: none; }
.cal-cell.has { background: linear-gradient(135deg, rgba(139,92,246,0.25), rgba(59,130,246,0.2)); border-color: var(--accent); color: var(--text-primary); font-weight: 700; cursor: pointer; }
.cal-cell.has:hover { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--border); margin-top: 10px; }
.main { flex: 1; padding: 24px 22px 60px; max-width: 920px; }
.view.hidden { display: none; }
.diary-entry { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; cursor: pointer; }
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .month-list { max-height: 200px; }
  .main { max-width: 100%; padding: 18px 14px 50px; }
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar .title { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.topbar .badge { font-size: 11px; font-weight: 700; color: var(--accent); border: 1px solid var(--accent); border-radius: 8px; padding: 2px 8px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.user-chip { font-size: 12px; color: var(--text-muted); margin-right: 4px; }

.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 18px; }
.card-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-muted); }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], select, textarea {
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: 9px; padding: 9px 12px; font-size: 14px; font-family: inherit; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { width: 100%; resize: vertical; line-height: 1.7; }

#progress { margin-top: 12px; font-size: 13px; color: var(--text-secondary); }
.step { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

#result-card { display: none; }
.diary-meta { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }
.photo-strip { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 14px; }
.photo-strip img { width: 120px; height: 120px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; transition: outline 0.12s; }
.photo-strip img:hover { outline: 2px solid var(--text-muted); }
.photo-strip img.best { outline: 3px solid var(--accent); }
#diary-text { min-height: 280px; font-size: 14.5px; }

#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-primary);
  padding: 12px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: all 0.25s ease; z-index: 9999; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: var(--red); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 500; }
.modal { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; padding: 22px; }
.modal h3 { margin: 0 0 16px; }
.modal .field { margin-bottom: 12px; }
.modal .field input, .modal .field textarea, .modal .field select { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-top: 4px; }

/* 인물 관리 */
#side-people { display: flex; align-items: center; justify-content: space-between; }
.side-badge { background: var(--amber); color: #1b1300; font-size: 11px; font-weight: 800; border-radius: 10px; padding: 1px 7px; min-width: 18px; text-align: center; }
.person-row { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.person-row.pending { border-color: var(--amber); background: rgba(245,158,11,0.07); }
.person-face { width: 54px; height: 54px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); background: var(--bg-elevated); flex: none; }
.person-info { flex: 1; min-width: 0; }
.person-name { font-weight: 700; }
.person-rel { color: var(--accent); font-size: 12px; font-weight: 600; border: 1px solid var(--accent); border-radius: 6px; padding: 1px 6px; margin-left: 4px; }
.person-memo { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
