/* Muse interface — a one-to-one restyle of the Muse app.
   Bright, soft, quiet: near-white warm background, near-black text,
   monochrome chrome, and a single soft multicolor spark gradient
   reserved for the assistant's avatar. System fonts only. */
:root {
  --radius: 20px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 58px;
  --rail-w: 78px;
  --spark: linear-gradient(135deg, #FFD08A 0%, #FF9E7D 32%, #F97FB8 64%, #B79CFF 100%);
}
html[data-theme="light"] {
  --bg: #FCFCFA;
  --bg-soft: #F6F5F1;
  --surface: #FFFFFF;
  --surface-2: #F4F2EC;
  --border: #E9E6DD;
  --border-strong: #D8D4C7;
  --text: #1B1B18;
  --muted: #7C7A72;
  --accent: #23231F;
  --accent-soft: #EFEDE7;
  --on-accent: #FFFFFF;
  --user-bubble: #F1EFEA;
  --danger: #B3402A;
  --danger-dim: rgba(179, 64, 42, 0.35);
  --warn: #9A6B14;
  --ok: #3E7C43;
  --badge: #D64541;
  --shadow: 0 10px 34px rgba(27, 27, 24, 0.10);
  --shadow-soft: 0 2px 12px rgba(27, 27, 24, 0.055);
  --code: #F5F3EE;
  --tabbar-bg: rgba(255, 255, 255, 0.9);
}
html[data-theme="dark"] {
  --bg: #171512;
  --bg-soft: #1D1A16;
  --surface: #211E1A;
  --surface-2: #2A2620;
  --border: #37322A;
  --border-strong: #4A4436;
  --text: #F2F0E9;
  --muted: #A6A29A;
  --accent: #F0EEE7;
  --accent-soft: #2E2A24;
  --on-accent: #171512;
  --user-bubble: #2B2721;
  --danger: #E08A72;
  --danger-dim: rgba(224, 138, 114, 0.4);
  --warn: #D9A94F;
  --ok: #93C498;
  --badge: #E0655F;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 2px 12px rgba(0, 0, 0, 0.35);
  --code: #1B1915;
  --tabbar-bg: rgba(23, 21, 18, 0.9);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "SF Pro", Inter, "Segoe UI",
    Roboto, system-ui, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid rgba(140, 138, 128, 0.55); outline-offset: 1px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.spacer { flex: 1; }
.error { color: var(--danger); min-height: 1.2em; margin: 0.3em 0; font-size: 0.9rem; }
.error:empty, .ok-msg:empty { min-height: 0; margin: 0; }
.ok-msg { color: var(--ok); min-height: 1.2em; margin: 0.3em 0; font-size: 0.9rem; }
a { color: var(--accent); }

button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5em 1.05em;
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
button:hover { background: var(--surface-2); border-color: var(--border-strong); }
button.primary {
  background: var(--text); color: var(--bg);
  border: 1px solid var(--text); font-weight: 600;
}
button.primary:hover { opacity: 0.88; background: var(--text); }
button.big { padding: 0.75em 1.5em; font-size: 1rem; }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger-dim); }
button.link { background: none; border: none; color: var(--muted); padding: 0.3em 0.5em; }
button.link:hover { background: none; color: var(--text); }
button:disabled { opacity: 0.55; cursor: default; }
.small-btn { padding: 0.35em 0.85em; font-size: 0.88rem; }
.link-btn {
  display: inline-flex; align-items: center; gap: 0.4em;
  text-decoration: none; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 0.5em 1.05em; font-size: 0.95rem; cursor: pointer;
}
.link-btn:hover { background: var(--surface-2); }
a.primary.link-btn { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
a.small-btn.link-btn { padding: 0.35em 0.85em; font-size: 0.88rem; }
.file-label { display: inline-flex; align-items: center; cursor: pointer; }

input, textarea, select {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6em 0.8em;
  font: inherit;
  font-size: 0.98rem;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; line-height: 1.5; }
label { display: block; font-size: 0.92rem; font-weight: 600; margin-bottom: 0.9em; }
label input, label textarea, label select { margin-top: 0.35em; font-weight: 400; }
label.inline-label { display: inline-flex; align-items: center; gap: 0.5em; margin: 0; font-weight: 500; }
label.inline-label select { width: auto; }
.row { display: flex; gap: 0.6em; align-items: center; flex-wrap: wrap; }
.stack-form { display: block; }
.stack-form.wide, .narrow { max-width: 720px; }
.switch-row { display: flex; align-items: center; gap: 0.6em; font-weight: 500; cursor: pointer; }
.switch-row input { width: 1.15em; height: 1.15em; accent-color: var(--accent); }
.inline-form { display: flex; gap: 0.5em; }
.inline-form input { flex: 1; }

/* ---------- auth ---------- */
.auth-view {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 1.2em; background: var(--bg);
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; box-shadow: var(--shadow-soft);
  padding: 2em 1.8em; width: 100%; max-width: 380px; text-align: center;
}
.auth-card h1 { margin: 0.3em 0 0.1em; font-size: 1.9rem; font-weight: 700; }
.auth-card form { text-align: start; margin-top: 1.2em; }
.auth-card .primary { width: 100%; }
.logo-mark {
  width: 58px; height: 58px; margin: 0 auto;
  border-radius: 50%; background: var(--spark); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.logo-mark svg { width: 30px; height: 30px; }

/* ---------- layout ---------- */
.app { display: flex; height: 100dvh; overflow: hidden; }
#sidebar {
  width: 296px; flex: 0 0 296px; height: 100%;
  background: var(--bg-soft); border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
  padding: calc(0.9em + var(--sat)) 0.9em calc(0.9em + var(--sab));
  gap: 0.9em;
}
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.pane { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.pane-head {
  display: flex; align-items: center; gap: 0.7em;
  padding: calc(0.8em + var(--sat)) 1.1em 0.8em;
  background: transparent;
}
.pane-head h2 { margin: 0; font-size: 1.3rem; font-weight: 650; }
.pane-body { flex: 1; overflow-y: auto; padding: 1.1em; max-width: 980px; width: 100%; margin: 0 auto; }
.pane-body.narrow { max-width: 760px; }
.pane-title { display: flex; align-items: center; gap: 0.65em; min-width: 0; }
.pane-title h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; padding: 0; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; border: none; background: none; color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
.menu-btn { display: none; }

/* ---------- chat header: centered identity ---------- */
.pane-head.chat-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(0.55em + var(--sat)) 0.9em 0.55em;
}
.chat-title {
  flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; text-align: center; border-radius: 14px; padding: 2px 10px;
}
.chat-title h2 { font-size: 0.94rem; font-weight: 600; line-height: 1.15; }
#chat-bot-sub { display: none; }
.head-actions { justify-self: end; display: flex; gap: 2px; }
.chat-head > .menu-btn { justify-self: start; }

/* ---------- sidebar ---------- */
.side-head { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 0.5em; font-size: 1.3rem; font-weight: 700; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--spark); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-mark svg { width: 19px; height: 19px; }
.new-chat-btn {
  display: flex; align-items: center; justify-content: center; gap: 0.5em;
  background: var(--text); color: var(--bg); border: 1px solid var(--text);
  font-weight: 600; padding: 0.65em 1em; width: 100%;
}
.new-chat-btn svg { width: 17px; height: 17px; }
.new-chat-btn:hover { background: var(--text); opacity: 0.88; }
#main-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 0.65em; width: 100%;
  background: none; border: none; border-radius: 12px;
  padding: 0.55em 0.7em; font-size: 0.98rem; text-align: start; color: var(--text);
}
.nav-item svg { width: 19px; height: 19px; color: var(--muted); flex: 0 0 auto; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--surface); font-weight: 600; box-shadow: var(--shadow-soft); }
.nav-item.active svg { color: var(--text); }
.nav-group {
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted);
  margin: 0.9em 0.7em 0.25em;
}
.badge {
  margin-inline-start: auto; background: var(--badge); color: #fff;
  font-size: 0.72rem; font-weight: 700; border-radius: 999px;
  min-width: 1.5em; padding: 0.15em 0.45em; text-align: center;
}
.side-section { border-top: 1px solid var(--border); padding-top: 0.8em; }
.side-label {
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 0.5em;
}
.side-add { background: none; border: none; color: var(--text); font-weight: 600; padding: 0.4em 0.2em; }
.side-add:hover { background: none; text-decoration: underline; }
.side-foot {
  margin-top: auto; border-top: 1px solid var(--border); padding-top: 0.8em;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5em;
}
.conv-list, .bot-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-list li, .bot-list li {
  display: flex; align-items: center; gap: 0.55em;
  padding: 0.5em 0.6em; border-radius: 11px; cursor: pointer; font-size: 0.94rem;
}
.conv-list li:hover, .bot-list li:hover { background: var(--surface-2); }
.conv-list li.active, .bot-list li.active { background: var(--surface); font-weight: 600; }
.conv-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-tag {
  font-size: 0.68rem; font-weight: 700; color: var(--muted);
  background: var(--accent-soft); border-radius: 999px; padding: 0.12em 0.5em;
}
.avatar {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 12px;
  background: var(--surface-2); border: none;
  color: var(--muted); font-weight: 700; font-size: 0.95rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.avatar.small { width: 28px; height: 28px; border-radius: 9px; font-size: 0.8rem; }
.avatar.muse-avatar { background: var(--spark); color: #fff; border-radius: 50%; }
.avatar.muse-avatar svg { width: 18px; height: 18px; }
.avatar.small.muse-avatar svg { width: 14px; height: 14px; }
#chat-bot-avatar { width: 38px; height: 38px; }
#chat-bot-avatar svg { width: 20px; height: 20px; }
.bot-meta { flex: 1; min-width: 0; }
.bot-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-preview { font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scrim {
  position: fixed; inset: 0; background: rgba(28, 26, 22, 0.38); z-index: 30;
}

/* ---------- activity & identity panel ---------- */
#panel-scrim { z-index: 65; }
#panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 70;
  width: min(340px, 88vw);
  background: var(--surface); box-shadow: var(--shadow);
  transform: translateX(105%); transition: transform 0.24s ease;
  display: flex; flex-direction: column; overflow-y: auto;
  padding: calc(0.9em + var(--sat)) 0.9em calc(0.9em + var(--sab));
}
#panel.open { transform: translateX(0); }
.panel-head { display: flex; align-items: center; gap: 0.7em; padding: 0.3em 0.2em 1em; }
.panel-head .avatar { width: 42px; height: 42px; }
.panel-head .avatar svg { width: 22px; height: 22px; }
.panel-name { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.panel-group {
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted);
  margin: 1em 0.6em 0.3em;
}
.panel-row {
  display: flex; align-items: center; gap: 0.7em; width: 100%;
  background: none; border: none; border-radius: 12px;
  padding: 0.72em 0.6em; font-size: 0.98rem; text-align: start; color: var(--text);
}
.panel-row:hover { background: var(--surface-2); }
.panel-row svg { width: 20px; height: 20px; color: var(--muted); flex: 0 0 auto; }
.panel-row.danger { color: var(--danger); }
.panel-row.danger svg { color: var(--danger); }

/* ---------- tab bar / rail ---------- */
#tabbar {
  position: fixed; z-index: 60;
  background: var(--tabbar-bg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.tab-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 0.66rem; font-weight: 500; line-height: 1;
}
.tab-item svg { width: 23px; height: 23px; }
.tab-item.active { color: var(--text); font-weight: 650; }
.tab-item:hover { background: none; color: var(--text); }

/* ---------- chat ---------- */
.chat-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.messages {
  flex: 1; overflow-y: auto; width: 100%; max-width: 760px; margin: 0 auto;
  padding: 1.3em 1.1em 0.6em; display: flex; flex-direction: column; gap: 1.15em;
}
.hero { text-align: center; padding: 3.2em 1.4em; max-width: 560px; margin: auto; }
.hero h3 { font-size: 1.6rem; margin: 0.6em 0 0.3em; }
.hero p { color: var(--muted); line-height: 1.55; }
.hero .logo-mark { width: 68px; height: 68px; }
.hero .logo-mark svg { width: 36px; height: 36px; }
.empty { text-align: center; color: var(--muted); padding: 2em 1em; }
.msg-row { display: flex; }
.msg-row.user { justify-content: flex-end; }
.msg-col { display: flex; flex-direction: column; gap: 0.35em; max-width: 100%; min-width: 0; }
.msg-row.user .msg-col { align-items: flex-end; max-width: 78%; }
.msg {
  line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  overflow-wrap: anywhere; text-align: start;
}
.msg.user {
  background: var(--user-bubble); color: var(--text);
  border-radius: 22px; padding: 0.62em 1.05em;
}
.msg.assistant { padding: 0; }
.msg-time { font-size: 0.68rem; color: var(--muted); opacity: 0.85; }
.msg.typing { display: inline-flex; gap: 5px; padding: 0.6em 0.2em; }
.msg.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite;
}
.msg.typing span:nth-child(2) { animation-delay: 0.2s; }
.msg.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.space-card {
  display: flex; align-items: center; gap: 0.7em; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 0.75em 1em; color: var(--text);
  box-shadow: var(--shadow-soft);
}
.space-card:hover { border-color: var(--border-strong); }
.space-card .sc-mark {
  width: 34px; height: 34px; border-radius: 11px; flex: 0 0 auto;
  background: var(--accent-soft); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
}
.space-card .sc-mark svg { width: 18px; height: 18px; }
.space-card .sc-title { font-weight: 600; font-size: 0.94rem; }
.space-card .sc-sub { font-size: 0.78rem; color: var(--muted); }
.trace {
  background: var(--surface-2); border: none;
  border-radius: 14px; padding: 0.5em 0.85em; font-size: 0.84rem;
}
.trace summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.trace-items { margin-top: 0.5em; display: flex; flex-direction: column; gap: 0.35em; }
.trace-item { display: flex; gap: 0.5em; align-items: baseline; min-width: 0; }
.t-icon { flex: 0 0 auto; font-weight: 700; }
.t-icon.st-ok, .t-icon.st-approved { color: var(--ok); }
.t-icon.st-error, .t-icon.st-denied, .t-icon.st-timeout { color: var(--danger); }
.t-icon.st-running { color: var(--warn); }
.t-name { font-weight: 600; flex: 0 0 auto; }
.t-preview { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.approval-card {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 18px; padding: 0.85em 1em; max-width: 560px;
  box-shadow: var(--shadow-soft);
}
.approval-card h4 { margin: 0 0 0.5em; font-size: 0.95rem; }
.approval-card pre, .card pre {
  background: var(--code); border-radius: 10px; padding: 0.6em 0.8em;
  overflow-x: auto; font-size: 0.83rem; margin: 0 0 0.7em; white-space: pre-wrap; word-break: break-word;
}
.decided { font-weight: 600; font-size: 0.9rem; }

/* ---------- composer: floating pill ---------- */
.composer {
  width: calc(100% - 24px); max-width: 760px; margin: 4px auto 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 28px; box-shadow: var(--shadow-soft);
  display: flex; gap: 2px; align-items: flex-end; padding: 6px;
}
.composer textarea {
  flex: 1; border: none; background: transparent; box-shadow: none;
  border-radius: 20px; padding: 0.55em 0.5em; max-height: 140px; resize: none;
}
.composer textarea:focus { outline: none; border: none; box-shadow: none; }
.comp-btn {
  width: 40px; height: 40px; flex: 0 0 auto; padding: 0;
  border-radius: 50%; border: none; background: none; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.comp-btn:hover { background: var(--surface-2); color: var(--text); }
.comp-btn svg { width: 21px; height: 21px; }
.comp-btn.listening { color: var(--danger); background: var(--surface-2); }
.send-btn {
  width: 40px; height: 40px; flex: 0 0 auto; padding: 0;
  border-radius: 50%; background: var(--text); border: 1px solid var(--text);
  color: var(--bg); display: inline-flex; align-items: center; justify-content: center;
}
.send-btn:hover { background: var(--text); opacity: 0.88; }
.send-btn svg { width: 19px; height: 19px; }
.send-btn.stop { background: var(--surface); color: var(--danger); border-color: var(--danger-dim); }
#chat-error { max-width: 760px; margin: 0 auto; width: 100%; padding: 0 1.1em; }

/* ---------- sheets & cards ---------- */
.sheet {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 1.1em; overflow-y: auto;
}
.sheet h3 { margin-top: 0; }
.inline-sheet { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1.1em; }
.card-list { display: flex; flex-direction: column; gap: 0.8em; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1em 1.1em;
}
.card h4 { margin: 0 0 0.3em; font-size: 1.02rem; }
.card .meta { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.5em; }
.card p { margin: 0.3em 0; line-height: 1.5; }
.card-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1em; margin-top: 1.2em; }
.card-form h3 { margin-top: 0; }
.cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.9em; margin-top: 0.8em;
}
.library-spaces-card { margin-bottom: 0.4em; }
.status-pill {
  font-size: 0.72rem; font-weight: 700; border-radius: 999px; padding: 0.18em 0.6em;
  background: var(--accent-soft); color: var(--text);
}
.status-pill.pending { background: #F6ECD2; color: var(--warn); }
html[data-theme="dark"] .status-pill.pending { background: #4A3D1E; }
.status-pill.approved, .status-pill.completed, .status-pill.saved { background: #E2EFE0; color: var(--ok); }
html[data-theme="dark"] .status-pill.approved,
html[data-theme="dark"] .status-pill.completed,
html[data-theme="dark"] .status-pill.saved { background: #2C422C; }
.status-pill.denied, .status-pill.timeout, .status-pill.dismissed { background: #F6E0D9; color: var(--danger); }
html[data-theme="dark"] .status-pill.denied,
html[data-theme="dark"] .status-pill.timeout,
html[data-theme="dark"] .status-pill.dismissed { background: #4A2E26; }
.filter-chips { display: flex; gap: 0.45em; flex-wrap: wrap; margin: 0.4em 0 0.2em; }
.chip {
  border-radius: 999px; padding: 0.38em 0.95em; font-size: 0.88rem;
  background: var(--surface-2); border: none; max-width: 100%; color: var(--text);
}
.chip:hover { background: var(--accent-soft); }
.chip.active { background: var(--text); color: var(--bg); font-weight: 600; }
.section-title { margin: 1.4em 0 0.7em; }
.memory-list { list-style: none; margin: 0 0 0.9em; padding: 0; display: flex; flex-direction: column; gap: 0.5em; }
.memory-list li {
  display: flex; gap: 0.5em; align-items: center;
  background: var(--surface-2); border: none;
  border-radius: 12px; padding: 0.55em 0.8em;
}
.memory-list .note-text { flex: 1; min-width: 0; }

/* ---------- settings: iOS-style grouped cards ---------- */
#view-settings, #view-connectors, #view-devices, #view-vault,
#view-permissions, #view-data { background: var(--bg-soft); }
#view-settings .pane-body, #view-connectors .pane-body, #view-devices .pane-body,
#view-vault .pane-body, #view-permissions .pane-body, #view-data .pane-body {
  background: transparent;
}
.settings-section {
  background: var(--surface); border: none;
  border-radius: var(--radius); box-shadow: var(--shadow-soft);
  padding: 1.05em 1.15em; margin-bottom: 1.1em;
}
.settings-section h3 { margin-top: 0; }
.settings-row-btn {
  display: flex; align-items: center; gap: 0.6em; width: 100%;
  background: none; border: none; border-radius: 10px;
  padding: 0.35em 0.1em; font-size: 0.98rem; color: var(--text); text-align: start;
}
.settings-row-btn:hover { background: none; }
.theme-icon-slot { display: inline-flex; color: var(--muted); }
.theme-icon-slot svg { width: 20px; height: 20px; }
#theme-toggle svg { width: 20px; height: 20px; }

/* Settings navigation rows + connector rows (iOS grouped-list style) */
.settings-rows { padding: 0.35em 0.5em; }
.srow {
  display: flex; align-items: center; gap: 0.75em; width: 100%;
  background: none; border: none; border-radius: 12px;
  padding: 0.62em 0.6em; text-align: start; color: var(--text);
  font-size: 0.98rem; cursor: pointer;
}
.srow:hover { background: var(--surface-2); }
.srow + .srow { border-top: 1px solid var(--border); }
.srow-icon {
  width: 30px; height: 30px; flex: 0 0 auto; border-radius: 9px;
  background: var(--accent-soft); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
}
.srow-icon svg { width: 17px; height: 17px; }
.srow-icon.conn-icon { font-weight: 700; font-size: 0.95rem; }
.srow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.srow-name { font-weight: 550; }
.srow-desc { font-size: 0.8rem; color: var(--muted); line-height: 1.35; }
.srow-value { font-size: 0.85rem; color: var(--muted); flex: 0 0 auto; }
.chev { color: var(--muted); font-size: 1.3rem; line-height: 1; flex: 0 0 auto; }
.srow .status-pill { flex: 0 0 auto; }

/* Key/value rows (connector detail, devices) */
.kv-rows { display: flex; flex-direction: column; }
.kv-row {
  display: flex; gap: 1em; padding: 0.55em 0;
  border-bottom: 1px solid var(--border);
}
.kv-row:last-child { border-bottom: none; }
.kv-key { flex: 0 0 38%; color: var(--muted); font-size: 0.9rem; }
.kv-val { flex: 1; min-width: 0; font-size: 0.95rem; word-break: break-word; }

/* Honest-state notice (e.g. a connector that needs HTTPS) */
.notice {
  background: var(--surface-2); border-radius: 14px;
  padding: 0.8em 1em; font-size: 0.92rem; line-height: 1.55; margin-top: 0.8em;
}
.notice.warn { background: #FBF2D8; color: #6D5510; }
html[data-theme="dark"] .notice.warn { background: #453A1C; color: #ECD9A0; }
#connector-search { margin-bottom: 0.3em; }
.settings-section .switch-row { margin-bottom: 0.7em; }
/* Pane-head action buttons never wrap their labels on narrow screens. */
.pane-head .small-btn { white-space: nowrap; }
@media (max-width: 480px) {
  .pane-head .small-btn { padding: 0.32em 0.65em; font-size: 0.82rem; }
  .pane-head h2 { font-size: 1.18rem; }
}
.detail-bar { margin-bottom: 0.9em; }
.detail-bar h3 { margin: 0; }
.space-frame {
  width: 100%; height: 62dvh; border: 1px solid var(--border);
  border-radius: var(--radius); background: #fff;
}

/* ---------- feed: a personal newspaper ---------- */
.feed-list { display: flex; flex-direction: column; }
.feed-post {
  background: transparent; border: none; border-radius: 0;
  padding: 1.15em 0.1em 1.3em; border-bottom: 1px solid var(--border);
}
.feed-post .kicker {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 0.4em;
}
.feed-post h3 {
  margin: 0 0 0.4em; font-size: 1.45rem; line-height: 1.3; font-weight: 600;
  font-family: ui-serif, "New York", Georgia, "Times New Roman", serif;
}
.feed-post .post-body { line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.feed-post .meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.7em; }
.feed-post .row button { border: none; background: none; color: var(--muted); padding: 0.3em 0.2em; }
.feed-post .row button:hover { color: var(--danger); }

/* ---------- ideas: quiet cards, text actions ---------- */
#ideas-grid .card .row { margin-top: 0.5em; }
#ideas-grid .card .row button {
  border: none; background: none; padding: 0.3em 0.35em;
  color: var(--muted); font-weight: 500;
}
#ideas-grid .card .row button.primary { color: var(--text); font-weight: 650; background: none; border: none; }
#ideas-grid .card .row button:hover { color: var(--text); }
#ideas-grid .card .row button.danger:hover { color: var(--danger); }

/* ---------- goals: clean rows with a status dot ---------- */
#goals-list { gap: 0; }
#goals-list .card {
  background: transparent; border: none; border-radius: 0; box-shadow: none;
  border-bottom: 1px solid var(--border); padding: 1.05em 0.15em;
}
#goals-list .status-pill { background: transparent; padding: 0; color: var(--muted); }
#goals-list .status-pill::before {
  content: ""; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--warn); margin-inline-end: 7px;
}
#goals-list .status-pill.completed { color: var(--ok); }
#goals-list .status-pill.completed::before { background: var(--ok); }
.goal-notes {
  background: var(--surface-2); border-radius: 12px; padding: 0.6em 0.8em;
  font-size: 0.86rem; white-space: pre-wrap; line-height: 1.5; margin: 0.5em 0;
}
.goal-note-form { display: flex; gap: 0.5em; margin-top: 0.6em; }
.goal-note-form input { flex: 1; }

/* ---------- responsive ---------- */
/* Phones & small tablets: bottom tab bar, slide-over sidebar */
@media (max-width: 1023px) {
  .app { padding-bottom: calc(var(--tabbar-h) + var(--sab)); }
  #tabbar {
    left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar-h) + var(--sab)); padding-bottom: var(--sab);
    border-top: 1px solid var(--border);
    display: flex; align-items: stretch;
  }
  .tab-item { flex: 1; padding: 7px 0 3px; }
  #sidebar {
    position: fixed; inset-inline-start: 0; top: 0; z-index: 40;
    transform: translateX(-105%); transition: transform 0.22s ease;
    box-shadow: var(--shadow); width: min(320px, 88vw); flex-basis: auto;
  }
  #sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .pane-body { padding: 0.9em; }
}
/* Wide screens: left icon rail, static sidebar, centered chat column */
@media (min-width: 1024px) {
  .app { padding-left: var(--rail-w); }
  #tabbar {
    left: 0; top: 0; bottom: 0; width: var(--rail-w);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; align-items: center;
    padding: calc(14px + var(--sat)) 0 14px; gap: 6px;
  }
  .tab-item { width: 62px; padding: 9px 0 7px; border-radius: 16px; }
  .tab-item.active { background: var(--surface-2); }
  #main-nav { display: none; }
}
