:root {
  --bg: #F7F7F5;
  --text: #37352F;
  --text-muted: #787774;
  --border: #E9E9E7;
  --brand: #3A3C84;
  --brand-soft: #DFE6F7;
  --accent: #2E74B5;
  --card: #ffffff;
  --hover: #F1F1EF;
  --danger: #b3261e;
}
* { box-sizing: border-box; margin: 0; }
body { font-family: Pretendard, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg); color: var(--text); }
.hidden { display: none !important; }

#login-view { max-width: 320px; margin: 25vh auto; text-align: center;
  display: flex; flex-direction: column; gap: 12px; padding: 0 16px; }
#login-view h1 { color: var(--brand); font-size: 22px; }

header { background: var(--card); color: var(--text); padding: 12px 16px;
  position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; }
header h1 { font-size: 17px; font-weight: 700; color: var(--text); }
header button#search-open-btn { background: none; border: none; color: var(--text-muted);
  font-size: 18px; padding: 4px 8px; }
main { max-width: 760px; margin: 0 auto; padding: 12px 12px 76px; }

input, textarea, button, select { font: inherit; }
input, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--card); color: var(--text); }
input:focus, textarea:focus, #meeting-editor:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px rgba(58,60,132,.12); }
textarea { resize: vertical; }
button { padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text); cursor: pointer; }
button:hover { background: var(--hover); }
button.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
button.primary:hover { background: #32346f; }
button.danger { color: var(--danger); }
button.text-btn { border: none; background: none; padding: 4px 8px; color: var(--text-muted); }
button.text-btn:hover { background: var(--hover); border-radius: 6px; }

select { appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 30px; border: 1px solid var(--border); border-radius: 8px;
  background-color: var(--card); background-repeat: no-repeat;
  background-position: right 10px center;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%23787774' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>"); }

.input-box { background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; margin-top: 10px; }
.input-box textarea { border: none; padding: 4px; resize: none;
  transition: min-height .25s ease, background .25s ease; }

#meeting-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
#meeting-header #meeting-title { flex: 2; }
#meeting-header #meeting-category { flex: 1; }
#meeting-header #meeting-cancel-btn { flex-shrink: 0; white-space: nowrap; }

#meeting-editor {
  display: none;
  min-height: 55vh;
  line-height: 28px;
  padding: 6px 8px;
  border-radius: 8px;
  overflow-y: auto;
  background:
    repeating-linear-gradient(transparent, transparent 27px, #dfe3f2 27px, #dfe3f2 28px),
    #fffdf5;
}
#meeting-editor:not(.hidden) { display: block; }
#meeting-editor h3 { font-size: 17px; font-weight: 700; margin: 6px 0 2px; }
#meeting-editor div, #meeting-editor p { font-size: 15px; margin: 0; }

.input-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.input-actions #send-btn, .input-actions #meeting-end-btn { margin-left: auto; }
#mic-btn.rec { background: #ffe3e3; border-color: #e88; }

#format-toggle.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.msg { font-size: 13px; color: var(--brand); padding: 6px 4px; min-height: 18px; }

h2 { font-size: 13px; font-weight: 500; color: var(--text-muted);
  text-transform: none; letter-spacing: .01em; margin: 20px 4px 8px; }
.item { background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 6px; font-size: 15px; box-shadow: none;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item label { display: flex; gap: 8px; align-items: center; flex: 1; }
.item.note { display: block; }
.item .detail { font-size: 13px; color: var(--text-muted); margin-top: 4px;
  white-space: pre-wrap; }
.item .cat { font-size: 12px; color: var(--text-muted); background: var(--brand-soft);
  border-radius: 6px; padding: 1px 8px; margin-left: auto; }
.item .due { font-size: 12px; color: var(--danger); }
.item .person-badge { font-size: 12px; color: var(--accent); background: var(--hover);
  border-radius: 6px; padding: 1px 8px; }
.g-badge { font-size: 11px; font-weight: bold; color: #555; background: #e6e6e6;
  border-radius: 4px; padding: 1px 6px; }
.gcal-done { font-size: 12px; color: var(--accent); }
.actions { display: flex; gap: 6px; margin: -2px 0 8px; }
.actions button { font-size: 12px; padding: 4px 10px; }
.pending-note { font-size: 13px; color: #8a6d00; background: #fff7dd;
  border-radius: 8px; padding: 8px 12px; margin-top: 10px; }

.person-group { margin-bottom: 10px; }
.person-group h3 { font-size: 13px; font-weight: 500; color: var(--accent);
  margin: 10px 4px 4px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0; }
.tabs .tab { white-space: nowrap; font-size: 14px; }
.tabs .tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.cat-row { display: flex; align-items: center; gap: 8px; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
  margin-bottom: 6px; }
.cat-row .actions { margin: 0 0 0 auto; }
.add-row { display: flex; gap: 8px; margin: 10px 0 20px; }
#settings-view input { margin-bottom: 8px; }

/* ---------- 네비게이션: 모바일 하단 탭 / 데스크톱 좌측 사이드바 ---------- */
.nav-brand { display: none; }
nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
nav button { flex: 1; border: none; border-radius: 0; padding: 10px 0;
  font-size: 14px; color: var(--text-muted); background: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  position: relative; }
nav button:hover { background: var(--hover); }
nav button .nav-icon { font-size: 20px; line-height: 1; }
nav button .nav-label { font-size: 11px; line-height: 1; }
nav button.active { color: var(--brand); font-weight: 700; }
nav button.active::before { content: ""; position: absolute; top: 0;
  left: 50%; transform: translateX(-50%); width: 28px; height: 3px;
  border-radius: 3px; background: var(--brand); }

/* ---------- 검색 ---------- */
.search-bar { display: flex; gap: 8px; margin-top: 10px; }
.search-bar input { min-width: 0; }
.search-bar button { white-space: nowrap; flex-shrink: 0; }
.raw-hit { background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 6px; font-size: 14px; white-space: pre-wrap; }
.raw-hit .when { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 4px; }

.person-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.person-chips button { font-size: 13px; padding: 5px 12px; border-radius: 999px;
  color: var(--accent); border-color: var(--border); }
.person-chips button:hover { background: var(--brand-soft); }

.person-table { width: 100%; border-collapse: collapse; margin-top: 8px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; }
.person-table th { background: var(--brand-soft); font-size: 12px; font-weight: 500;
  text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--text-muted); }
.person-table td { padding: 8px 10px; font-size: 14px; border-bottom: 1px solid var(--border); }
.person-table tr:last-child td { border-bottom: none; }
.person-table .p-when { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.person-table .p-status { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.person-table tr.done td { opacity: .45; }
.person-table tr.done .p-title { text-decoration: line-through; }

/* ---------- 캘린더 ---------- */
.cal-nav { display: flex; align-items: center; justify-content: center;
  gap: 16px; margin: 10px 0; font-size: 16px; font-weight: 700; color: var(--brand); }
.cal-nav button { border: none; background: none; font-size: 18px; color: var(--brand); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .cal-dow { text-align: center; font-size: 12px; color: var(--text-muted);
  padding: 4px 0; }
.cal-cell { aspect-ratio: 1; border-radius: 8px; border: 1px solid transparent;
  background: var(--card); display: flex; flex-direction: column; align-items: center;
  justify-content: center; font-size: 13px; color: var(--text); cursor: pointer;
  gap: 2px; }
.cal-cell.empty { background: none; cursor: default; }
.cal-cell.today { border-color: var(--brand); font-weight: 700; }
.cal-cell.selected { background: var(--brand-soft); }
.cal-dots { display: flex; gap: 2px; height: 6px; }
.cal-dots span { width: 5px; height: 5px; border-radius: 50%; }
.dot-event { background: var(--accent); }
.dot-due { background: var(--danger); }
.dot-note { background: #999; }
.cal-day-detail { margin-top: 14px; }
.cal-day-detail h3 { font-size: 14px; color: var(--brand); margin-bottom: 6px; }
#cal-notes-toggle { margin-top: 10px; }

/* ---------- 반응형: 데스크톱 좌측 사이드바 (>=900px) ---------- */
@media (min-width: 900px) {
  nav { position: fixed; top: 0; bottom: 0; left: 0; right: auto; width: 220px;
    flex-direction: column; align-items: stretch; border-top: none;
    border-right: 1px solid var(--border); padding: 0; }
  .nav-brand { display: block; font-size: 15px; font-weight: 700; color: var(--brand);
    padding: 18px 20px; }
  nav button { flex: none; flex-direction: row; justify-content: flex-start;
    gap: 10px; padding: 10px 20px; font-size: 14px; border-radius: 0; }
  nav button .nav-icon { font-size: 16px; }
  nav button .nav-label { font-size: 14px; }
  nav button.active { background: var(--brand-soft); }
  nav button.active::before { top: 0; bottom: 0; left: 0; right: auto;
    width: 3px; height: auto; transform: none; border-radius: 0; }
  .app-body { margin-left: 220px; }
  main { max-width: 760px; margin: 0 auto; padding: 24px 24px 48px; }
  header { padding: 14px 24px; }
}
