/* ============ Notal AI — Claude-inspired design system ============ */
:root {
  --bg: #f5f1ea;
  --surface: #faf9f7;
  --surface-2: #f0eee9;
  --sidebar-bg: #f0eee6;
  --text: #1f1e1d;
  --text-soft: #5e5d59;
  --text-faint: #8d8b84;
  --accent: #d97757;
  --accent-soft: #f6e5dd;
  --border: #e3dfd6;
  --user-bubble: #f0eee6;
  --shadow: 0 1px 2px rgba(31, 30, 29, .05), 0 8px 24px rgba(31, 30, 29, .06);
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #262624;
  --surface: #30302e;
  --surface-2: #3a3a37;
  --sidebar-bg: #1f1e1d;
  --text: #e8e6e3;
  --text-soft: #b4b1a9;
  --text-faint: #83817a;
  --accent: #d97757;
  --accent-soft: #4a362e;
  --border: #3d3c39;
  --user-bubble: #3a3a37;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }

.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 268px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  transition: margin-left .25s ease;
}
.sidebar.collapsed { margin-left: -269px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 12px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
}
.brand-logo {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--text); color: var(--bg);
}
.brand-name { font-family: var(--sans); font-size: 17px; font-weight: 600; letter-spacing: -.2px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  color: var(--text-soft);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.sidebar-nav { padding: 4px 10px 10px; display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px;
  color: var(--text-soft); font-weight: 500; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.05); }

.new-chat-wrap { padding: 4px 16px 14px; display: grid; gap: 10px; }
.new-chat-btn {
  display: flex; align-items: center; gap: 9px;
  background: var(--accent); color: #fff;
  padding: 9px 14px; border-radius: 10px; font-weight: 600; font-size: 14px;
  box-shadow: 0 1px 2px rgba(217, 119, 87, .4);
  transition: filter .15s, transform .1s;
}
.new-chat-btn:hover { filter: brightness(1.06); }
.new-chat-btn:active { transform: translateY(1px); }

.search-wrap { position: relative; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.search-wrap input {
  width: 100%; padding: 8px 12px 8px 34px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  outline: none; font-size: 13.5px;
}
.search-wrap input::placeholder { color: var(--text-faint); }
.search-wrap input:focus { border-color: var(--accent); }

.history { flex: 1; overflow-y: auto; padding: 2px 10px 12px; }
.history-label {
  font-size: 11.5px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase;
  color: var(--text-faint); padding: 8px 10px 6px;
}
.history-list { list-style: none; display: grid; gap: 1px; }
.history-item {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 9px;
  color: var(--text-soft); font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .15s, color .15s;
}
.history-item:hover { background: var(--surface-2); color: var(--text); }
.history-item.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.history-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.history-empty { padding: 10px; color: var(--text-faint); font-size: 13px; }

.sidebar-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 12px 12px 14px; border-top: 1px solid var(--border);
}
.signin-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13.5px; font-weight: 600; color: var(--text);
  transition: border-color .15s, background .15s;
}
.signin-btn:hover { border-color: var(--text-faint); }
.signin-btn.signed-in svg { display: none; }

