/* Only the connected entry loads this sheet. Keep the approved diary rendering. */
/* Keep touch gestures at the page boundary without locking long settings pages. */
html { overscroll-behavior-y: none; }
html[data-page="chat"],
html[data-page="chat"] body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior-y: none;
}
@media (max-width: 1100px) {
  html[data-page="chat"] {
    background: var(--paper);
  }
}
#sparkHelp { position: fixed; inset: 0 auto auto 0; }
.chat-layout .messages { overscroll-behavior-y: contain; }
#app { min-height: var(--app-vh, 100dvh); }
.boot-page { min-height: var(--app-vh, 100dvh); display: grid; place-content: center; gap: 14px; text-align: center; padding: 24px; color: var(--muted); font-size: 12px; }
.boot-page p { margin: 0; max-width: 30em; }
.boot-page a { color: var(--ink); text-underline-offset: 5px; }
.chat-layout { min-height: calc(var(--app-vh, 100dvh) - 50px); }
.conversation { height: calc(var(--app-vh, 100dvh) - 50px); }
.partners-page { min-height: calc(var(--app-vh, 100dvh) - 56px); }
html[data-page="chat"] body[data-connected="true"] #app {
  position: fixed;
  top: var(--app-vtop, 0px);
  left: 0;
  right: 0;
  max-width: 1100px;
  margin: 0 auto;
  height: var(--app-vh, 100dvh);
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
html[data-page="chat"] .topbar.chat-header {
  flex: 0 0 50px;
}
html[data-page="chat"] .chat-layout {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  grid-template-rows: minmax(0, 1fr);
}
@media (max-width: 650px) {
  html[data-page="chat"] .chat-layout {
    display: flex;
    flex-direction: column;
  }
}
html[data-page="chat"] .conversation {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
}
html[data-page="chat"][data-keyboard-open="true"] .composer.voice-composer {
  padding-bottom: 8px;
}
.pwa-info { text-align: center; padding: 28px 16px; }
.pwa-info img { border-radius: 22%; }
.pwa-info [data-pwa-install] { padding: 12px 22px; background: #e1e9de; border: 0; border-radius: 46% 42% 45% 40% / 18% 22% 20% 24%; }
.pwa-info .fineprint { max-width: 320px; margin: 18px auto; line-height: 1.8; }
body[data-auth="login"] #floatingSpark {
  visibility: hidden;
}
.login-page {
  max-width: 390px;
  padding-top: 12dvh;
}
.login-page h1 {
  font-size: 27px;
  font-weight: 400;
}
.login-page .form {
  margin: 32px 0 20px;
}
.login-page [role="alert"] {
  font-size: 13px;
  color: #a56762;
}
.live-attachment {
  display: block;
  font-size: 12px;
  color: #71816b;
  margin-top: 8px;
}
.live-uploads {
  font-size: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.live-uploads button {
  padding: 4px;
}
body[data-mode="live"] .composer-note {
  font-size: 10px;
}

.floating-spark {
  z-index: 1000;
}
.diary-resource-editor {
  max-width: 640px;
  margin: auto;
}
.diary-resource-editor label {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  font-size: 14px;
}
.diary-resource-editor input:not([type="checkbox"]) {
  width: 100%;
  min-width: 0;
  padding: 10px 2px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
}
.diary-resource-editor .switch {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.diary-resource-editor .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}
.diary-resource-editor .header-pair {
  border: 0;
  border-bottom: 1px dashed var(--rule);
  padding: 10px 0;
}
.diary-resource-editor h2 {
  font-size: 16px;
  font-weight: 400;
  margin-top: 28px;
}
.resource-model {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  overflow-wrap: anywhere;
}
.resource-model small {
  color: var(--muted);
  font-size: 11px;
}
.last-turn-editor textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  line-height: 1.8;
  padding: 8px 0;
}
.last-turn-editor .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.last-turn-editor button,
.reply-versions button {
  font-size: 12px;
  padding: 6px 10px;
}
.reply-versions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  color: var(--muted);
  margin: 8px 0 0;
}
.reply-versions small {
  font-size: 11px;
}
.reply-footer{display:flex;justify-content:space-between;align-items:baseline;gap:8px;margin-top:6px;min-width:0;color:var(--muted);font-size:var(--thought-font,12.48px)}
.reply-usage{font-size:inherit;line-height:1.6;overflow-wrap:anywhere;min-width:0}
.reply-footer .reply-versions{margin:0 0 0 auto;flex-shrink:0;gap:2px;align-items:center;font-size:inherit}
.reply-footer .reply-versions button,.reply-footer .reply-versions small{font-size:inherit}
.reply-footer .regenerate-icon{display:grid;place-items:center;width:2.1em;height:2.1em;padding:.35em;border:0;background:transparent;color:inherit}
.regenerate-icon svg{width:1.35em;height:1.35em;fill:none;stroke:currentColor;stroke-width:1.3;stroke-linecap:round;stroke-linejoin:round}

