/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 13px;
  color: #111;
  background: #fff;
}
a { color: #111; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ──────────────────────────────────────────── */
#hdr {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
}

.burger {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #555;
  padding: 0 4px;
  font-family: inherit;
}

.logo {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-icon { font-size: 16px; }
.logo-text { font-size: 14px; font-weight: 600; color: #111; }

#search {
  flex: 1;
  max-width: 380px;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  background: #fafafa;
}
#search:focus { border-color: #555; background: #fff; }

.hdr-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
.hdr-user { font-size: 12px; color: #555; }
.logout-btn {
  font-size: 12px;
  color: #888;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.logout-btn:hover { color: #111; }

/* ── Tabs ────────────────────────────────────────────── */
#tabs-bar {
  position: sticky;
  top: 42px;
  z-index: 19;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}
#tabs {
  padding: 7px 16px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  border: 1px solid #d4d4d4;
  background: #f7f7f7;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background .12s, border-color .12s, color .12s;
  line-height: 1.4;
}
.tab-btn:hover:not(.active) { background: #eee; }
.tab-btn.active { background: #111; color: #fff; border-color: #111; }

/* ── Content ─────────────────────────────────────────── */
#content {
  padding: 20px 16px 60px;
  max-width: 860px;
  margin: 0 auto;
}

.loading {
  color: #888;
  padding: 40px 0;
  text-align: center;
}
.empty {
  color: #888;
  padding: 40px 0;
  text-align: center;
  font-size: 13px;
}
.error { color: #c0392b; padding: 20px 0; }

/* ── Page header ─────────────────────────────────────── */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 18px; font-weight: 600; }
.page-header p  { font-size: 13px; color: #666; margin-top: 4px; }

/* ── Stats row ───────────────────────────────────────── */
.stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.stat-card {
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 14px 20px;
  min-width: 100px;
  text-align: center;
  background: #fafafa;
}
.stat-num { font-size: 24px; font-weight: 600; color: #111; }
.stat-label { font-size: 11px; color: #888; margin-top: 2px; }

/* ── Index grid ──────────────────────────────────────── */
.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.index-section {
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 16px;
}
.index-section h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #666;
  margin-bottom: 10px;
}
.index-section ul { list-style: none; }
.index-section li { padding: 4px 0; border-bottom: 1px solid #f0f0f0; }
.index-section li:last-child { border-bottom: none; }
.index-section a { font-size: 13px; color: #111; }
.index-section a:hover { color: #2d6a4f; }

/* ── Timeline ────────────────────────────────────────── */
.timeline-section { margin-top: 4px; }
.timeline-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.timeline-hdr h2 { font-size: 14px; font-weight: 600; margin: 0; }
.tl-group { margin-bottom: 20px; }
.tl-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 10px;
}
.tl-group-label.upcoming { background: #e7f5e9; color: #166534; }
.tl-group-label.past     { background: #f5f5f5; color: #888; }
.tl-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #f2f2f2;
}
.tl-item:last-child { border-bottom: none; }
.tl-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}
.dot-past     { background: #d1d5db; }
.dot-meeting  { background: #3b82f6; }
.dot-zoom     { background: #8b5cf6; }
.dot-deadline { background: #ef4444; }
.dot-other    { background: #9ca3af; }
.tl-body { flex: 1; min-width: 0; }
.tl-title { font-size: 13px; font-weight: 500; }
.tl-past .tl-title { color: #999; }
.tl-date  { font-size: 11px; color: #bbb; margin-top: 2px; }
.tl-past .tl-date { color: #ccc; }
.tl-del {
  background: none; border: none; color: #ddd;
  cursor: pointer; font-size: 17px; padding: 0 4px; line-height: 1;
}
.tl-del:hover { color: #999; }
.add-event-form {
  background: #f9f9f9;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.form-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.form-row:last-child { margin-bottom: 0; }
.form-input {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #fff;
}
.form-input:focus { border-color: #888; }
.form-input-wide { flex: 1; min-width: 160px; }

/* ── Meetings list ───────────────────────────────────── */
.meetings-list { display: flex; flex-direction: column; gap: 8px; }
.meeting-item {
  padding: 12px 14px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  cursor: pointer;
  transition: background .1s;
}
.meeting-item:hover { background: #f8f8f8; }
.meeting-item-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.meeting-date { font-weight: 600; font-size: 13px; }
.meeting-preview-line { color: #666; font-size: 12px; margin: 0; }
.meeting-arrow { color: #bbb; font-size: 13px; }

/* Meeting structure outline */
.meeting-structure {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid #f0f0f0;
  padding-left: 10px;
}
.meeting-structure li {
  font-size: 12px;
  color: #555;
  padding: 2px 0;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ms-h2 { font-weight: 500; color: #333; }
.ms-h3 { padding-left: 12px; color: #777; }
.ms-h4 { padding-left: 24px; color: #999; font-size: 11px; }

/* ── Back link ───────────────────────────────────────── */
.back-link { margin-bottom: 12px; }
.back-link a { font-size: 12px; color: #666; }
.back-link a:hover { color: #111; }

/* ── Markdown content ────────────────────────────────── */
.markdown-content {
  line-height: 1.7;
  font-size: 14px;
}
.markdown-content h1 { font-size: 20px; margin: 0 0 16px; }
.markdown-content h2 { font-size: 16px; margin: 24px 0 10px; padding-bottom: 6px; border-bottom: 1px solid #eee; }
.markdown-content h3 { font-size: 14px; margin: 18px 0 8px; }
.markdown-content p  { margin: 0 0 12px; }
.markdown-content ul, .markdown-content ol { margin: 0 0 12px 20px; }
.markdown-content li { margin: 4px 0; }
.markdown-content blockquote { border-left: 3px solid #ddd; padding-left: 14px; color: #666; margin: 12px 0; }
.markdown-content code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; font-size: 12px; font-family: 'SF Mono', 'Fira Code', monospace; }
.markdown-content pre { background: #f3f4f6; padding: 12px; border-radius: 4px; overflow-x: auto; margin: 12px 0; }
.markdown-content pre code { background: none; padding: 0; }
.markdown-content table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
.markdown-content th { background: #f7f7f7; padding: 7px 10px; border: 1px solid #e0e0e0; text-align: left; }
.markdown-content td { padding: 6px 10px; border: 1px solid #e0e0e0; }
.markdown-content strong { font-weight: 600; }

/* Text selection highlight */
.selectable ::selection { background: #d1fae5; }

/* ── Section notes ────────────────────────────────────── */
.section-notes { margin-top: 32px; padding-top: 20px; border-top: 1px solid #e0e0e0; }
.section-notes h3 { font-size: 13px; font-weight: 600; margin-bottom: 12px; color: #555; }

/* ── Notes list ──────────────────────────────────────── */
.notes-list { display: flex; flex-direction: column; gap: 10px; }

.note-card {
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 12px 14px;
  background: #fafafa;
}
.note-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.note-author {
  font-weight: 600;
  font-size: 12px;
  background: #111;
  color: #fff;
  padding: 1px 7px;
  border-radius: 999px;
}
.note-section {
  font-size: 11px;
  color: #888;
  background: #f0f0f0;
  padding: 1px 7px;
  border-radius: 999px;
}
.note-date { font-size: 11px; color: #aaa; }
.note-del {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: #ccc;
  font-size: 16px;
  padding: 0;
  line-height: 1;
  font-family: inherit;
}
.note-del:hover { color: #c0392b; }
.note-ref {
  font-size: 12px;
  color: #888;
  font-style: italic;
  border-left: 2px solid #d1fae5;
  padding-left: 8px;
  margin-bottom: 6px;
  line-height: 1.5;
}
.note-text { font-size: 13px; line-height: 1.5; white-space: pre-wrap; }

/* ── Calculator ──────────────────────────────────────── */
.calc-container { max-width: 700px; }
.calc-section {
  margin-bottom: 24px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  overflow: hidden;
}
.calc-section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f7f7f7;
  border-bottom: 1px solid #e5e5e5;
}
.calc-section-hdr h3 { font-size: 13px; font-weight: 600; }
.btn-sm {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
}
.btn-sm:hover { background: #f0f0f0; }
.calc-table { width: 100%; border-collapse: collapse; }
.calc-table th {
  font-size: 11px;
  font-weight: 600;
  color: #888;
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid #eee;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.calc-table td { padding: 6px 6px; border-bottom: 1px solid #f5f5f5; vertical-align: middle; }
.calc-table tr:last-child td { border-bottom: none; }
.calc-input-text {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 4px 6px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  outline: none;
}
.calc-input-text:focus { border-color: #ccc; background: #fff; }
.calc-input-num {
  width: 80px;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 4px 6px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  outline: none;
  text-align: right;
}
.calc-input-num:focus { border-color: #ccc; background: #fff; }
.calc-sum { text-align: right; padding-right: 10px; font-size: 13px; color: #444; white-space: nowrap; }
.calc-del {
  background: none;
  border: none;
  color: #ccc;
  font-size: 16px;
  cursor: pointer;
  padding: 0 6px;
  font-family: inherit;
  line-height: 1;
}
.calc-del:hover { color: #c0392b; }
.calc-subtotal {
  padding: 8px 14px;
  font-size: 12px;
  color: #555;
  border-top: 1px solid #eee;
  text-align: right;
  background: #fafafa;
}
.calc-balance {
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafafa;
  margin-bottom: 16px;
}
.balance-label { font-size: 13px; font-weight: 600; color: #555; }
.balance-value { font-size: 22px; font-weight: 700; }
.calc-actions { display: flex; gap: 8px; }
.btn {
  padding: 8px 16px;
  background: #111;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: #333; }
.btn-secondary {
  padding: 8px 16px;
  background: #fff;
  color: #111;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn-secondary:hover { background: #f5f5f5; }

/* ── Search results ──────────────────────────────────── */
.search-results { display: flex; flex-direction: column; gap: 8px; }
.search-result {
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background .1s;
}
.search-result:hover { background: #f8f8f8; }
.result-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.result-excerpt { font-size: 12px; color: #666; line-height: 1.5; }

/* ── Note tooltip ────────────────────────────────────── */
.note-tooltip {
  position: absolute;
  background: #111;
  color: #fff;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  z-index: 1000;
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: all;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.note-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #111;
}

/* ── Modal ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
.modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-hdr h3 { font-size: 14px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #888;
  padding: 0;
  font-family: inherit;
  line-height: 1;
}
.modal-close:hover { color: #111; }
.modal-ref {
  font-size: 12px;
  color: #888;
  font-style: italic;
  border-left: 3px solid #d1fae5;
  padding: 6px 10px;
  margin-bottom: 12px;
  background: #f9fffe;
  border-radius: 0 4px 4px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.modal textarea {
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  line-height: 1.5;
}
.modal textarea:focus { border-color: #555; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* ── Toast ───────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 20px;
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  animation: fadein .2s ease;
}
@keyframes fadein { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

/* ── Mobile ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .burger { display: block; }
  .logo-text { display: none; }
  #search { max-width: none; }
  .hdr-user { display: none; }
  .meeting-date { width: auto; }
  .meeting-preview { display: none; }
  .stats-row { gap: 8px; }
  .stat-card { padding: 10px 14px; }
  .calc-input-num { width: 60px; }
}

@media print {
  #hdr, #tabs-bar, .calc-actions { display: none !important; }
  #content { padding: 0; }
}