/* account popover */
.account-wrap { position: relative; }
.signin-btn.open { border-color: var(--text-faint); background: var(--surface-2); }
.account-menu {
  position: absolute; left: 0; bottom: calc(100% + 10px);
  width: 250px; padding: 8px; z-index: 60;
  max-height: calc(100vh - 80px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 18px 44px rgba(0,0,0,.22);
  display: grid; gap: 4px;
  animation: popin .13s ease;
}
.account-menu[hidden] { display: none; }
@keyframes popin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.am-profile { display: flex; align-items: center; gap: 11px; padding: 8px 8px 10px; min-width: 0; }
.am-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-family: var(--serif); font-size: 17px; font-weight: 600;
}
.am-avatar img { width: 100%; height: 100%; object-fit: cover; }
.am-names { display: grid; gap: 1px; min-width: 0; }
.am-name { font-family: var(--serif); font-size: 16px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-sub { color: var(--text-faint); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-soft);
}
.am-divider { height: 1px; background: var(--border); margin: 4px 2px; }
.am-item {
  display: flex; align-items: center; gap: 9px; text-align: left;
  padding: 9px 10px; border-radius: 10px; font-size: 13px; font-weight: 500; color: var(--text-soft);
  transition: background .15s, color .15s;
}
.am-item:hover { background: var(--surface-2); color: var(--text); }
.am-item.danger:hover { color: #c0392b; }
.am-item:disabled { opacity: .5; cursor: default; }

/* settings modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 19, 18, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadein .15s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(660px, 100%); max-height: 84vh;
  display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .25);
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.modal-body { display: flex; overflow-y: auto; }
.settings-nav {
  width: 150px; flex-shrink: 0;
  padding: 12px 10px; border-right: 1px solid var(--border);
  display: grid; gap: 2px; align-content: start;
}
.settings-tab {
  text-align: left; padding: 9px 12px; border-radius: 9px;
  font-size: 13.5px; font-weight: 500; color: var(--text-soft);
  transition: background .15s, color .15s;
}
.settings-tab:hover { background: var(--surface-2); color: var(--text); }
.settings-tab.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.settings-panels { flex: 1; padding: 10px 22px 22px; min-width: 0; }
.settings-panel[hidden] { display: none; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 2px; border-bottom: 1px solid var(--border);
}
.setting-info { display: grid; gap: 2px; }
.setting-row.stack { flex-direction: column; align-items: stretch; gap: 10px; }
.relay-line { display: flex; gap: 8px; align-items: center; }
.relay-line .text-input { flex: 1; min-width: 0; }
.setting-name { font-size: 14px; font-weight: 600; }
.setting-info small { color: var(--text-faint); font-size: 12.5px; }
.seg {
  display: inline-flex; padding: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}
.seg button { padding: 5px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.seg button.active { background: var(--text); color: var(--bg); }
.danger-btn {
  padding: 7px 13px; border-radius: 9px; font-size: 13px; font-weight: 600;
  color: #c0392b; border: 1px solid var(--border); background: var(--surface);
}
.danger-btn:hover { border-color: #c0392b; }
.text-input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); outline: none; font-size: 13.5px; width: 180px;
}
.text-input:focus { border-color: var(--accent); }
.badge {
  font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}

/* providers */
.panel-note { font-size: 13px; color: var(--text-soft); margin: 8px 0 14px; }
.provider-list { list-style: none; display: grid; gap: 8px; margin-bottom: 16px; }
.provider-list:empty { margin-bottom: 0; }
.provider-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.pi-meta { flex: 1; display: grid; gap: 1px; min-width: 0; }
.pi-meta span { font-size: 13.5px; font-weight: 600; }
.pi-meta small { color: var(--text-faint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-del { flex-shrink: 0; }
.provider-form {
  display: grid; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px;
}
.pf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pf-grid label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-soft); }
.pf-grid input, .pf-grid select {
  padding: 8px 10px; font-size: 13.5px; font-weight: 400; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 9px; outline: none;
  min-width: 0;
}
.pf-grid input:focus, .pf-grid select:focus { border-color: var(--accent); }
.pf-actions { display: flex; justify-content: flex-end; }
.primary-btn {
  padding: 8px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  background: var(--text); color: var(--bg);
}
.primary-btn:hover { filter: brightness(1.2); }

/* model menu extras */
.menu-divider { height: 1px; background: var(--border); margin: 5px 8px; }
.model-option.menu-add span { color: var(--text-soft); font-weight: 500; }

/* attachments */
.attach-tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 4px; }
.attach-tray[hidden] { display: none; }
.pend-att { position: relative; display: inline-flex; align-items: center; }
.pend-att img { width: 44px; height: 44px; object-fit: cover; border-radius: 9px; border: 1px solid var(--border); }
.pend-file {
  font-size: 12px; background: var(--surface-2); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 9px; max-width: 180px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pend-x {
  position: absolute; top: -6px; right: -6px; z-index: 1;
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--text); color: var(--bg); font-size: 9px;
}
.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 8px; }
.att-img {
  max-width: 220px; max-height: 160px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--border); cursor: zoom-in;
}
.att-file {
  font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 9px;
}
.msg-bubble:empty { display: none; }
.msg-error { color: #c0392b; }

/* mic */
.icon-btn.recording {
  color: #c0392b; background: rgba(192, 57, 43, .12);
  animation: pulse 1.3s infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(192, 57, 43, .1); } }

/* toast + lightbox */
.toast {
  position: fixed; bottom: 22px; left: 50%; z-index: 200;
  transform: translateX(-50%) translateY(10px);
  background: var(--text); color: var(--bg);
  font-size: 13px; padding: 9px 16px; border-radius: 999px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: min(480px, 90vw); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0, 0, 0, .78);
  display: flex; align-items: center; justify-content: center;
  padding: 30px; cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; }

/* account */
.auth-actions { display: flex; gap: 8px; align-items: center; }
button:disabled { opacity: .5; cursor: default; }
.user-photo { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }

