/* Chakudya NutriMind: chat page and landing card */
body.is-nutrimind .sidebar, body.is-nutrimind .sidebar-scrim, body.is-nutrimind .sidebar-toggle, body.is-nutrimind .header-search { display: none !important; }
body.is-nutrimind .content { max-width: 820px; padding: 16px 20px 0; }

.nm { display: flex; flex-direction: column; min-height: calc(100dvh - var(--header-h) - 16px); }
.nm-head { display: flex; align-items: center; gap: 12px; padding: 6px 0 14px; border-bottom: 1px solid var(--border); }
.nm-head__logo, .nm-avatar { border-radius: 12px; background: #f9fbf9; flex: none; }
.nm-head__text { flex: 1; min-width: 0; }
.nm-head__title { font-size: clamp(19px, 3.4vw, 24px); line-height: 1.15; letter-spacing: -.3px; }
.nm-head__sub { margin: 3px 0 0; font-size: 12.5px; color: var(--text-secondary); }

.nm-thread { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 20px 0 24px; }
.nm-thread > * { scroll-margin-bottom: 210px; }

.nm-welcome { text-align: center; margin: auto; padding: 8px 4px 0; max-width: 560px; }
.nm-welcome__logo { width: 120px; height: 120px; border-radius: 28px; box-shadow: var(--shadow-sm); }
.nm-welcome h2 { margin-top: 14px; font-size: clamp(22px, 4.6vw, 30px); letter-spacing: -.4px; }
.nm-welcome p { margin: 8px 0 0; color: var(--text-secondary); line-height: 1.55; }
.nm-prompts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.nm-prompt { font: inherit; font-size: 13.5px; color: var(--text-primary); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 9px 14px; cursor: pointer; text-align: left; line-height: 1.35; }
.nm-prompt:hover { background: var(--surface-hover); border-color: var(--accent); }

.nm-msg { display: flex; gap: 10px; max-width: 100%; }
.nm-msg--user { justify-content: flex-end; }
.nm-avatar { width: 28px; height: 28px; margin-top: 2px; border: 1px solid var(--border); }
.nm-bubble { min-width: 0; font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.nm-msg--user .nm-bubble { background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 18px 18px 4px 18px; max-width: 100%; white-space: pre-wrap; }
.nm-ucol { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; max-width: 85%; min-width: 0; }
.nm-msg--bot .nm-bubble { background: var(--surface); border: 1px solid var(--border); padding: 12px 16px; border-radius: 4px 18px 18px 18px; max-width: calc(100% - 38px); color: var(--text-primary); }
.nm-msg--error .nm-bubble { border-color: var(--method-delete); }
.nm-bubble p { margin: 0 0 10px; } .nm-bubble p:last-child { margin-bottom: 0; }
.nm-bubble h4 { margin: 12px 0 6px; font-size: 14.5px; }
.nm-bubble ul, .nm-bubble ol { margin: 0 0 10px; padding-left: 22px; display: grid; gap: 4px; }
.nm-cite { font-size: 10.5px; font-weight: 700; color: var(--accent-strong); margin-left: 1px; }
.nm-tools { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 16px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12.5px; }
.nm-sources { flex: 1 1 220px; color: var(--text-secondary); }
.nm-sources summary { cursor: pointer; font-weight: 600; color: var(--text-secondary); }
.nm-sources ol { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; }
.nm-copy { font: inherit; font-size: 12.5px; font-weight: 600; background: none; border: 0; color: var(--text-secondary); cursor: pointer; padding: 0; }
.nm-copy:hover { color: var(--accent-strong); }
.nm-retry { margin-top: 10px; }

.nm-typing { display: flex; align-items: center; gap: 5px; padding: 15px 16px; }
.nm-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-tertiary); animation: nm-bounce 1.2s infinite ease-in-out; }
.nm-typing span:nth-child(2) { animation-delay: .15s; } .nm-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes nm-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }

.nm-composer { position: sticky; bottom: 0; padding: 18px 0 calc(10px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to bottom, transparent, var(--bg) 22%); }
.nm-modes { display: flex; gap: 6px; margin-bottom: 8px; }
.nm-mode { font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.nm-mode[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.nm-box { display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 22px; padding: 6px 6px 6px 16px; }
.nm-box:focus-within { border-color: var(--accent); box-shadow: var(--focus-ring); }
.nm-box textarea { flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: transparent; color: var(--text-primary); font: inherit; font-size: 16px; line-height: 1.45; padding: 8px 0; max-height: 140px; }
.nm-box textarea::placeholder { color: var(--text-tertiary); }
.nm-send { flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; }
.nm-send:disabled { opacity: .45; cursor: not-allowed; }
.nm-fine { margin: 8px 4px 0; font-size: 11.5px; line-height: 1.5; color: var(--text-tertiary); }

/* Landing card */
.lp-nm__panel { display: grid; grid-template-columns: auto 1fr; gap: 20px 28px; align-items: center; }
.lp-nm__logo { width: 112px; height: 112px; border-radius: 26px; box-shadow: var(--shadow-sm); }
.lp-nm__panel .lp-cta { grid-column: 2; margin-top: 0; }

@media (max-width: 640px) {
  body.is-nutrimind .content { padding: 10px 14px 0; }
  .nm-ucol { max-width: 92%; }
  .nm-head { gap: 8px; }
  .nm-head .nm-new { padding: 6px 10px; }
  .lp-nm__panel { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .lp-nm__panel .lp-cta { grid-column: 1; justify-content: center; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .nm-typing span { animation: none; } }

/* Streaming, emoji and graphics */
.nm-msg--new { animation: nm-in .28s ease-out; }
@keyframes nm-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.nm-caret { display: inline-block; width: 7px; height: 1.05em; margin-left: 2px; vertical-align: -0.15em; background: var(--accent); border-radius: 2px; animation: nm-blink 1s steps(2, start) infinite; }
@keyframes nm-blink { to { visibility: hidden; } }
.nm-send.is-stop { background: var(--text-primary); color: var(--bg); }
.nm-emoji { margin-right: 6px; font-style: normal; }
.nm-prompt { display: inline-flex; align-items: center; gap: 8px; }
.nm-prompt__icon { font-size: 17px; line-height: 1; flex: none; }

.nm-callout { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--accent-bg); font-size: 14.5px; }
.nm-callout:last-child { margin-bottom: 0; }
.nm-callout--tip { border-color: rgba(63,166,107,.45); background: rgba(63,166,107,.10); }
.nm-callout--warn { border-color: rgba(226,87,76,.5); background: rgba(226,87,76,.09); }
.nm-callout__icon { font-size: 18px; line-height: 1.4; flex: none; }
.nm-callout > div { min-width: 0; }

.nm-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; margin: 4px 0 12px; }
.nm-fact { display: grid; gap: 1px; padding: 10px 10px 9px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-raised); text-align: left; }
.nm-fact__icon { font-size: 18px; line-height: 1.2; }
.nm-fact__val { font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--text-primary); line-height: 1.15; }
.nm-fact__val small { margin-left: 3px; font-family: var(--font-body); font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.nm-fact__name { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.nm-fact__note { margin-top: 2px; font-size: 11px; line-height: 1.35; color: var(--text-tertiary); }
@media (prefers-reduced-motion: reduce) { .nm-msg--new, .nm-caret { animation: none; } }

/* Chats, memory, branch, retry and edit */
.nm-iconbtn { display: inline-grid; place-items: center; padding: 6px 9px; }
.nm-shuffle { margin-top: 12px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); background: none; border: 0; cursor: pointer; padding: 6px 10px; border-radius: 999px; }
.nm-shuffle:hover { color: var(--accent-strong); background: var(--surface-hover); }

.nm-act, .nm-copy { display: inline-flex; align-items: center; gap: 5px; }
.nm-act { font: inherit; font-size: 12.5px; font-weight: 600; background: none; border: 0; color: var(--text-secondary); cursor: pointer; padding: 2px 0; }
.nm-act:hover { color: var(--accent-strong); }
.nm-acts { display: flex; gap: 12px; padding-right: 4px; opacity: .85; }
.nm-acts .nm-act { font-size: 12px; }

.nm-edit { width: min(100%, 520px); display: grid; gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--accent); border-radius: 18px; box-shadow: var(--focus-ring); }
.nm-edit textarea { width: 100%; resize: none; border: 0; outline: 0; background: transparent; color: var(--text-primary); font: inherit; font-size: 16px; line-height: 1.45; padding: 4px 6px; max-height: 180px; }
.nm-edit__row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

.nm-branchnote { display: flex; align-items: center; gap: 7px; align-self: center; max-width: 100%; font-size: 12px; color: var(--text-secondary); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; }
.nm-branchnote span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nm-drawer { position: fixed; inset: 0; z-index: 1000; display: flex; justify-content: flex-end; }
.nm-drawer[hidden] { display: none; }
.nm-drawer__scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); }
.nm-drawer__panel { position: relative; width: min(360px, 92vw); height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--bg); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-md); animation: nm-slide .2s ease-out; }
@keyframes nm-slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.nm-drawer__head { display: flex; align-items: center; justify-content: space-between; }
.nm-drawer__head h3 { font-size: 17px; }
.nm-x { font: inherit; font-size: 16px; color: var(--text-secondary); background: none; border: 0; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.nm-x:hover { background: var(--surface-hover); color: var(--text-primary); }
.nm-drawer__new { align-self: flex-start; }
.nm-chatlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; flex: 1; align-content: start; }
.nm-chatlist__empty { font-size: 13px; color: var(--text-tertiary); padding: 8px 2px; }
.nm-chat { display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.nm-chat.is-active { border-color: var(--accent); }
.nm-chat__open { flex: 1; min-width: 0; display: grid; gap: 2px; text-align: left; font: inherit; background: none; border: 0; color: var(--text-primary); cursor: pointer; padding: 10px 12px; }
.nm-chat__title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nm-chat__meta { font-size: 11.5px; color: var(--text-tertiary); }
.nm-chat__del { font: inherit; font-size: 13px; background: none; border: 0; color: var(--text-tertiary); cursor: pointer; padding: 0 12px; }
.nm-chat__del:hover { color: var(--method-delete); }
.nm-mem { border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 8px; justify-items: start; }
.nm-mem h4 { font-size: 13.5px; }
.nm-mem__text { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.nm-mem__hint { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--text-tertiary); }

.nm-toast { position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 1100; background: var(--text-primary); color: var(--bg); font-size: 13px; padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow-md); }
@media (prefers-reduced-motion: reduce) { .nm-drawer__panel { animation: none; } }

/* Feedback and server memory */
.nm-fb { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.nm-fb__btn { padding: 2px 4px; border-radius: 6px; }
.nm-fb__btn[aria-pressed="true"] { color: var(--accent-strong); background: var(--accent-bg); }
.nm-fb__why { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; flex-basis: 100%; font-size: 12px; color: var(--text-secondary); }
.nm-chip { font: inherit; font-size: 12px; font-weight: 600; color: var(--text-secondary); background: var(--bg); border: 1px solid var(--border-strong); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.nm-chip[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.nm-switch { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.4; color: var(--text-primary); cursor: pointer; }
.nm-switch input { margin-top: 3px; accent-color: var(--accent); flex: none; }