.resource-headers fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.mcp-connection-row{display:flex;flex-direction:column;border-bottom:1px solid var(--rule);padding:4px 0 8px}
.mcp-connection-main{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:12px;min-height:44px}
.mcp-connection-main>.row{border-bottom:0;min-width:0;padding:10px 0}
.mcp-connection-main>.row>.arrow{display:none}
.mcp-connection-main>.row strong,.mcp-connection-main>.row small{overflow-wrap:anywhere}
.mcp-connection-actions [hidden],.mcp-connection-subrow[hidden],.mcp-connection-subrow [hidden]{display:none!important}
.mcp-connection-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;font-size:13px;flex-shrink:0}
.mcp-connection-actions .switch{margin:0}
.mcp-oauth-btn{min-height:36px;padding:6px 12px;border:1px solid #A9C5AF;border-radius:4px;background:#DCE9DC;color:#393D42;font-size:13px;white-space:nowrap}
.mcp-oauth-btn:disabled{opacity:.55}
.mcp-connection-subrow{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px 12px;padding:0 0 4px}
.mcp-subrow-note{font-size:12px;color:#747971;overflow-wrap:anywhere;flex:1 1 180px}
.mcp-check-btn{min-height:36px;padding:4px 10px;font-size:12px;white-space:nowrap}

dialog[data-kind="mcp-editor"] .sheet-surface{display:flex;flex-direction:column;height:min(64dvh,560px);min-height:min(60dvh,420px);max-height:68dvh;overflow:hidden;padding:10px 18px 0;background:var(--paper)}
html.keyboard dialog[data-kind="mcp-editor"] .sheet-surface{height:min(84dvh,620px);max-height:86dvh}
dialog[data-kind="mcp-editor"] .sheet-surface::before{content:"";display:block;width:36px;height:4px;border-radius:999px;background:#cdd2c9;margin:0 auto 10px;flex-shrink:0}
dialog[data-kind="mcp-editor"] .sheet-head{flex-shrink:0;margin-bottom:10px}
dialog[data-kind="mcp-editor"] .sheet-head h2{font-size:19px}
dialog[data-kind="mcp-editor"] #sheet-body{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;overflow:hidden}
.mcp-sheet-shell{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;gap:0}
.mcp-sheet-scroll{display:flex;flex-direction:column;gap:12px;flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:2px 2px 14px}
.mcp-load-banner{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;padding:8px 10px;border:1px solid #d9ddd6;border-radius:4px;background:#f9faf5}
.mcp-load-banner[hidden]{display:none}
.mcp-field{display:flex;flex-direction:column;gap:6px;margin:0;min-width:0}
.mcp-field>span{font-size:12.5px;color:#747971;line-height:1.3}
.mcp-sheet-shell input[type="text"],.mcp-sheet-shell input[type="url"],.mcp-sheet-shell input[type="password"]{width:100%;min-height:44px;height:44px;padding:9px 12px;background:#F9FAF5;border:1px solid #A9C5AF;border-radius:4px;font-size:14px;color:#393D42;box-sizing:border-box;outline:none;transition:border-color 150ms}
.mcp-sheet-shell input[type="text"]:focus,.mcp-sheet-shell input[type="url"]:focus,.mcp-sheet-shell input[type="password"]:focus{border-color:#628C6A}
.mcp-sheet-shell input[readonly]{background:#f1f3ee;color:#5a605a}
.mcp-header-fieldset{border:0;padding:0;margin:0;min-width:0;display:flex;flex-direction:column;gap:10px}
.mcp-header-row{display:flex;flex-direction:column;gap:10px;padding-top:4px;border-top:1px dashed #e2e5de}
.mcp-header-row:first-child{padding-top:0;border-top:0}
.mcp-input-row{display:flex;align-items:center;gap:6px;min-width:0}
.mcp-input-row>input{flex:1 1 auto;min-width:0}
.mcp-icon-btn{flex:0 0 auto;min-width:44px;min-height:44px;display:inline-flex;align-items:center;justify-content:center;padding:0;background:#F9FAF5;border:1px solid #A9C5AF;border-radius:4px;color:#393D42;font-size:18px;line-height:1;cursor:pointer}
.mcp-icon-btn svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.mcp-icon-btn[aria-pressed="true"]{border-color:#628C6A;background:#DCE9DC}
.mcp-icon-btn.danger{color:#937260;border-color:#d8c4b9}
.mcp-icon-btn[hidden]{display:none}
.mcp-oauth-details{border:1px solid #d9ddd6;border-radius:4px;background:#fafbf8;padding:0}
.mcp-oauth-summary{list-style:none;display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:44px;padding:8px 12px;cursor:pointer;font-size:14px;color:#393D42}
.mcp-oauth-summary::-webkit-details-marker{display:none}
.mcp-oauth-badge{font-size:12px;padding:2px 8px;border-radius:999px;background:#dfe8df;color:#393D42;white-space:nowrap}
.mcp-oauth-body{display:flex;flex-direction:column;gap:10px;padding:6px 12px 12px;border-top:1px solid #e6e9e2}
.mcp-oauth-hint,.mcp-redirect-box{margin:0}
.mcp-gmail-chips{display:flex;flex-direction:column;gap:6px}
.mcp-gmail-chips[hidden],.mcp-secret-clear-row[hidden]{display:none}
.mcp-chip-list{display:flex;flex-wrap:wrap;gap:6px}
.mcp-chip{min-height:36px;padding:5px 10px;border:1px solid #A9C5AF;border-radius:4px;background:#F9FAF5;color:#393D42;font-size:12.5px;cursor:pointer}
.mcp-chip.is-active{background:#DCE9DC;border-color:#628C6A;font-weight:500}
.mcp-scope-warn{color:#937260}
.mcp-copy-btn{min-height:44px;padding:0 12px;border:1px solid #A9C5AF;border-radius:4px;background:#F9FAF5;font-size:13px;white-space:nowrap}
.mcp-oauth-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.mcp-oauth-actions [hidden],.mcp-danger-zone[hidden]{display:none}
.mcp-danger-zone{padding-top:6px;border-top:1px solid var(--rule);display:flex;justify-content:flex-start}
.mcp-delete-btn{min-height:44px;color:#937260;padding:6px 4px}
.mcp-sheet-status{flex-shrink:0;margin:0;padding:6px 2px 8px;font-size:12.5px;color:#393D42;overflow-wrap:anywhere;border-top:1px solid #ecefe8}
.mcp-sheet-status:empty{display:none}
.mcp-sheet-footer{flex-shrink:0;display:grid;grid-template-columns:1fr 1fr;gap:10px;padding:10px 0 calc(14px + env(safe-area-inset-bottom,0px));background:var(--paper);border-top:1px solid var(--rule)}
.mcp-btn-save,.mcp-btn-test{min-height:44px;height:44px;width:100%;padding:0 12px;background:#DCE9DC;border:1px solid #A9C5AF;border-radius:4px;color:#393D42;font-size:14px;font-weight:500;cursor:pointer;transition:background 160ms,border-color 160ms,opacity 160ms}
.mcp-btn-save:hover:not(:disabled),.mcp-btn-test:hover:not(:disabled){background:#D1E1D1;border-color:#628C6A}
.mcp-btn-save:disabled,.mcp-btn-test:disabled{opacity:.6;cursor:default}

.mcp-approval-banner{display:block;width:calc(100% - 24px);margin:4px auto 6px;padding:9px 12px;border:1px solid #A9C5AF;border-radius:4px;background:#DCE9DC;color:#393D42;font-size:13px;text-align:left;min-height:44px}
.mcp-approval-card{display:flex;flex-direction:column;gap:12px}
.mcp-approval-meta{display:flex;flex-wrap:wrap;align-items:center;gap:8px;font-size:13px;color:#747971}
.mcp-approval-server{font-weight:500;color:#393D42}
.mcp-approval-tool{padding:2px 6px;border-radius:4px;background:#f0f2ed;font-size:12px}
.mcp-approval-message{max-height:36dvh;overflow-y:auto;padding:10px 12px;border:1px solid #d9ddd6;border-radius:4px;background:#F9FAF5;font-size:14px;line-height:1.55;overflow-wrap:anywhere}
.mcp-approval-actions{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}
.mcp-approval-allow{min-height:44px;background:#DCE9DC;border:1px solid #A9C5AF;border-radius:4px;color:#393D42;font-weight:500}
.mcp-approval-actions>button{min-height:44px;border:1px solid #d9ddd6;border-radius:4px}
.mcp-approval-more{border:1px solid #d9ddd6;border-radius:4px;padding:6px 10px;background:#fafbf8}
.mcp-approval-more summary{min-height:36px;display:flex;align-items:center;cursor:pointer;font-size:13px;color:#747971}
.mcp-approval-more-list{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
.mcp-approval-more-list>button{min-height:44px;border:1px solid #d8c4b9;border-radius:4px;padding:6px 12px}

dialog[data-kind="mcp-editor"] #floatingSpark,dialog[data-kind="mcp-approval"] #floatingSpark{display:none}
body:has(.mcp-connection-row) #floatingSpark{top:auto!important;bottom:calc(20px + env(safe-area-inset-bottom,0px))!important}
@media (prefers-reduced-motion:reduce){
  .mcp-sheet-shell input,.mcp-btn-save,.mcp-btn-test{transition:none}
}
[data-header-fields]{border:0;padding:0;margin:0;min-width:0}

.reply-footer{align-items:center;flex-wrap:wrap;justify-content:flex-start;column-gap:8px;row-gap:2px}
.reply-time{font:inherit;color:inherit;white-space:nowrap}
.reply-footer .reply-versions{align-self:center}

.reply-footer{flex-wrap:nowrap}
.reply-meta{min-width:0;flex:1;line-height:1.6}
.reply-meta .reply-time{margin-left:.6em}

/* Inline archive actions: scrolling only selects a visible action; only a click executes it. */
.archive-wheel{flex:0 0 58px;height:44px;overflow-y:auto;scroll-snap-type:y mandatory;scrollbar-width:none;border-block:1px dashed var(--rule);border-radius:8px;overscroll-behavior:contain}
.archive-wheel::-webkit-scrollbar{display:none}
.archive-wheel button{display:block;width:100%;height:44px;min-height:44px;padding:0;font-size:13px;scroll-snap-align:start;background:transparent;border:0}
.reply-footer{animation:reply-meta-appear 220ms ease-out}
@keyframes reply-meta-appear{from{opacity:0;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}
@media(prefers-reduced-motion:reduce){.reply-footer{animation:none}}
/* The same lightweight accordion hosts both public reasoning and private recall. */
.message-head .recall-trigger{margin-left:0;font-size:11.5px;color:#7c8278;padding:4px 0;min-height:32px}
.thought .reasoning-content[hidden],.thought .recall-content[hidden]{display:none!important}
.recall-content{font-size:var(--thought-font);line-height:1.7;color:var(--muted);overflow-wrap:anywhere}
.recall-content h4{font-size:inherit;font-weight:500;margin:10px 0 4px}
.recall-content small{display:block;font-size:.92em}
.recall-item{margin:8px 0}
.recall-text{white-space:pre-wrap;margin:3px 0}
.message-head .thought-trigger:focus-visible,.message-head .recall-trigger:focus-visible{outline:1px dashed currentColor;outline-offset:3px}

/* Unified paper notices live above the reading/input area, including the keyboard viewport. */
#notice,.navigation-status{top:calc(var(--app-vtop,0px) + env(safe-area-inset-top,0px) + var(--app-vh,100dvh) * 0.125);bottom:auto!important;left:50%;transform:translateX(-50%);max-width:min(88vw,440px);white-space:normal;z-index:1400;line-height:1.5}
#notice button{font:inherit;border:0;background:transparent;color:inherit;text-decoration:underline;margin-left:8px}
.cloud-status{display:block;width:28px;height:28px;padding:2px;margin:0 0 7px;border:0;background:none;color:var(--muted)}
.cloud-status svg{width:25px;height:25px;fill:none;stroke:currentColor;stroke-width:1.2;stroke-linecap:round;stroke-linejoin:round}
.cloud-status[data-state=connected]{color:#72836b}.cloud-status[data-state=checking]{opacity:.6}
.account-summary{display:flex;flex-direction:column;align-items:center;gap:5px;padding:10px 0 22px}.account-summary .avatar{width:66px;height:66px}.account-summary .profile-avatar{padding:0;border:0;background:none}.account-summary>.quiet{font-size:17px;padding:0}.application-info{margin-top:16px}.application-info [data-application-info]{padding:12px 0}

#notice.visible { pointer-events: auto; }

.read-marker{display:block;height:1px;width:1px;pointer-events:none}.unread-badge{color:var(--muted);font-size:11px;margin-left:6px}

.application-info .fineprint{font-family:inherit;font-size:.8rem;line-height:1.6}
@supports(interpolate-size:allow-keywords){
 .application-info{interpolate-size:allow-keywords}
 .application-info::details-content{block-size:0;opacity:0;overflow:clip;transition:block-size .24s ease,opacity .2s ease,content-visibility .24s allow-discrete}
 .application-info[open]::details-content{block-size:auto;opacity:1}
}
@media(prefers-reduced-motion:reduce){.application-info::details-content{transition:none}}

.local-tool-loading{min-width:72px;text-align:center;color:var(--muted);}

/* Attachments belong to the message, never a min-content-sized extra grid column. */
.message,.message-text,.conversation,.composer{min-width:0;max-width:100%}
.message-attachments{min-width:0;max-width:100%;display:flex;flex-direction:column;gap:8px}
.message.user .message-attachments{grid-column:1;grid-row:2;justify-self:end;align-items:flex-end}
.message.user:has(.message-attachments) .user-message-meta{grid-row:3}
.live-attachment{box-sizing:border-box;max-width:100%;overflow-wrap:anywhere;word-break:break-word}
.image-attachment{display:block;margin:0;width:fit-content;max-width:100%;line-height:0;border-radius:12px;overflow:hidden}
.image-attachment img{display:block;width:auto;height:auto;max-width:min(240px,100%);max-height:280px;object-fit:contain;border-radius:12px}
.live-uploads{min-width:0;max-width:100%}
.live-uploads > span{min-width:0;max-width:100%;overflow-wrap:anywhere}

.live-attachment:not(.image-attachment):not(.file-attachment){display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}

/* V1 generated files reuse authenticated attachments; no preview surface. */
.live-attachment.file-attachment{display:flex;color:var(--ink);text-decoration:none;font-size:14px;line-height:1.5;width:min(100%,340px);overflow:visible;flex-direction:column;gap:4px;padding:10px 14px;border:1px solid var(--line,#d4cabb);border-radius:8px;min-height:48px;max-width:100%;box-sizing:border-box;overflow-wrap:anywhere;}
.file-attachment small{color:var(--muted,#756e65);font-size:.8em;}

.file-attachment > span{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;width:100%}
.file-attachment small{display:block;line-height:1.4}
.file-attachment:focus-visible{outline:2px solid var(--ink);outline-offset:3px}

/* Empty status must not become a third flex item beside the aligned switches. */
.permission-row .resource-name [role="status"]:empty { display: none; }

/* Actual vs shadow stays side by side at phone widths; no private diagnostics in chat. */
.recall-compare{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px;min-width:0}
.recall-compare>section{min-width:0;overflow-wrap:anywhere}
.recall-compare>section+section{border-left:1px dashed var(--muted);padding-left:12px}
.recall-content button.recall-item{display:block;text-align:left;width:100%;min-height:44px;border:0;background:none;padding:5px 0;color:inherit;font:inherit;white-space:normal;overflow-wrap:anywhere}
.recall-content button.recall-item:focus-visible{outline:1px dashed currentColor;outline-offset:2px}
.recall-detail-mask{position:fixed;inset:0;z-index:1000;background:#443c3438;backdrop-filter:blur(4px);display:grid;place-items:center;padding:20px}
.recall-detail-card{position:relative!important;inset:auto!important;width:min(100%,440px);max-height:75dvh;overflow:auto;background:var(--paper,#faf6ee);padding:24px;border-radius:16px;color:var(--ink);box-sizing:border-box}
.recall-detail-card p{white-space:pre-wrap;overflow-wrap:anywhere}
.recall-dependencies{margin-top:14px;padding-top:12px;border-top:1px dashed var(--muted,#756e65)}
.recall-dependencies h4{margin:8px 0 4px;font-size:.95rem;font-weight:500}
.memory-retrieval-form .recall-limits,.memory-reviewer-settings .recall-limits{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.recall-limits input{width:100%;min-width:0;box-sizing:border-box}
@media(max-width:370px){.recall-compare{gap:8px}.recall-compare>section+section{padding-left:8px}.recall-limits{grid-template-columns:1fr!important}}