/* ---------------- Main ---------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
}
.sidebar-open { display: none; }
.sidebar.collapsed ~ .main .sidebar-open,
body.sidebar-hidden .sidebar-open { display: inline-flex; }

.topbar-spacer { flex: 1; }
.chat-title { font-family: var(--serif); font-size: 16px; font-weight: 600; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 9px; font-size: 13.5px; font-weight: 600;
  color: var(--text-soft); border: 1px solid var(--border); background: var(--surface);
  transition: color .15s, border-color .15s;
}
.ghost-btn:hover { color: var(--text); border-color: var(--text-faint); }

/* ---------------- Chat ---------------- */
.chat { flex: 1; overflow-y: auto; scroll-behavior: smooth; }

.greeting {
  max-width: 720px; margin: 0 auto;
  padding: clamp(48px, 14vh, 120px) 24px 32px;
}
.greeting h1 {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(30px, 4.5vw, 42px); letter-spacing: -.3px;
}
.greeting h1 .accent-word { color: var(--accent); }
.greeting-sub { margin-top: 8px; color: var(--text-soft); font-size: 16px; }

.suggestions { margin-top: 34px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.suggestion {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 15px; text-align: left; font-size: 13.5px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-soft);
  transition: border-color .15s, color .15s, transform .1s, box-shadow .15s;
}
.suggestion:hover { border-color: var(--accent); color: var(--text); box-shadow: var(--shadow); }
.suggestion:active { transform: translateY(1px); }
.s-icon { color: var(--accent); font-size: 15px; }

.messages {
  max-width: 720px; margin: 0 auto;
  padding: 24px 24px 40px;
  display: grid; gap: 26px;
}

.msg { display: flex; gap: 13px; animation: rise .25s ease both; }
.msg.user { justify-content: flex-end; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.msg-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; margin-top: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 600;
}
.msg.assistant .msg-avatar { background: var(--accent); color: #fff; }

.msg-body { min-width: 0; flex: 1; }
.msg.user .msg-body { flex: 0 1 auto; max-width: 84%; }
.msg.user .msg-attachments { justify-content: flex-end; }
.msg-role { font-size: 12px; font-weight: 600; color: var(--text-faint); margin-bottom: 5px; letter-spacing: .3px; }
.msg-text { font-size: 15px; line-height: 1.7; word-wrap: break-word; }
.msg-text > * + * { margin-top: 12px; }
.msg-text p { margin: 0; }
.msg-text h3, .msg-text h4, .msg-text h5, .msg-text h6 {
  font-family: var(--serif); line-height: 1.35; margin: 20px 0 0; font-weight: 600;
}
.msg-text h3 { font-size: 19px; }
.msg-text h4 { font-size: 17px; }
.msg-text h5, .msg-text h6 { font-size: 15.5px; }
.msg-text ul, .msg-text ol { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.msg-text li { padding-left: 2px; }
.msg-text li::marker { color: var(--text-faint); }
.msg-text a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.msg-text code, .att-file code {
  font-family: var(--mono); font-size: .88em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px;
}
.msg-text pre {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 13px 15px; overflow-x: auto; line-height: 1.55;
}
.msg-text pre code { background: none; border: 0; padding: 0; font-size: 13px; }
.msg-text blockquote {
  margin: 0; padding: 2px 0 2px 14px; border-left: 2px solid var(--accent);
  color: var(--text-soft); display: grid; gap: 8px;
}
.msg-text hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

.msg.user .msg-bubble {
  background: var(--user-bubble); border: 1px solid var(--border);
  padding: 11px 16px; border-radius: 14px 4px 14px 14px;
  font-size: 15px; line-height: 1.7; white-space: pre-wrap; word-wrap: break-word;
  display: inline-block; max-width: 100%;
}

/* typing indicator */
.typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint);
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ---------------- Composer ---------------- */
.composer-wrap { padding: 8px 24px 14px; }
.composer {
  position: relative;
  max-width: 760px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 16px 16px 12px 20px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .15s;
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
  border: none; outline: none; background: transparent; resize: none;
  font-size: 15px; line-height: 1.55; max-height: 200px;
  padding: 2px 0 0; color: var(--text);
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; }
.composer-left, .composer-right { display: flex; align-items: center; gap: 4px; }
.char-count { font-size: 12px; color: var(--text-faint); margin-right: 6px; min-width: 12px; text-align: right; }
.send-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--text); color: var(--bg);
  transition: filter .15s, opacity .15s, transform .1s;
}
.send-btn:hover { filter: brightness(1.2); }
.send-btn:active { transform: scale(.95); }
.send-btn:disabled { opacity: .3; cursor: default; }
.fineprint { text-align: center; font-size: 11.5px; color: var(--text-faint); margin-top: 10px; }

