:root {
  --ink: #070b10;
  --panel: #121b24;
  --line: rgba(180, 220, 210, 0.12);
  --mist: #d7e6e1;
  --muted: #8aa39a;
  --accent: #3ecfac;
  --accent-2: #e8b86d;
  --danger: #ff7b72;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--mist);
}

body {
  font-family: "Pretendard", "Noto Sans KR", sans-serif;
  background:
    radial-gradient(900px 500px at 0% 0%, rgba(62, 207, 172, 0.10), transparent 55%),
    radial-gradient(700px 400px at 100% 0%, rgba(232, 184, 109, 0.07), transparent 50%),
    #070b10;
  overflow: hidden;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.035;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.brand-font {
  font-family: "Gowun Dodum", "Pretendard", sans-serif;
  letter-spacing: -0.03em;
}

.fade-up { animation: fadeUp 0.5s ease both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-enter { animation: msgIn 0.25s ease both; }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

body.live #connectBtn {
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(62, 207, 172, 0.35); }
  70% { box-shadow: 0 0 0 12px rgba(62, 207, 172, 0); }
  100% { box-shadow: 0 0 0 0 rgba(62, 207, 172, 0); }
}

.composer:focus-within {
  border-color: rgba(62, 207, 172, 0.45);
  box-shadow: 0 0 0 3px rgba(62, 207, 172, 0.1);
}

.composer {
  flex-wrap: nowrap;
}

@media (max-width: 480px) {
  .composer #connectBtn,
  .composer #disconnectBtn {
    padding-left: 0.7rem;
    padding-right: 0.7rem;
    font-size: 12px;
  }
}

.scroll-thin::-webkit-scrollbar { width: 7px; }
.scroll-thin::-webkit-scrollbar-thumb {
  background: rgba(138, 163, 154, 0.3);
  border-radius: 999px;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--mist);
  border-radius: 0.55rem;
  padding: 0.35rem 0.45rem;
  cursor: pointer;
}
.tree-item:hover { background: rgba(62, 207, 172, 0.08); }
.tree-file.active {
  background: rgba(62, 207, 172, 0.16);
  color: var(--accent);
}
.tree-folder { list-style: none; }
.tree-dir > summary { list-style: none; }
.tree-dir > summary::-webkit-details-marker { display: none; }
.tree-ico { font-size: 0.85rem; opacity: 0.85; }
.tree-alias {
  margin-left: auto;
  font-size: 10px;
  color: var(--muted);
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-body {
  line-height: 1.7;
  font-size: 0.95rem;
  color: #eceff4;
  /* Obsidian Things theme accents */
  --things-pink: #ff82b2;
  --things-strong: #ff82b2;
  --things-em: #ff82b2;
}
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  font-family: "Gowun Dodum", "Pretendard", sans-serif;
  letter-spacing: -0.02em;
  margin: 1.2em 0 0.45em;
  line-height: 1.25;
  color: #ffffff;
}
.md-body h1 { font-size: 1.7rem; }
.md-body h2 { font-size: 1.35rem; }
.md-body h3 { font-size: 1.1rem; }
.md-body p { margin: 0.55em 0; }
.md-body br { display: block; content: ""; margin: 0; }

/* Things: bold / italic in pink */
.md-body strong,
.md-body b {
  color: var(--things-strong);
  font-weight: 700;
}
.md-body em,
.md-body i {
  color: var(--things-em);
  font-style: italic;
}
.md-body strong em,
.md-body em strong,
.md-body b i,
.md-body i b {
  color: var(--things-pink);
}

.md-body a { color: #7ec8ff; text-decoration: underline; text-underline-offset: 2px; }
.md-body ul, .md-body ol { padding-left: 1.25rem; margin: 0.6em 0; }
.md-body li { margin: 0.25em 0; }
.md-body blockquote {
  margin: 0.8em 0;
  padding: 0.2em 0 0.2em 0.9em;
  border-left: 3px solid var(--things-pink);
  color: #b8c0cc;
}
.md-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: rgba(18, 27, 36, 0.9);
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  padding: 0.1em 0.35em;
  color: #ff98a4;
}
.md-body pre {
  background: rgba(18, 27, 36, 0.95);
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  padding: 0.9rem 1rem;
  overflow-x: auto;
}
.md-body pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
}
.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.9em;
}
.md-body th, .md-body td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.6rem;
}
.md-body th { background: rgba(18, 27, 36, 0.8); }
.md-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.4em 0;
}
.md-body mark {
  background: rgba(255, 130, 178, 0.25);
  color: inherit;
  padding: 0.05em 0.2em;
  border-radius: 0.2em;
}

/* Side tabs */
.side-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  border-radius: 0.7rem;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
}
.side-tab:hover { color: var(--mist); background: rgba(62, 207, 172, 0.06); }
.side-tab.active {
  color: var(--accent);
  background: rgba(62, 207, 172, 0.12);
  border-color: rgba(62, 207, 172, 0.25);
}

.session-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--mist);
  border-radius: 0.7rem;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
}
.session-item:hover { background: rgba(62, 207, 172, 0.08); }
.session-item.active {
  background: rgba(62, 207, 172, 0.14);
  border-color: rgba(62, 207, 172, 0.22);
}
.session-item .s-title {
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.session-item .s-meta {
  margin-top: 0.2rem;
  font-size: 10px;
  color: var(--muted);
}
.session-item-row {
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
}
.session-del {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  padding: 0.35rem 0.4rem;
  border-radius: 0.4rem;
  cursor: pointer;
  opacity: 0.55;
}
.session-del:hover { opacity: 1; color: var(--danger); background: rgba(255,123,114,0.1); }

.vault-path-link {
  display: inline;
  color: #7ec8ff;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
}
.vault-path-link:hover { color: #a8dbff; }

.hit-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}
.hit-chip {
  border: 1px solid rgba(126, 200, 255, 0.35);
  background: rgba(126, 200, 255, 0.08);
  color: #b9dffc;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 11px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hit-chip:hover { background: rgba(126, 200, 255, 0.16); }

/* Note modal */
.note-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.note-modal.hidden { display: none; }
.note-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 10, 0.72);
  backdrop-filter: blur(4px);
}
.note-modal-panel {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: min(88dvh, 900px);
  display: flex;
  flex-direction: column;
  background: #0d141c;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.note-modal-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 27, 36, 0.65);
}
.note-modal-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 0.55rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--mist);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.note-modal-close:hover { background: rgba(255,255,255,0.05); }
.note-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1.25rem 1.5rem;
}

#messages {
  scroll-behavior: smooth;
}
#messages .msg-bubble {
  max-width: min(720px, 92%);
}

@media (max-width: 767px) {
  .tree-panel.flex {
    position: absolute;
    z-index: 30;
    inset: 48px auto 0 0;
    height: calc(100dvh - 48px);
    background: rgba(7, 11, 16, 0.96);
  }
}
