/* LLMemory web app (vault) — Halo design system.
   Tokens, fonts, and shared atoms come from assets/brand.css; this file is the
   3-pane vault layout (sidebar · list · reader) plus the copy toast. */

html, body { height: 100%; }
body { overflow: hidden; }
.app { height: 100vh; display: flex; font-family: var(--font); color: var(--text); background: var(--bg); }

/* ============ SIDEBAR ============ */
.side { width: 258px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.side-top { padding: 16px 16px 6px; }
.skbtn { margin: 8px 12px 0; display: flex; align-items: center; gap: 9px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 9px 12px; color: var(--text-3); font-size: 13px; cursor: text; transition: .14s; }
.skbtn:hover, .skbtn:focus-within { border-color: var(--border-strong); }
.skbtn .ic { font-size: 14px; }
.skbtn input { flex: 1; min-width: 0; border: none; background: none; outline: none; font-family: var(--font); font-size: 13px; color: var(--text); }
.skbtn input::placeholder { color: var(--text-3); }
.skbtn .k { margin-left: auto; font-family: var(--mono); font-size: 10.5px; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; color: var(--text-3); }
.nav { padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 2px; }
#navSources { padding-top: 0; }
.navitem { display: flex; align-items: center; gap: 11px; padding: 8px 11px; border-radius: 10px; font-size: 13.5px; font-weight: 500; color: var(--text-2); cursor: pointer; transition: .13s; white-space: nowrap; }
.navitem .label { overflow: hidden; text-overflow: ellipsis; }
.navitem:hover { background: var(--surface-2); color: var(--text); }
.navitem.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.navitem svg { width: 17px; height: 17px; flex-shrink: 0; }
.navitem .ct { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.navitem.on .ct { color: var(--accent-text); }
.seclbl { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); padding: 16px 16px 7px; }
.side-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.side-foot { border-top: 1px solid var(--border); padding: 12px; }
.storage { padding: 6px 8px 10px; }
.storage .lab { font-size: 11px; color: var(--text-3); display: flex; justify-content: space-between; margin-bottom: 6px; white-space: nowrap; gap: 8px; }
.bar { height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.acct { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; }
.acct:hover { background: var(--surface-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; }
.acct .who { flex: 1; min-width: 0; }
.acct .nm { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct .em { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct .connect { margin-left: auto; }
.connect-choices { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.connect-choices .act { width: 100%; justify-content: center; }
.tt { display: flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 2px; margin-left: auto; flex-shrink: 0; }
.tt button { width: 26px; height: 24px; border: none; background: none; border-radius: 99px; cursor: pointer; color: var(--text-3); font-size: 12px; }
.tt button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* ============ LIST ============ */
.list { width: 362px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.list-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.lh-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lh-top h1 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; margin: 0; }
.lh-top .n { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.sortrow { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.seg button { font-family: var(--font); font-weight: 600; font-size: 12px; color: var(--text-3); background: none; border: none; border-radius: 7px; padding: 5px 11px; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.list-scroll { flex: 1; overflow-y: auto; padding: 6px 10px 16px; min-height: 0; }
.day { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 12px 8px 6px; }
.row { display: flex; gap: 11px; padding: 11px 11px; border-radius: 12px; cursor: pointer; position: relative; }
.row:hover { background: var(--surface-2); }
.row.sel { background: var(--accent-soft); }
.row.sel::before { content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px; border-radius: 3px; background: var(--accent); }
.row .dot { margin-top: 5px; }
.row .c { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row .t { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.sel .t { color: var(--accent-text); }
.row .mt { font-size: 11px; color: var(--text-3); margin-top: 5px; display: flex; align-items: center; gap: 7px; }

/* ============ READER ============ */
.reader { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.rd-head { padding: 20px 30px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.rd-top { display: flex; align-items: center; gap: 11px; }
.rd-title { font-size: 20px; font-weight: 700; letter-spacing: -.015em; flex: 1; min-width: 0; margin: 0; }
.rd-meta { font-size: 12.5px; color: var(--text-3); margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rd-meta .sep { opacity: .5; }
.rd-actions { display: flex; align-items: center; gap: 8px; margin-top: 15px; flex-wrap: wrap; }
.act { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font); font-weight: 600; font-size: 12.5px; padding: 8px 13px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; transition: .15s; white-space: nowrap; }
.act:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-2); }
.act.primary { background: var(--accent); border-color: transparent; color: #fff; box-shadow: var(--shadow-accent); }
.act.primary:hover { background: var(--accent-hover); color: #fff; }
.act.icon { padding: 8px; }
.act .star-on { color: var(--warn); }
.rd-spacer { flex: 1; }
.rd-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.rd-inner { max-width: 760px; margin: 0 auto; padding: 10px 30px 60px; }
.turn { padding: 20px 0; display: flex; gap: 15px; }
.turn + .turn { border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent); }
.turn .body { min-width: 0; flex: 1; }
.av { width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; }
.av.you { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.av.tool { background: var(--surface-3); color: var(--text-2); }
.who { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.when { font-size: 11px; color: var(--text-3); font-weight: 500; white-space: nowrap; }
.content { font-size: 14.5px; line-height: 1.64; color: var(--text); margin-top: 7px; overflow-wrap: anywhere; }
.content p { margin: 0 0 11px; } .content p:last-child { margin-bottom: 0; }
.content code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.content pre.codeblock { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 14px 16px; margin: 8px 0 12px; overflow-x: auto; white-space: pre; }
.content pre.codeblock code { background: none; border: none; padding: 0; }
.content ul { margin: 5px 0 11px; padding-left: 20px; } .content li { margin: 4px 0; }

/* states */
.empty, .loading { color: var(--text-3); font-size: 13.5px; padding: 16px; line-height: 1.55; }
.rd-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; color: var(--text-3); gap: 14px; padding: 40px; }
.rd-empty .ic { opacity: .5; }
.rd-empty code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; color: var(--text-2); }

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text); color: var(--bg);
  border-radius: 10px; padding: 9px 16px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease; z-index: 50;
  display: flex; align-items: center; gap: 8px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast .tick { color: var(--live); }

/* ============ SETTINGS MODAL ============ */
.acct { position: relative; }
.acct .gear { margin-left: 6px; color: var(--text-3); font-size: 14px; opacity: 0; transition: .14s; }
.acct:hover .gear { opacity: 1; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in srgb, #0b0d12 52%, transparent);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: 100%; max-width: 560px; max-height: 86vh;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; min-height: 0;
  animation: modalIn .16s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.modal-x { width: 30px; height: 30px; border: none; background: var(--surface-2); border-radius: 8px; color: var(--text-2); cursor: pointer; font-size: 13px; }
.modal-x:hover { background: var(--surface-3); color: var(--text); }
.modal-body { padding: 8px 22px 22px; overflow-y: auto; min-height: 0; }

.set-sec { padding: 18px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.set-sec:last-child { border-bottom: none; }
.set-sec > h3 { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); margin: 0 0 12px; }
.set-sec .hint { font-size: 12px; color: var(--text-3); line-height: 1.5; margin: 0 0 12px; }

/* storage backend rows */
.store-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; }
.store-row.active { border-color: var(--accent); background: var(--accent-soft); }
.store-row .si { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.store-row .si svg { width: 19px; height: 19px; }
.store-row .meta { flex: 1; min-width: 0; }
.store-row .meta .nm { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.store-row .meta .st { font-size: 11.5px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-row .badge-on { font-size: 10px; font-weight: 700; color: var(--live); background: color-mix(in srgb, var(--live) 14%, transparent); border-radius: 99px; padding: 2px 7px; text-transform: uppercase; letter-spacing: .04em; }
.store-row .actions { display: flex; gap: 6px; flex-shrink: 0; }
.set-btn { font-family: var(--font); font-weight: 600; font-size: 12px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; white-space: nowrap; transition: .14s; }
.set-btn:hover { border-color: var(--border-strong); color: var(--text); }
.set-btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.set-btn.primary:hover { background: var(--accent-hover); color: #fff; }
.set-btn.danger { color: var(--danger, #d64545); border-color: color-mix(in srgb, var(--danger, #d64545) 35%, var(--border)); }
.set-btn.danger:hover { background: color-mix(in srgb, var(--danger, #d64545) 10%, transparent); }
.set-btn:disabled { opacity: .5; cursor: default; }

/* stub / coming-soon */
.soon-list { display: flex; flex-direction: column; gap: 9px; }
.soon-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--text-2); }
.soon-item .tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }

/* advanced disclosure */
.set-adv { padding-top: 4px; }
.set-adv > summary { cursor: pointer; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); list-style: none; display: flex; align-items: center; gap: 7px; padding: 14px 0 6px; }
.set-adv > summary::-webkit-details-marker { display: none; }
.set-adv > summary::before { content: "\25b8"; font-size: 9px; transition: transform .15s; }
.set-adv[open] > summary::before { transform: rotate(90deg); }

/* danger zone */
.danger-zone { border: 1px solid color-mix(in srgb, var(--danger, #d64545) 30%, var(--border)); border-radius: 12px; padding: 14px; }
.danger-zone .dz-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.danger-zone .dz-row .nm { font-size: 13px; font-weight: 600; }
.danger-zone .dz-row .ds { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

@media (max-width: 1024px) { .list { width: 322px; } }
@media (max-width: 860px) {
  .side { width: 64px; }
  .side .label, .side .seclbl, .side .skbtn input, .side .skbtn .k, .side .storage, .side .acct .who, .side .navitem .ct { display: none; }
  .side .skbtn { justify-content: center; }
  .side .navitem { justify-content: center; }
  .side .acct .tt { margin-left: 0; }
}
@media (max-width: 760px) { .list { width: 280px; } }