/* model picker pill (inside composer) */
.model-picker {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; margin-right: 2px;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--text);
  transition: background .15s, border-color .15s;
}
.model-picker:hover { background: var(--surface-2); }
.model-picker.open { border-color: var(--text-faint); }
.mp-star { color: var(--text); }
.mp-chevron { transition: transform .18s; color: var(--text-soft); }
.model-picker.open .mp-chevron { transform: rotate(180deg); }
.model-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 30;
  min-width: 250px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow);
  display: grid; gap: 2px;
}
.model-menu[hidden] { display: none; }
.model-option {
  display: grid; gap: 2px; text-align: left; padding: 9px 11px; border-radius: 10px;
}
.model-option:hover { background: var(--surface-2); }
.model-option.selected span { color: var(--accent); }
.model-option span { font-weight: 600; font-size: 13.5px; }
.model-option small { color: var(--text-faint); font-size: 12px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 860px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; box-shadow: var(--shadow); }
  .sidebar.collapsed { margin-left: 0; transform: translateX(-100%); }
  .sidebar-open { display: inline-flex; }
  .suggestions { grid-template-columns: 1fr; }
}

::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- projects / memory / skills views ---------- */
.view {
  flex: 1; overflow-y: auto; padding: 26px 30px 40px;
  width: 100%; max-width: 980px; margin: 0 auto;
  display: grid; align-content: start; gap: 18px;
}
.view[hidden] { display: none; }
.view-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.view-header h1 { font-family: var(--serif); font-size: 26px; font-weight: 600; }
.view-sub { font-size: 13px; color: var(--text-soft); margin-top: 4px; max-width: 52ch; }
.inline-add { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-add input, .inline-add select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 13.5px; min-width: 160px;
}
.inline-add input:focus, .inline-add select:focus { outline: none; border-color: var(--accent); }
.empty-note { color: var(--text-faint); font-size: 13.5px; padding: 18px 4px; }

.card-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card {
  display: grid; gap: 8px; align-content: start;
  padding: 16px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface);
}
.card.active { border-color: var(--accent); }
.card h3 { font-family: var(--serif); font-size: 16px; font-weight: 600; }
.card small { color: var(--text-faint); font-size: 12px; }
.card-desc { font-size: 12.5px; color: var(--text-soft); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card > .ghost-btn, .card > .icon-btn { justify-self: start; }

.item-list { list-style: none; display: grid; gap: 8px; }
.mem-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface);
}
.mem-item.off .mem-body { opacity: .45; }
.mem-body { flex: 1; min-width: 0; font-size: 13.5px; }
.mem-body small { color: var(--text-faint); font-size: 11.5px; }

/* chat logo eyes */
.stare-logo .eyes {
  transform-box: fill-box; transform-origin: center;
  transition: transform .14s ease;
}
.stare-logo circle { transition: cx .13s ease-out, cy .13s ease-out; }

/* ---------- switch toggle ---------- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.sl.track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--border); transition: background .18s;
}
.sl.track::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  border-radius: 50%; background: #fff; transition: transform .18s;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.switch input:checked + .sl.track { background: var(--accent); }
.switch input:checked + .sl.track::before { transform: translateX(18px); }
.switch input:disabled + .sl.track { opacity: .45; cursor: not-allowed; }

/* ---------- shortcut list ---------- */
.shortcut-list { list-style: none; display: grid; gap: 8px; }
.shortcut-list li {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); font-size: 13.5px;
}
.shortcut-list li span { flex: 1; color: var(--text-soft); }
kbd {
  font-family: var(--mono, ui-monospace, monospace); font-size: 11.5px;
  padding: 2px 7px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); box-shadow: 0 1px 0 var(--border);
}

/* ---------- pin lock screen ---------- */
.lock-screen {
  position: fixed; inset: 0; z-index: 120;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px);
}
.lock-screen[hidden] { display: none; }
.lock-card {
  width: min(330px, 88vw); padding: 28px 26px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow, 0 18px 50px rgba(0,0,0,.16));
  display: grid; gap: 10px; justify-items: center;
}
.lock-logo {
  width: 44px; height: 44px; border-radius: 13px; background: var(--text);
  display: grid; place-items: center;
}
.lock-logo::after { content: ""; width: 0; height: 0; border-left: 11px solid transparent; border-right: 11px solid transparent; border-bottom: 16px solid var(--bg); }
.lock-card h2 { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.lock-hint { font-size: 13px; color: var(--text-soft); margin-top: -4px; }
.pin-input {
  width: 100%; text-align: center; letter-spacing: 6px; font-size: 18px;
  padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text);
}
.pin-input:focus { outline: none; border-color: var(--accent); }
.lock-card .primary-btn { width: 100%; justify-content: center; }
.lock-error { font-size: 12.5px; color: #c0392b; }
.lock-error[hidden] { display: none; }
