/* Kindness Companion front door, in the Kindness Spark look: Nunito, a white
   page with a soft blue glow, pill-shaped controls and soft shadows instead of
   hard borders. Colours are theme variables: light by default, dark under
   [data-theme="dark"] (chosen with the theme button, or following the device
   setting the first time). */
:root {
  --bg: #ffffff; --panel: #ffffff; --ink: #2D2A26; --muted: #8A8078; --placeholder: #B8AFA6;
  --accent: #4C6FE0; --accent-ink: #2F5FC7; --accent-soft: #EAF2FF; --line: #EEF0F4;
  --glow: #B8D4FF; --glow-bg: #B8D4FF; --ring: rgba(79, 125, 243, .18);
  --coral: #FF6B6B; --coral-dark: #F4511E; --coral-soft: #FFF1EC; --coral-hover: #FFE3D9;
  --green-ink: #2B8A5A; --green-soft: #E6F7EE; --green-hover: #D3F1E0;
  --gold-ink: #B7791F; --gold-soft: #FFF6D6; --gold-hover: #FFEDB3;
  --word1: #4285F4; --word2: #34A853;
  --hyp: #b8860b; --ok: #2f9e6e; --danger: #E03131;
  --field: #ffffff; --card: #ffffff; --warm: #FFF6EE; --code-bg: #F3F6FC;
  --pre-bg: #2D2A26; --pre-ink: #f6f1ea; --hover: #EEF4FF; --active: #D4E4FF;
  --bubble-user: #E4F4E8;
  /* the soft Kindness Spark blue: a light wash on the side menus, a deeper glow behind the chat */
  --side-bg: linear-gradient(180deg, #E4EEFF 0%, #EEF4FF 50%, #F7FAFF 100%);
  --chat-bg: radial-gradient(ellipse 75% 65% at 50% 50%, rgba(120, 170, 255, .62) 0%, rgba(160, 197, 255, .45) 38%, rgba(200, 222, 255, .2) 65%, rgba(255, 255, 255, 0) 90%),
             linear-gradient(180deg, #EDF4FF 0%, #F6F9FF 50%, #EAF2FF 100%);
  --badge-hyp: #FFF3D6; --badge-ok: #E3F6EC; --badge-bad: #FFF0F0;
  --shadow: rgba(45, 42, 38, .18);
  --shadow-tiny: 0 3px 10px rgba(45, 42, 38, .08);
  --shadow-soft: 0 10px 26px rgba(255, 107, 107, .14);
  --shadow-pop: 0 8px 24px rgba(45, 42, 38, .16), 0 0 0 1px rgba(45, 42, 38, .06);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #14171C; --panel: #1B1F26; --ink: #E9EDF3; --muted: #9AA3B1; --placeholder: #6E7684;
  --accent: #6B8FF0; --accent-ink: #A9C2FF; --accent-soft: #24324D; --line: #2A303A;
  --glow: #2C3D5E; --glow-bg: rgba(66, 133, 244, .22); --ring: rgba(107, 143, 240, .3);
  --coral: #FF8787; --coral-dark: #FF8A65; --coral-soft: #3A2620; --coral-hover: #4A2E25;
  --green-ink: #6FCF9A; --green-soft: #1F3A2C; --green-hover: #27493A;
  --gold-ink: #F2C14E; --gold-soft: #3A3120; --gold-hover: #4A3E26;
  --word1: #6EA4FF; --word2: #5CC77A;
  --hyp: #e0b55a; --ok: #6fcf9a; --danger: #FF6B6B;
  --field: #222731; --card: #1F242C; --warm: #33261F; --code-bg: #262C36;
  --pre-bg: #0E1014; --pre-ink: #E9EDF3; --hover: #252B35; --active: #24324D;
  --bubble-user: #26385A;
  --side-bg: linear-gradient(180deg, #1A2131 0%, #191E28 55%, #181B22 100%);
  --chat-bg: radial-gradient(ellipse 65% 55% at 50% 48%, rgba(66, 133, 244, .30) 0%, rgba(66, 133, 244, .13) 42%, rgba(20, 23, 28, 0) 78%),
             linear-gradient(180deg, #161B25 0%, #14171C 50%, #151A24 100%);
  --badge-hyp: #4a3d1e; --badge-ok: #1F3A2C; --badge-bad: #4a2622;
  --shadow: rgba(0, 0, 0, .5);
  --shadow-tiny: 0 3px 10px rgba(0, 0, 0, .35);
  --shadow-soft: 0 10px 26px rgba(0, 0, 0, .45);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .06);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; }
body { font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-weight: 600;
       background-color: var(--bg); color: var(--ink); }
button, input, select, textarea { font-family: inherit; }
::placeholder { color: var(--placeholder); font-weight: 600; }
/* thin, quiet scrollbars like Kindness Spark */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
*::-webkit-scrollbar-track { background: transparent; }

header { padding: 10px 22px; display: flex; align-items: center; gap: 14px; background: var(--panel); min-height: 64px;
         box-shadow: var(--shadow-tiny); position: relative; z-index: 10; }
header h1 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; white-space: nowrap; }
header h1 .word1 { color: var(--word1); }
header h1 .word2 { color: var(--word2); }
header .tag { color: var(--muted); font-size: 13px; font-weight: 600; }
header .tagline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }   /* one line: shrinks before it wraps */
header select { font-size: 13px; font-weight: 700; padding: 8px 14px; border: none; border-radius: 999px; background: var(--field);
                color: var(--ink); max-width: 190px; box-shadow: var(--shadow-tiny); cursor: pointer; transition: box-shadow .2s ease; }
header select:hover, header select:focus { box-shadow: var(--shadow-soft), 0 0 0 3px var(--ring); outline: none; }
/* header buttons: soft pills; icon-only ones (hamburger, side panel) are round */
.hbtn { font-size: 14px; font-weight: 700; line-height: 1; min-height: 38px; padding: 0 16px; border: none; border-radius: 999px; background: var(--field);
        color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
        box-shadow: var(--shadow-tiny); transition: background .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease; }
.hbtn:hover { background: var(--glow); transform: translateY(-1px); }
/* the Experiences button and the Bazaar link in the header: two coloured pills from the Kindness Spark
   palette (green for Experiences, coral for Bazaar), soft fills so they read in light and dark mode */
.exp-btn, .bazaar-btn { font-size: 13px; font-weight: 800; letter-spacing: .2px; padding: 0 18px; text-decoration: none; white-space: nowrap; }
.exp-btn { margin-left: auto; background: var(--green-soft); color: var(--green-ink); }
.exp-btn:hover { background: var(--green-hover); box-shadow: var(--shadow-soft); }
.bazaar-btn { background: var(--coral-soft); color: var(--coral-dark); }
.bazaar-btn:hover { background: var(--coral-hover); box-shadow: var(--shadow-soft); }
/* Sparks: a link out to Kindness Spark, in its sunny yellow */
.sparks-btn { font-size: 13px; font-weight: 800; letter-spacing: .2px; padding: 0 18px; text-decoration: none; white-space: nowrap;
              background: var(--gold-soft); color: var(--gold-ink); }
.sparks-btn:hover { background: var(--gold-hover); box-shadow: var(--shadow-soft); }
.auth-btn { font-size: 13px; font-weight: 800; letter-spacing: .3px; padding: 9px 22px; border: none; border-radius: 999px;
            background: var(--coral-soft); color: var(--coral-dark); cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-tiny);
            transition: background .15s ease, box-shadow .15s ease, transform .15s ease; }
.auth-btn:hover { background: var(--coral-hover); box-shadow: var(--shadow-soft); transform: translateY(-1px); }
.auth-btn[hidden] { display: none; }
/* shown instead of the app when sign-in is required and nobody is signed in */
#signin-gate { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
               background: var(--bg) radial-gradient(ellipse farthest-side at 50% 50%, var(--glow-bg) 0%, transparent 90%); padding: 16px; }
.signin-card { max-width: 360px; width: 100%; text-align: center; padding: 28px 22px; }
.signin-card .content { font-size: 18px; margin: 0 0 18px; }
.mobile-only { display: none; }

main { display: grid; grid-template-columns: 270px 1fr 380px; gap: 0; height: calc(100vh - 64px); height: calc(100dvh - 64px); }

/* chats panel */
#threads { background: var(--side-bg); display: flex; flex-direction: column; gap: 6px; padding: 18px 14px 16px; overflow: hidden;
           box-shadow: var(--shadow-tiny); position: relative; z-index: 2; }
.new-chat { font-size: 13px; font-weight: 800; padding: 10px 12px; margin-bottom: 4px; border: none; border-radius: 10px;
            background: var(--active); color: var(--accent-ink); cursor: pointer; text-align: left; transition: background .15s ease; }
.new-chat:hover { background: var(--glow); }
/* on the blue-tinted menu, hovering lifts a row to white */
#threads .thread:hover, #threads .lib-btn:hover, #threads .foot-btn:hover { background: rgba(255, 255, 255, .8); box-shadow: var(--shadow-tiny); }
#threads .thread.active { background: var(--active); }
[data-theme="dark"] #threads .thread:hover, [data-theme="dark"] #threads .lib-btn:hover, [data-theme="dark"] #threads .foot-btn:hover { background: var(--hover); }
[data-theme="dark"] #threads .thread.active { background: var(--active); }
#thread-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; margin: 0 -4px; padding: 0 4px; }
.thread { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 10px; border-radius: 10px; cursor: pointer; color: var(--ink);
          transition: background .15s ease; }
.thread:hover { background: var(--hover); }
.thread.active { background: var(--active); }
.thread .t-main { flex: 1; min-width: 0; }
.thread .t-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread .t-snippet { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.thread .t-snippet mark { background: var(--accent-soft); color: inherit; border-radius: 3px; }
.thread .t-acts { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.thread:hover .t-acts, .thread.active .t-acts { opacity: 1; }
.thread .t-acts button { border: none; background: none; cursor: pointer; font-size: 13px; padding: 3px 4px; border-radius: 8px; color: var(--muted); }
.thread .t-acts button:hover { background: var(--panel); color: var(--ink); }
.thread .pin-on { opacity: 1 !important; }
.thread.menu-open .t-acts { opacity: 1; }
.thread .t-acts .t-more { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; }
.thread .t-acts .t-more .ico { width: 18px; height: 18px; vertical-align: 0; }
/* The menu a chat's three dots open (fixed to the page; Rename, Pin, Delete) */
.t-menu { position: fixed; z-index: 60; min-width: 190px; padding: 6px; display: flex; flex-direction: column; gap: 2px;
          background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-soft, 0 8px 28px rgba(0, 0, 0, .16)); }
.t-menu-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: none; border-radius: 9px; background: none; cursor: pointer;
               font-size: 14px; font-weight: 600; color: var(--ink); text-align: left; }
.t-menu-item:hover, .t-menu-item:focus-visible { background: var(--hover); outline: none; }
.t-menu-item .ico { width: 18px; height: 18px; vertical-align: 0; }
.t-menu-item.danger { color: var(--danger, #c0392b); }
.t-menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }
.t-group { font-size: 12px; font-weight: 700; color: var(--placeholder); margin: 14px 4px 6px; padding: 0 6px; }

/* conversation: the page's soft blue glow sits behind the chat */
#chat { display: flex; flex-direction: column; padding: 20px 28px; overflow: hidden; min-width: 0;
        background: var(--chat-bg); }
#messages { flex: 1; overflow-y: auto; padding-right: 8px; }
.msg { margin-bottom: 16px; max-width: 78%; }
.msg .who { font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--placeholder); margin-bottom: 5px; }
.msg .body { padding: 12px 16px; border-radius: 10px; line-height: 1.6; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.person { margin-left: auto; }
.msg.person .who { text-align: right; }
.msg.person .body { background: var(--bubble-user); font-weight: 600; box-shadow: var(--shadow-tiny); }
.msg.companion .body { background: var(--card); box-shadow: var(--shadow-tiny); }
.msg .body.md { white-space: normal; }
.md p { margin: 0 0 10px; }
.md p:last-child, .md ul:last-child, .md ol:last-child, .md pre:last-child { margin-bottom: 0; }
.md .h { font-weight: 800; font-size: 16px; margin: 10px 0 6px; }
.md ul, .md ol { margin: 4px 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; padding-left: 4px; }
.md code { font-family: Consolas, 'Courier New', monospace; font-size: 13px; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--pre-bg); color: var(--pre-ink); padding: 12px 14px; border-radius: 10px; overflow-x: auto; margin: 6px 0 10px; }
.md pre code { background: none; color: inherit; padding: 0; font-size: 13px; white-space: pre; }
.md a { color: var(--accent); word-break: break-all; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.md ul.checklist { list-style: none; padding-left: 4px; }
.md li.check label { cursor: pointer; display: flex; gap: 8px; align-items: flex-start; }
.md li.check input { margin-top: 4px; accent-color: var(--ok); }
.md li.check.done span { text-decoration: line-through; color: var(--muted); }
.md.typing::after { content: '▍'; color: var(--accent); }
/* The actions under a message: plain icons, as in other chat apps; a soft square appears only under the one pointed at. */
.msg .acts { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-top: 4px; opacity: .85; transition: opacity .15s; }
.msg:hover .acts { opacity: 1; }
.msg.person .acts { justify-content: flex-end; }
.msg .acts button { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 6px; border: none;
                    border-radius: 8px; background: transparent; box-shadow: none; cursor: pointer; color: var(--muted);
                    font: inherit; font-size: 12px; font-weight: 700; transition: background .15s ease, color .15s ease; }
.msg .acts button:hover { background: var(--hover); color: var(--ink); }
.msg .acts button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.msg .acts button .ico { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
                         vertical-align: 0; }
.msg .acts button.rated { color: var(--coral-dark); }
.msg .acts button.rated .ico { fill: var(--coral-soft); }
.msg.reminder .body { background: var(--warm); box-shadow: var(--shadow-tiny), inset 3px 0 0 var(--coral); }
.msg.silent { max-width: 100%; text-align: center; color: var(--muted); font-style: italic; font-size: 13px; margin: 18px 0; }
.follow-ups { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.follow-ups button { font-size: 13px; font-weight: 700; padding: 8px 14px; border: none; border-radius: 999px; background: var(--card);
                     color: var(--ink); cursor: pointer; text-align: left; box-shadow: var(--shadow-tiny);
                     transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.follow-ups button:hover { background: var(--accent-soft); transform: translateY(-1px); box-shadow: var(--shadow-soft); }
/* Kindness Bazaar helping in this chat: the page keeps the Companion's own colours; only the room's name shows - big when the
   Bazaar button opened the chat, a slim heading when Bazaar started from a question. */
.mode-hero { text-align: center; margin: 4vh auto 18px; max-width: 520px; }
.mode-brand { font-weight: 800; letter-spacing: -.2px; }
.mode-brand .word1 { color: var(--word1); }
.mode-brand .word2 { color: var(--word2); }
.mode-hero .mode-brand { font-size: 18px; }
.mode-title { margin: 12px 0 0; font-size: 26px; font-weight: 800; letter-spacing: -.3px; color: var(--ink); opacity: .78; }
/* While Kindness Bazaar is open, the other app buttons fade away and only Bazaar's stays; the sidebar marks Bazaar's chats. */
#experiences, #sparks, #guild { transition: opacity .3s ease, visibility .3s ease; }
body.mode-bazaar #experiences, body.mode-bazaar #sparks, body.mode-bazaar #campus, body.mode-bazaar #guild,
body.mode-campus #experiences, body.mode-campus #sparks, body.mode-campus #bazaar, body.mode-campus #guild,
body.mode-guild #experiences, body.mode-guild #sparks, body.mode-guild #bazaar, body.mode-guild #campus,
body.mode-sparks #experiences, body.mode-sparks #bazaar, body.mode-sparks #campus, body.mode-sparks #guild { opacity: .3; pointer-events: none; }
body.mode-experiences #sparks, body.mode-experiences #bazaar, body.mode-experiences #campus, body.mode-experiences #guild { opacity: .3; pointer-events: none; }
body.mode-bazaar #bazaar { box-shadow: 0 0 0 3px var(--ring, rgba(255, 120, 60, .35)); }
body.mode-campus #campus { box-shadow: 0 0 0 3px rgba(40, 130, 200, .35); }
.campus-btn { font-size: 13px; font-weight: 800; letter-spacing: .2px; padding: 0 18px; text-decoration: none; white-space: nowrap;
              background: #DDEEFB; color: #12507F; }
.campus-btn:hover { background: #CBE4F8; box-shadow: var(--shadow-soft); }
.t-tag-campus { background: #DDEEFB; color: #12507F; }
[data-theme="dark"] .t-tag-campus { background: #1E3A52; color: #9CCBF0; }
.t-sub { margin-top: 2px; }
.t-tag { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .02em; padding: 1px 8px; border-radius: 999px;
         background: #FFE7DA; color: #B8430C; }
[data-theme="dark"] .t-tag { background: #4A2A1C; color: #FFB38F; }
/* Bazaar's question under its message: answers so far, buttons, links, and the preferences panel. */
.bz-card { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; max-width: 560px; }
.bz-card .app-hist { margin: 0; }
.bz-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bz-card button { font: inherit; font-size: 13px; font-weight: 700; padding: 7px 14px; border: none; border-radius: 999px; cursor: pointer;
                  background: var(--accent-soft); color: var(--accent-ink); box-shadow: var(--shadow-tiny); }
.bz-card button:hover { background: var(--glow); }
.bz-card button:disabled { opacity: .5; cursor: default; }
.bz-card button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bz-card button.bz-quiet { background: transparent; box-shadow: none; color: var(--muted); font-weight: 600; text-decoration: underline; padding: 6px 4px; }
.bz-card button.bz-chip { background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.bz-card button.bz-picked { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.bz-card button.bz-edit { grid-column: 2; grid-row: 1 / span 2; padding: 4px 8px; font-size: 13px; }
.bz-panel { display: flex; flex-direction: column; gap: 14px; padding: 12px 14px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow-tiny); }
.bz-prow { display: flex; flex-direction: column; gap: 6px; }
.bz-plabel { font-size: 13px; font-weight: 700; color: var(--muted); }
.bz-pinput { font: inherit; font-size: 15px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); color: inherit; min-width: 0; }
.bz-err { color: var(--danger, #a33); font-size: 13px; font-weight: 700; }
.mode-exit { border: none; background: none; font: inherit; font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer;
             text-decoration: underline; padding: 2px 4px; }
.mode-exit:hover { color: var(--ink); }
.mode-hero .mode-exit { display: block; margin: 10px auto 0; }
header h1 { cursor: pointer; }
header h1:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.empty-chat { margin: 18vh auto 0; text-align: center; color: var(--muted); max-width: 440px; line-height: 1.7; font-size: 14px; }
.empty-chat .big { font-size: 22px; font-weight: 700; letter-spacing: -.3px; color: var(--ink); margin-bottom: 4px; }

/* composer: one pill-shaped bar, like the Kindness Spark search bar */
#composer { display: flex; gap: 10px; padding-top: 14px; align-items: center; }
#composer input { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; height: 47px; padding: 0 16px; border: none; border-radius: 999px;
                  background: var(--field); color: var(--ink); box-shadow: var(--shadow-tiny); outline: none; transition: box-shadow .2s ease; }
#composer input:hover, #composer input:focus { box-shadow: var(--shadow-soft), 0 0 0 3px var(--ring); }
#composer button { font-size: 15px; font-weight: 800; padding: 0 24px; height: 47px; border: none; border-radius: 999px;
                   background: linear-gradient(135deg, #6A9BFF 0%, var(--accent) 100%); color: #fff; cursor: pointer;
                   box-shadow: 0 6px 16px rgba(76, 111, 224, .28); transition: filter .15s ease, transform .15s ease, box-shadow .15s ease; }
#composer button#send:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 8px 20px rgba(76, 111, 224, .36); }
#composer button.icon { padding: 12px 14px; background: var(--field); color: var(--ink); }
#composer button.icon:hover { background: var(--glow); }
#composer button.mic { display: inline-flex; align-items: center; justify-content: center; padding: 9px 12px; }
#composer button.mic svg { display: block; }
#composer button.mic.recording { background: #fce8e6; animation: micpulse 1.2s ease-in-out infinite; }
#composer button.mic.recording svg path { stroke: #ea4335; }
@keyframes micpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(234,67,53,.45); } 50% { box-shadow: 0 0 0 8px rgba(234,67,53,0); } }
#composer button.recording { background: var(--danger); color: #fff; }
#composer button:disabled { opacity: .55; cursor: default; }
#composer button:disabled:hover { filter: none; transform: none; }
/* While a reply is being made, Say becomes Stop (square icon, like other chat apps). */
#composer button#send.stop { background: var(--ink); color: var(--bg); min-width: 86px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
#composer button#send.stop::before { content: ''; width: 10px; height: 10px; border-radius: 2px;
  background: currentColor; display: inline-block; }
#composer button#send.stop:hover { opacity: .88; }
#composer button#send.stop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#attachbar { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; }
#attachbar[hidden] { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 5px 12px; border: none; border-radius: 999px;
        background: var(--card); box-shadow: var(--shadow-tiny); }
.chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 8px; }
.chip button { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 0 2px; }
.chip.lib-chip { background: var(--accent-soft); }

/* Attachments beside the message box: a preview card for each (a picture you can open, or a file's type, name and
   size), each with its own ×; "3 of 5" says how many fit. Pictures sent in a chat show as thumbnails there too. */
#attachbar { gap: 12px; align-items: center; }
.att-card { position: relative; display: flex; align-items: center; gap: 10px; max-width: 250px; padding: 8px 14px 8px 8px; border-radius: 14px;
            background: var(--card); box-shadow: var(--shadow-tiny); }
.att-card.att-pic { padding: 0; }
.att-thumb { display: block; width: 72px; height: 72px; padding: 0; border: none; border-radius: 14px; overflow: hidden; background: var(--field); cursor: zoom-in; }
div.att-thumb { cursor: default; }
.att-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.att-tile { flex: none; min-width: 42px; height: 42px; padding: 0 7px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
            font-size: 11px; font-weight: 800; letter-spacing: .03em; background: var(--accent-soft); color: var(--accent-ink); }
.att-text { min-width: 0; }
.att-name { max-width: 150px; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-meta { font-size: 12px; color: var(--muted); }
.att-x { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; padding: 0; border: none; border-radius: 50%; cursor: pointer;
         display: flex; align-items: center; justify-content: center; font-size: 15px; line-height: 1; background: var(--ink); color: var(--bg);
         box-shadow: var(--shadow-tiny); }
.att-x:hover { filter: brightness(1.25); }
.att-x:focus-visible, .att-thumb:focus-visible, .msg-pic:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.att-spin { flex: none; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: attspin .8s linear infinite; }
@keyframes attspin { to { transform: rotate(360deg); } }
.att-count { font-size: 12px; font-weight: 700; color: var(--muted); }
/* What a message carried, as cards above its text (the same cards as beside the message box); your own are on the right. */
.msg-files { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.msg.person .msg-files { justify-content: flex-end; }
.msg.person .msg-files + .body { width: fit-content; margin-left: auto; }     /* the text bubble fits its text, on the right */
.msg-files .att-card { max-width: 280px; padding-right: 14px; }
.att-card.att-open { cursor: pointer; transition: background .15s ease; }
.att-card.att-open:hover { background: var(--hover); }
.att-card.att-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.att-t-pdf { background: #fde7e4; color: #d93025; }
.att-t-word { background: #e3edff; color: #2b5fd9; }
.att-t-sheet { background: #e2f4e7; color: #1e8e3e; }
.att-t-slides { background: #fdebdc; color: #d9661a; }
[data-theme="dark"] .att-t-pdf { background: #3a2320; color: #ff8a80; }
[data-theme="dark"] .att-t-word { background: #1f2d4d; color: #8fb0ff; }
[data-theme="dark"] .att-t-sheet { background: #1f3a28; color: #7fd69a; }
[data-theme="dark"] .att-t-slides { background: #3d2c1c; color: #ffb066; }
/* The viewer: a file opened from a message. */
#viewer { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0, 0, 0, .6); }
.vw-panel { display: flex; flex-direction: column; width: min(96vw, 980px); height: min(90vh, 900px); overflow: hidden; border-radius: 18px;
            background: var(--panel); box-shadow: 0 18px 60px rgba(0, 0, 0, .35); }
.vw-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.vw-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vw-dl { font-size: 13px; font-weight: 700; padding: 7px 14px; border: none; border-radius: 999px; background: var(--accent); color: #fff; cursor: pointer; }
.vw-dl:hover { filter: brightness(1.08); }
.vw-x { width: 34px; height: 34px; padding: 0; border: none; border-radius: 50%; background: var(--field); color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer; }
.vw-x:hover { background: var(--hover); }
.vw-body { flex: 1; min-height: 0; display: flex; overflow: auto; }
.vw-body iframe { flex: 1; width: 100%; height: 100%; border: 0; background: #fff; }
.vw-body pre { width: 100%; margin: 0; padding: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.55 ui-monospace, Consolas, monospace; }
.vw-body audio { margin: auto; width: min(90%, 480px); }
.vw-note { margin: auto; padding: 20px; text-align: center; font-size: 14px; color: var(--muted); }
.msg-pic { display: block; padding: 0; border: none; border-radius: 12px; overflow: hidden; background: none; cursor: zoom-in; }
.msg-pic img { display: block; max-width: 200px; max-height: 200px; object-fit: cover; border-radius: 12px; }
.pic-gone { font-size: 12px; color: var(--muted); }
#lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
            padding: 24px; background: rgba(0, 0, 0, .8); }
#lightbox[hidden] { display: none; }
#lightbox img { max-width: min(92vw, 1100px); max-height: 80vh; object-fit: contain; border-radius: 12px; background: #fff; }
.lb-name { color: #fff; font-size: 14px; font-weight: 700; text-align: center; overflow-wrap: anywhere; }
.lb-x { position: absolute; top: 14px; right: 18px; width: 40px; height: 40px; border: none; border-radius: 50%; cursor: pointer; font-size: 24px;
        line-height: 1; background: rgba(255, 255, 255, .16); color: #fff; }
.lb-x:hover { background: rgba(255, 255, 255, .3); }
.lb-dl { padding: 8px 18px; border: none; border-radius: 999px; background: rgba(255, 255, 255, .18); color: #fff; font-size: 13px; font-weight: 700; cursor: pointer; }
.lb-dl:hover { background: rgba(255, 255, 255, .32); }
.lb-dl[hidden] { display: none; }
/* The camera window (a computer): a live view, then the photo that was taken. */
#camera-box { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .6); }
.cm-panel { display: flex; flex-direction: column; width: min(100%, 720px); max-height: 100%; overflow: hidden; border-radius: 18px;
            background: var(--panel); box-shadow: 0 18px 60px rgba(0, 0, 0, .35); }
.cm-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.cm-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 800; }
.cm-x { width: 34px; height: 34px; padding: 0; border: none; border-radius: 50%; background: var(--field); color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer; }
.cm-x:hover { background: var(--hover); transform: none; }
.cm-view { position: relative; display: flex; align-items: center; justify-content: center; height: min(56vh, 480px); min-height: 160px; flex: 0 1 auto; background: #000; }
.cm-view video, .cm-view img { width: 100%; height: 100%; object-fit: contain; }
.cm-view video[hidden], .cm-view img[hidden], .cm-note[hidden] { display: none; }
.cm-note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; text-align: center; font-size: 14px; line-height: 1.5; color: #fff; }
.cm-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding: 12px 14px; }
.cm-btn { font-size: 14px; font-weight: 700; padding: 9px 20px; border: 1px solid var(--line); border-radius: 999px; background: var(--field); color: var(--ink); cursor: pointer; }
.cm-btn:hover { background: var(--hover); transform: none; }
.cm-btn.cm-main { border-color: var(--accent); background: var(--accent); color: #fff; }
.cm-btn.cm-main:hover { filter: brightness(1.08); }
.cm-btn[hidden] { display: none; }
#dropzone { position: fixed; inset: 12px; z-index: 900; display: flex; align-items: center; justify-content: center; pointer-events: none;
            border: 2px dashed var(--accent); border-radius: 22px; font-size: 20px; font-weight: 800; color: var(--accent-ink);
            background: color-mix(in srgb, var(--bg) 82%, transparent); }
#dropzone[hidden] { display: none; }

/* Library: sidebar entry, screen, paperclip menu */
.lib-btn { font-size: 14px; font-weight: 700; padding: 9px 10px; border: none; border-radius: 10px; background: transparent; color: var(--ink);
           cursor: pointer; text-align: left; transition: background .15s ease; }
.lib-btn:hover { background: var(--hover); }
.lib-btn.active { background: var(--active); color: var(--accent-ink); }
#chat.lib-open > :not(#library-view) { display: none; }
#library-view { flex: 1; display: flex; flex-direction: column; gap: 12px; overflow: hidden; min-height: 0; }
#library-view[hidden] { display: none; }
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lib-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.lib-close, .lib-upload, .lib-act { font-size: 13px; font-weight: 700; padding: 8px 14px; border: none; border-radius: 999px; background: var(--card);
                                    color: var(--ink); cursor: pointer; box-shadow: var(--shadow-tiny);
                                    transition: background .15s ease, color .15s ease, transform .15s ease; }
.lib-upload { background: var(--accent); color: #fff; }
.lib-upload:hover { filter: brightness(1.06); transform: translateY(-1px); }
.lib-close:hover, .lib-act:hover { background: var(--glow); }
.lib-close:hover { transform: translateY(-1px); }
.lib-act.danger:hover { background: var(--badge-bad); color: var(--danger); }
/* ---- The Library page: a header with a title, an info card and a scope chip; one rounded bar of filters; roomy cards (grid) or rows
   (list) whose actions show on hover; and a small bar that floats at the bottom while files are being chosen. ---- */
#library-view { position: relative; gap: 14px; }
.lib-title { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.lib-title h2 { font-size: 26px; letter-spacing: -.4px; }
.lib-logo { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.lib-logo .ico { width: 22px; height: 22px; }
.lib-info-btn { width: 22px; height: 22px; padding: 0; flex: none; border-radius: 50%; border: 1.5px solid var(--muted); background: transparent; color: var(--muted);
                font: italic 700 12px/1 Georgia, "Times New Roman", serif; cursor: pointer; display: grid; place-items: center; transition: background .15s ease, color .15s ease, border-color .15s ease; }
.lib-info-btn:hover, .lib-info-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.lib-scope { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px; background: var(--card);
             border: 1px solid var(--line); color: var(--green-ink); box-shadow: var(--shadow-tiny); white-space: nowrap; }
.lib-scope .ico { width: 13px; height: 13px; }
.lib-scope:empty, .lib-scope > span:empty { display: none; }
.lib-head-acts { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#library-view #lib-status:empty { display: none; }
#library-view .lib-close { background: var(--card); border: 1px solid var(--line); box-shadow: none; }
#library-view .lib-close:hover { background: var(--hover); }
#library-view .lib-upload { padding: 9px 18px; box-shadow: 0 6px 16px rgba(76, 111, 224, .28); }
/* the info card under the "i" */
.lib-info-card { position: absolute; top: calc(100% + 8px); left: 0; z-index: 30; width: min(392px, calc(100vw - 40px)); padding: 16px 18px; border-radius: 18px;
                 background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-pop); }
.lib-info-card[hidden] { display: none; }
.lib-info-head { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 800; }
.lib-info-head .lock { width: 18px; height: 18px; color: var(--accent); }
.lib-info-x { margin-left: auto; width: 28px; height: 28px; padding: 0; border: none; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
              display: grid; place-items: center; }
.lib-info-x:hover { background: var(--hover); color: var(--ink); }
.lib-info-card p { margin: 10px 0 12px; font-size: 14px; line-height: 1.55; }
.lib-info-ctx { padding: 11px 13px; border-radius: 12px; background: var(--accent-soft); font-size: 13.5px; line-height: 1.5; }
.lib-info-ctx:empty { display: none; }
/* one bar: filters with their numbers, search, Select, grid or list */
.lib-bar { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 20px;
           box-shadow: var(--shadow-tiny); flex-wrap: wrap; }
.lib-kinds { display: flex; gap: 4px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.lib-kinds::-webkit-scrollbar { display: none; }
.lib-kind { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: none; border-radius: 999px; background: transparent; color: var(--ink);
            font: 700 13px/1 inherit; font-family: inherit; cursor: pointer; white-space: nowrap; transition: background .15s ease, color .15s ease; }
.lib-kind:hover { background: var(--hover); }
.lib-kind[aria-pressed="true"] { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(76, 111, 224, .3); }
.lib-count { min-width: 20px; padding: 2px 7px; border-radius: 999px; background: var(--hover); color: var(--muted); font-size: 11px; font-weight: 800; text-align: center; }
.lib-count[hidden] { display: none; }
.lib-kind[aria-pressed="true"] .lib-count { background: rgba(255, 255, 255, .28); color: #fff; }
.lib-bar .lib-search { flex: 0 1 230px; min-width: 150px; }
.lib-bar .lib-search input { box-shadow: none; border: 1px solid var(--line); }
.lib-select-btn { padding: 8px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font: 700 13px/1 inherit; font-family: inherit; cursor: pointer; }
.lib-select-btn:hover { background: var(--hover); }
.lib-select-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
.lib-select-btn:disabled { opacity: .5; cursor: default; }
.lib-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--hover); }
.lib-seg button { width: 34px; height: 30px; padding: 0; border: none; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.lib-seg button[aria-pressed="true"] { background: var(--accent); color: #fff; box-shadow: 0 3px 8px rgba(76, 111, 224, .3); }
/* the files */
#lib-list { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 4px 80px; }
#lib-list.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; align-content: start; }
#lib-list.lib-rows { display: flex; flex-direction: column; gap: 10px; }
.lib-file { position: relative; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-tiny); cursor: pointer; outline: none;
            transition: box-shadow .18s ease, border-color .18s ease, background .18s ease; }
.lib-file:hover, .lib-file:focus-within { box-shadow: 0 10px 28px rgba(76, 111, 224, .16); border-color: var(--glow); }
.lib-file:focus-visible { box-shadow: 0 0 0 3px var(--ring); }
.lib-file.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.lib-thumb { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; height: 150px; overflow: hidden;
             border-radius: 17px 17px 0 0; background: var(--hover); color: var(--accent); }
.lib-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lib-glyph { width: 46px; height: 46px; border-radius: 14px; background: var(--card); box-shadow: 0 4px 12px rgba(45, 42, 38, .1); display: grid; place-items: center; }
.lib-glyph .ico { width: 22px; height: 22px; }
.lib-badge { padding: 2px 10px; border-radius: 999px; background: var(--card); color: var(--accent-ink); font-size: 11px; font-weight: 800; letter-spacing: .3px; }
.lib-wave { display: inline-flex; align-items: flex-end; gap: 3px; height: 14px; }
.lib-wave i { width: 3px; border-radius: 2px; background: currentColor; opacity: .55; }
.lib-wave i:nth-child(1) { height: 6px; } .lib-wave i:nth-child(2) { height: 11px; } .lib-wave i:nth-child(3) { height: 14px; }
.lib-wave i:nth-child(4) { height: 9px; } .lib-wave i:nth-child(5) { height: 5px; }
.lib-thumb[data-tone="audio"] { background: linear-gradient(180deg, #f1edff, #faf8ff); color: #6b4fd8; }
.lib-thumb[data-tone="word"] { background: linear-gradient(180deg, #e8f0ff, #f5f8ff); color: #2b5fd9; }
.lib-thumb[data-tone="pdf"] { background: linear-gradient(180deg, #ffecec, #fff7f7); color: #e0314b; }
.lib-thumb[data-tone="sheet"] { background: linear-gradient(180deg, #e5f6ea, #f4fcf7); color: #1e8e3e; }
.lib-thumb[data-tone="slides"] { background: linear-gradient(180deg, #ffefe0, #fff9f2); color: #d9661a; }
.lib-thumb[data-tone="video"] { background: linear-gradient(180deg, #e4f4fb, #f4fafd); color: #1a7fa8; }
.lib-thumb[data-tone="archive"] { background: linear-gradient(180deg, #fff4d9, #fffaf0); color: #b7791f; }
[data-theme="dark"] .lib-thumb[data-tone="audio"] { background: linear-gradient(180deg, #2a2545, #232037); color: #b4a2ff; }
[data-theme="dark"] .lib-thumb[data-tone="word"] { background: linear-gradient(180deg, #1f2d4d, #1c2740); color: #8fb0ff; }
[data-theme="dark"] .lib-thumb[data-tone="pdf"] { background: linear-gradient(180deg, #3a2320, #2f1f1d); color: #ff8a80; }
[data-theme="dark"] .lib-thumb[data-tone="sheet"] { background: linear-gradient(180deg, #1f3a28, #1b3023); color: #7fd69a; }
[data-theme="dark"] .lib-thumb[data-tone="slides"] { background: linear-gradient(180deg, #3d2c1c, #31241a); color: #ffb066; }
[data-theme="dark"] .lib-thumb[data-tone="video"] { background: linear-gradient(180deg, #1c3340, #192c37); color: #6cc4e8; }
[data-theme="dark"] .lib-thumb[data-tone="archive"] { background: linear-gradient(180deg, #3a3120, #2f281b); color: #f2c14e; }
.lib-info { padding: 13px 16px 15px; min-width: 0; }
.lib-name { font-size: 14px; font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lib-m1 { display: flex; justify-content: space-between; gap: 8px; margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--ink); }
.lib-m1 span:last-child { color: var(--muted); }
.lib-m2 { display: flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 11.5px; font-weight: 600; color: var(--green-ink); }
.lib-m2 .ico { width: 12px; height: 12px; flex: none; }
.lib-m2 span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the circle to pick a file (on hover, and while choosing) */
.lib-pick { position: absolute; top: 10px; left: 10px; z-index: 3; width: 26px; height: 26px; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .15s ease; }
.lib-file:hover .lib-pick, .lib-file:focus-within .lib-pick, .lib-file.selected .lib-pick, #lib-list.selecting .lib-pick { opacity: 1; }
.lib-check { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.lib-circle { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); background: var(--card); box-shadow: 0 2px 6px rgba(45, 42, 38, .15); display: grid; place-items: center;
              transition: background .15s ease, border-color .15s ease; pointer-events: none; }
.lib-circle::after { content: ""; width: 9px; height: 5px; margin-top: -2px; border-left: 2.2px solid #fff; border-bottom: 2.2px solid #fff; transform: rotate(-45deg) scale(0); transition: transform .15s ease; }
.lib-check:checked + .lib-circle { background: var(--accent); border-color: var(--accent); }
.lib-check:checked + .lib-circle::after { transform: rotate(-45deg) scale(1); }
.lib-check:focus-visible + .lib-circle { box-shadow: 0 0 0 3px var(--ring); }
/* what can be done with a file: shown on hover (always where there is no hover) */
.lib-hover { position: absolute; top: 10px; right: 10px; z-index: 3; display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px; background: var(--card);
             box-shadow: 0 4px 14px rgba(45, 42, 38, .16); opacity: 0; transform: translateY(-3px); pointer-events: none; transition: opacity .15s ease, transform .15s ease; }
.lib-file:hover .lib-hover, .lib-file:focus-within .lib-hover { opacity: 1; transform: none; pointer-events: auto; }
.lib-hbtn { height: 30px; min-width: 30px; padding: 0 9px; border: none; border-radius: 999px; background: transparent; color: var(--ink); font: 700 12.5px/1 inherit; font-family: inherit;
            display: inline-flex; align-items: center; justify-content: center; gap: 5px; cursor: pointer; white-space: nowrap; }
.lib-hbtn .ico { width: 16px; height: 16px; }
.lib-hbtn:hover { background: var(--hover); color: var(--accent-ink); }
.lib-hbtn.add { color: var(--accent-ink); padding: 0 11px 0 9px; }
.lib-hbtn.danger:hover { background: var(--badge-bad); color: var(--danger); }
@media (hover: none) {
  .lib-hover { opacity: 1; transform: none; pointer-events: auto; }
  .lib-pick { opacity: 1; }
}
/* list view: one row per file */
#lib-list.lib-rows .lib-file { display: grid; grid-template-columns: 26px 48px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px 16px; border-radius: 16px; }
#lib-list.lib-rows .lib-pick { position: static; }
#lib-list.lib-rows .lib-thumb { width: 48px; height: 48px; border-radius: 12px; gap: 0; }
#lib-list.lib-rows .lib-thumb .lib-badge, #lib-list.lib-rows .lib-thumb .lib-wave { display: none; }
#lib-list.lib-rows .lib-glyph { width: 100%; height: 100%; border-radius: 12px; background: transparent; box-shadow: none; }
#lib-list.lib-rows .lib-info { padding: 0; }
#lib-list.lib-rows .lib-name { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#lib-list.lib-rows .lib-m1 { display: inline; margin: 0; padding: 0; border: none; font-weight: 600; color: var(--muted); }
#lib-list.lib-rows .lib-m1 span:last-child::before { content: " · "; }
#lib-list.lib-rows .lib-m2 { display: inline-flex; margin: 0 0 0 6px; }
#lib-list.lib-rows .lib-m2::before { content: "·"; color: var(--muted); margin-right: 2px; }
#lib-list.lib-rows .lib-meta-row { display: flex; align-items: center; flex-wrap: wrap; margin-top: 3px; }
#lib-list.lib-rows .lib-hover { position: static; background: transparent; box-shadow: none; padding: 0; gap: 4px; transform: none; }
#lib-list.lib-rows .lib-hbtn.add { background: var(--accent-soft); }
#lib-list.lib-rows .lib-hbtn.add:hover { background: var(--active); }
@media (max-width: 760px) {
  #library-view .lib-title h2 { font-size: 22px; }
  #lib-list.lib-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .lib-thumb { height: 120px; }
  #lib-list.lib-grid .lib-hbtn.add .lbl { display: none; }                        /* a small card shows only the + */
  #lib-list.lib-grid .lib-hbtn.add { padding: 0; width: 30px; }
  #lib-list.lib-grid .lib-hover { right: 8px; top: 8px; }
  #lib-list.lib-rows .lib-file { grid-template-columns: 26px 44px minmax(0, 1fr); }
  #lib-list.lib-rows .lib-hover { grid-column: 2 / -1; }
  .lib-bar .lib-search { flex: 1 1 100%; order: 3; }
}
/* what is shown below the files: how many, Load more, and how full the Library is */
.lib-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 6px 0; border-top: 1px solid var(--line); min-height: 40px; }
.lib-more-btn { padding: 7px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font: 700 13px/1 inherit; font-family: inherit; cursor: pointer; box-shadow: var(--shadow-tiny); }
.lib-more-btn:hover { background: var(--hover); color: var(--accent-ink); }
.lib-more-btn[hidden] { display: none; }
.lib-meter { margin-left: auto; display: flex; align-items: center; gap: 12px; max-width: 100%; }
.lib-meter[hidden] { display: none; }
.lib-meter-text { display: flex; align-items: baseline; gap: 8px; font-size: 12px; font-weight: 700; color: var(--ink); white-space: nowrap; }
#lib-meter-note { font-weight: 600; color: var(--muted); }
#lib-meter-note:empty { display: none; }
.lib-meter-bar { width: 96px; height: 6px; border-radius: 999px; background: var(--active); overflow: hidden; flex: none; }
.lib-meter-bar > span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .3s ease, background .2s ease; }
.lib-meter.warn .lib-meter-bar > span { background: #e0a030; }
.lib-meter.full .lib-meter-bar > span { background: var(--danger, #c0392b); }
.lib-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 18px 4px; }
.lib-empty strong { font-size: 17px; font-weight: 800; }
.lib-empty-ico { width: 36px; height: 36px; color: var(--muted); stroke-width: 1.4; }
/* the small bar that floats while files are being chosen (white and blue, like the rest of the Companion) */
.lib-selbar { position: absolute; left: 50%; bottom: 60px; transform: translateX(-50%); z-index: 20; display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 4px;
              width: max-content; max-width: calc(100% - 24px); padding: 8px 10px 8px 18px; border-radius: 26px; background: var(--card); border: 1px solid var(--line);
              box-shadow: 0 14px 40px rgba(45, 42, 38, .22), 0 0 0 1px rgba(76, 111, 224, .08); }
.lib-selbar[hidden] { display: none; }
.lib-sel-count { padding-right: 12px; margin-right: 4px; border-right: 1px solid var(--line); font-size: 14px; font-weight: 800; color: var(--accent-ink); white-space: nowrap; }
.lib-sel-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: none; border-radius: 999px; background: transparent; color: var(--ink);
               font: 700 13px/1 inherit; font-family: inherit; cursor: pointer; white-space: nowrap; transition: background .15s ease, color .15s ease; }
.lib-sel-btn .ico { width: 16px; height: 16px; }
.lib-sel-btn:hover:not(:disabled) { background: var(--hover); color: var(--accent-ink); }
.lib-sel-btn.primary { background: var(--accent); color: #fff; }
.lib-sel-btn.primary:hover:not(:disabled) { background: var(--accent); color: #fff; filter: brightness(1.08); }
.lib-sel-btn.danger { color: var(--danger); }
.lib-sel-btn.danger:hover:not(:disabled) { background: var(--badge-bad); color: var(--danger); }
.lib-sel-btn.done { background: var(--accent-soft); color: var(--accent-ink); }
.lib-sel-btn:disabled { opacity: .45; cursor: default; }
.lib-sel-btn[hidden] { display: none; }
#lib-status.error { color: var(--danger); }
/* Icons: small stroke icons from the inline sprite; they take the text color */
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.lib-btn, .lib-act, .lib-upload, .lib-close { display: inline-flex; align-items: center; gap: 8px; }
.lib-head h2 { display: inline-flex; align-items: center; gap: 8px; }
.lib-head h2 .ico { width: 22px; height: 22px; color: var(--accent); }
/* One search box look for Chats and Library: magnifier inside the field */
.searchbox { position: relative; display: flex; align-items: center; }
.searchbox .ico { position: absolute; left: 13px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.searchbox input { width: 100%; font-size: 13px; font-weight: 600; padding: 9px 12px 9px 36px; border: none; border-radius: 999px; background: var(--field);
                   color: var(--ink); box-shadow: var(--shadow-tiny); outline: none; transition: box-shadow .2s ease, background .2s ease; }
.searchbox input:focus { background: var(--field); box-shadow: var(--shadow-tiny), 0 0 0 3px var(--ring); }
.lib-pick-note { padding: 10px 14px; border: none; border-radius: 14px; background: var(--accent-soft); color: var(--ink); font-size: 14px; }
.lib-pick-note:empty { display: none; }
.lib-pick-note[hidden] { display: none; }
#composer { position: relative; }
/* The message box: the + is inside it, at the left (like ChatGPT), so there is no separate button. */
.msgfield { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.msgfield #text { width: 100%; height: 56px; padding-left: 58px; padding-right: 100px; text-overflow: ellipsis; }
@media (max-width: 480px) { .msgfield #text { font-size: 13px; padding-left: 52px; padding-right: 94px; } }   /* the whole hint stays visible on a phone */
/* ...and so is the mic, at the right end of the same box (round buttons, as in Kindness Spark). */
#composer .msgfield #mic { position: absolute; right: 49px; top: 50%; margin-top: -19px; width: 38px; height: 38px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; border: none; border-radius: 8px;
  background: transparent; box-shadow: none; cursor: pointer; transition: background .15s ease; }
#composer .msgfield #mic:hover { background: var(--hover); transform: none; }
#composer .msgfield #mic:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#composer .msgfield #mic.recording { background: #fce8e6; }
#composer .msgfield #mic { color: var(--ink); }   /* black in light mode, white in dark mode */
#composer .msgfield #mic svg { width: 19px; height: 19px; display: block; }
/* The send arrow: a round button at the very end of the message box (it becomes a square Stop while a reply is made). */
#composer .msgfield #send { position: absolute; right: 5px; top: 50%; margin-top: -19px; width: 38px; height: 38px; min-width: 0; padding: 0; gap: 0;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
#composer .msgfield #send .ico { width: 20px; height: 20px; stroke-width: 2.2; vertical-align: 0; }
#composer .msgfield #send:hover { transform: none; }
#composer .msgfield #send.stop { min-width: 0; gap: 0; }   /* a small round Stop, not the old wide one */
#composer .msgfield #attach { position: absolute; left: 5px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); box-shadow: none; cursor: pointer; transition: background .15s ease, color .15s ease; }
#composer .msgfield #attach .ico { width: 19px; height: 19px; stroke-width: 2; vertical-align: 0; }
#composer .msgfield #attach:hover, #composer .msgfield #attach[aria-expanded="true"] { background: var(--hover); color: var(--ink); }
#composer .msgfield #attach:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#attach-menu { position: absolute; bottom: calc(100% + 10px); left: 0; min-width: 230px; display: flex; flex-direction: column; gap: 2px; padding: 6px;
               background: var(--card); border-radius: 14px; box-shadow: var(--shadow-pop); z-index: 5; }
#attach-menu[hidden] { display: none; }
#composer #attach-menu button { display: flex; align-items: center; gap: 12px; height: auto; border-radius: 10px; background: none; color: var(--ink);
                                padding: 10px 12px; text-align: left; font-size: 14px; font-weight: 700; white-space: nowrap; box-shadow: none; }
#composer #attach-menu button .ico { width: 18px; height: 18px; vertical-align: 0; color: var(--muted); }
#composer #attach-menu button:hover, #composer #attach-menu button:focus-visible { background: var(--hover); color: var(--ink); outline: none; }
#composer #attach-menu button:hover .ico { color: var(--ink); }
/* A message that is sent but not answered yet: your words are in the chat at once,
   and "Thinking" with moving dots holds the place of the answer (like ChatGPT). */
.msg.inflight.person .body { white-space: pre-wrap; }
.thinking { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-style: italic; }
.thinking .dots { display: inline-flex; align-items: center; gap: 4px; }
.thinking .dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .25; animation: kcdot 1.2s infinite ease-in-out both; }
.thinking .dots span:nth-child(2) { animation-delay: .18s; }
.thinking .dots span:nth-child(3) { animation-delay: .36s; }
@keyframes kcdot { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .thinking .dots span { animation: none; opacity: .6; } }

/* memory side panel */
#side { background: var(--side-bg); overflow-y: auto; padding: 20px; box-shadow: var(--shadow-tiny); position: relative; z-index: 2; }
#side h2 { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--placeholder); margin: 24px 0 10px; }
#side h2:first-child { margin-top: 0; }
.card { border: none; border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; font-size: 14px; background: var(--card); box-shadow: var(--shadow-tiny); }
.card .layer { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.card .content { margin: 6px 0; line-height: 1.5; }
.card .why { font-size: 12px; color: var(--muted); font-style: italic; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; margin-left: 6px; }
.badge.hypothesis { background: var(--badge-hyp); color: var(--hyp); }
.badge.confirmed, .badge.narrowed { background: var(--badge-ok); color: var(--ok); }
.badge.granted { background: var(--badge-ok); color: var(--ok); }
.badge.revoked { background: var(--badge-bad); color: var(--danger); }
.controls { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.controls button { font-size: 12px; font-weight: 700; padding: 5px 12px; border: none; border-radius: 999px; background: var(--hover); cursor: pointer;
                   color: var(--ink); transition: background .15s ease, color .15s ease; }
.controls button:hover { background: var(--glow); }
.controls button.forget:hover { background: var(--badge-bad); color: var(--danger); }
.note { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 6px 0 14px; }
.pending { background: var(--warm); box-shadow: var(--shadow-tiny), inset 3px 0 0 var(--coral); }
.run .st { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
#auditline { font-size: 11px; color: var(--placeholder); margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--line); }
#systemline { font-size: 12px; color: var(--muted); padding-top: 8px; min-height: 18px; font-style: italic; text-align: center; }
#systemline.error { color: var(--danger); }
#backdrop { position: fixed; inset: 0; background: var(--shadow); z-index: 40; }
#backdrop[hidden] { display: none; }

/* medium screens: the memory panel becomes a drawer */
@media (max-width: 1200px) {
  main { grid-template-columns: 250px 1fr; }
  #toggle-side { display: inline-flex; }
  #side { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 88vw); z-index: 50;
          transform: translateX(105%); transition: transform .22s ease; box-shadow: var(--shadow-pop); }
  #side.open { transform: none; }
}

/* phones: chats become a drawer too; compact header and composer */
@media (max-width: 760px) {
  header { padding: 10px 12px; gap: 8px; flex-wrap: wrap; min-height: 56px; }
  header h1 { font-size: 18px; flex: 1; }
  header .tagline, header .tag { display: none; }
  header select { font-size: 13px; padding: 6px 10px; max-width: 42vw; }
  .exp-btn, .bazaar-btn { order: 10; font-size: 12px; min-height: 34px; padding: 0 12px; }
  .exp-btn { margin-left: 0; }
  #ctx { order: 11; }
  .auth-btn { font-size: 12px; padding: 7px 14px; order: 12; }
  #ctx { max-width: 34vw; }
  .mobile-only { display: inline-flex; }
  main { grid-template-columns: 1fr; height: auto; min-height: calc(100dvh - 100px); }
  #threads { position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 86vw); z-index: 50;
             transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow-pop);
             padding-top: calc(16px + env(safe-area-inset-top)); }
  #threads.open { transform: none; }
  .thread .t-acts { opacity: 1; }
  #chat { padding: 10px 10px calc(8px + env(safe-area-inset-bottom)); height: calc(100dvh - 100px); }
  .msg { max-width: 92%; }
  .msg .body { font-size: 15px; padding: 10px 13px; }
  .msg .acts { opacity: 1; }
  #composer { gap: 6px; padding-top: 10px; }
  #composer input { font-size: 16px; }  /* 16px stops phones zooming in */
  #composer button { padding: 0 16px; }
  #composer button.icon { padding: 10px 11px; }
}
/* very narrow phones: SIGN IN still fits beside the selectors */
@media (max-width: 380px) {
  #ctx { max-width: 27vw; }
  .auth-btn { font-size: 12px; padding: 6px 10px; }
}

/* thumbs, "Still true?" card, settings */
.fbwrap { display: inline-flex; gap: 2px; align-items: center; }
.card.still-true { background: var(--coral-soft); margin-bottom: 18px; box-shadow: var(--shadow-tiny), inset 3px 0 0 var(--coral); }
.card.still-true .layer { color: var(--coral-dark); }
.still-change { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.still-change label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.still-change input { font: inherit; font-size: 14px; font-weight: 600; padding: 8px 12px; border: none; border-radius: 10px;
                      background: var(--field); color: var(--ink); box-shadow: var(--shadow-tiny); }
#settings .setting { display: flex; align-items: center; gap: 10px; font-size: 14px; margin: 8px 0; cursor: pointer; }
#settings .setting input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Hamburger: opens and closes the chat history panel (desktop: collapses the
   column and remembers it; phones: slides the drawer in and out). */
.hamburger { display: inline-flex; flex-direction: column; justify-content: center; gap: 4px; width: 38px; height: 38px; min-height: 0; padding: 0 11px;
             background: transparent; box-shadow: none; border-radius: 50%; }
.hamburger:hover { background: var(--glow); transform: none; }
.hamburger span { display: block; height: 2px; width: 100%; background: var(--ink); border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }
.hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
body.threads-collapsed #threads { display: none; }
body.threads-collapsed main { grid-template-columns: 1fr 380px; }
@media (max-width: 1200px) {
  body.threads-collapsed main { grid-template-columns: 1fr; }
}
/* the right-hand panel can be hidden and shown (wide screens; on smaller ones it is a drawer anyway) */
@media (min-width: 1201px) {
  body.side-collapsed main { grid-template-columns: 270px 1fr; }
  body.side-collapsed #side { display: none; }
  body.threads-collapsed.side-collapsed main { grid-template-columns: 1fr; }
}
#toggle-side { width: 38px; height: 38px; min-height: 0; padding: 0; border-radius: 50%; }
#toggle-side.active { background: var(--accent-soft); color: var(--accent-ink); }
#toggle-side .ico { width: 19px; height: 19px; display: block; }
@media (max-width: 760px) {
  /* phones always use the drawer, whatever the desktop choice */
  body.threads-collapsed #threads { display: flex; }
  body.threads-collapsed main { grid-template-columns: 1fr; }
}

/* Memory & Trust: Memory Center, Context Manager, Goals, Trust (one view) */
#chat.you-open > :not(#you-view) { display: none; }
#you-view { flex: 1; display: flex; flex-direction: column; gap: 12px; overflow: hidden; min-height: 0; }
#you-view[hidden] { display: none; }
.you-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.you-tabs button { font-size: 13px; font-weight: 700; padding: 8px 16px; border: none; border-radius: 999px; background: var(--card); color: var(--ink);
                   cursor: pointer; box-shadow: var(--shadow-tiny); transition: background .15s ease, color .15s ease; }
.you-tabs button:hover { background: var(--glow); }
.you-tabs button.active { background: var(--accent-soft); color: var(--accent-ink); }
#you-status { font-size: 13px; color: var(--muted); min-height: 18px; }
#you-status.error { color: var(--danger); }
.you-body { flex: 1; overflow-y: auto; padding: 2px 6px 6px 2px; min-height: 0; }
.you-body h3 { font-size: 16px; font-weight: 800; margin: 20px 0 8px; }
.you-body h3:first-child { margin-top: 4px; }
.you-body .meta { font-size: 12px; color: var(--muted); line-height: 1.6; }
.you-body .meta b { color: var(--ink); font-weight: 700; }
.you-body ul.plain { margin: 4px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.6; }
.you-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 12px; }
.you-form input, .you-form select, .you-form textarea { font-size: 14px; padding: 8px 12px; border: none; border-radius: 10px; background: var(--field);
                                                        color: var(--ink); min-width: 0; box-shadow: var(--shadow-tiny); outline: none; }
.you-form input:focus, .you-form select:focus, .you-form textarea:focus { box-shadow: var(--shadow-tiny), 0 0 0 3px var(--ring); }
.you-form input[type=text], .you-form textarea { flex: 1 1 220px; }
.you-form textarea { min-height: 56px; resize: vertical; }
.you-form label { font-size: 12px; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; gap: 4px; flex: 1 1 220px; }
.you-form button, .preview-actions button { font-size: 13px; font-weight: 700; padding: 8px 16px; border: none; border-radius: 999px; background: var(--card);
                                            color: var(--ink); cursor: pointer; box-shadow: var(--shadow-tiny); transition: background .15s ease; }
.you-form button:hover, .preview-actions button:hover { background: var(--glow); }
.you-form button.primary, .preview-actions button.primary { background: var(--accent); color: #fff; }
.you-form button.primary:hover, .preview-actions button.primary:hover { background: var(--accent); filter: brightness(1.06); }
.tag-now { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); margin-left: 6px; }
.badge.paused, .badge.proposed, .badge.waiting { background: var(--badge-hyp); color: var(--hyp); }
.badge.active, .badge.live { background: var(--badge-ok); color: var(--ok); }
.badge.ended, .badge.stopped, .badge.declined, .badge.expired, .badge.failed { background: var(--badge-bad); color: var(--danger); }
.preview dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 8px 0; font-size: 13px; }
.preview dt { color: var(--muted); }
.preview dd { margin: 0; overflow-wrap: anywhere; }
.preview-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ctxline { font-size: 13px; color: var(--muted); padding: 2px 2px 10px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.ctxline b { color: var(--ink); font-weight: 800; }
.ctxline button { font-size: 12px; font-weight: 700; padding: 4px 12px; border: none; border-radius: 999px; background: var(--card); color: var(--ink);
                  cursor: pointer; box-shadow: var(--shadow-tiny); transition: background .15s ease; }
.ctxline button:hover { background: var(--glow); }
.ctxline:empty { display: none; }
details.cont { font-size: 12px; color: var(--muted); margin: 6px 0 2px; }
details.cont summary { cursor: pointer; }
details.cont ul { margin: 4px 0 0; padding-left: 18px; line-height: 1.5; }
@media (max-width: 760px) { .preview dl { grid-template-columns: 1fr; } .preview dt { margin-top: 4px; } }
.linkish { font-size: 12px; font-weight: 700; padding: 4px 12px; border: none; border-radius: 999px; background: var(--field); color: var(--ink); cursor: pointer;
           box-shadow: var(--shadow-tiny); transition: background .15s ease; }
.linkish:hover { background: var(--glow); }

/* Side panel as a summary; Spark offers; Library use line */
/* Presence (how far the Companion may come forward) and time horizons */
.horizon-head { margin: 18px 0 4px; font-size: 15px; font-weight: 800; }
.horizon-head .meta { font-weight: 600; margin-left: 6px; font-size: 12px; }
.horizon-empty { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.goal-horizon { font-size: 12px; margin-top: 8px; display: flex; gap: 6px; align-items: center; color: var(--muted); }
.goal-horizon select { font: inherit; font-size: 12px; padding: 3px 10px; border: none; border-radius: 999px; background: var(--hover); color: var(--ink); }
.card.connection { background: var(--warm); box-shadow: var(--shadow-tiny), inset 3px 0 0 var(--coral); }
.card.connection .layer { color: var(--coral-dark); }
.card.connection.accepted { background: var(--card); box-shadow: var(--shadow-tiny); }
.card.proposal { background: var(--warm); box-shadow: var(--shadow-tiny), inset 3px 0 0 var(--coral); }
.card.proposal .layer { color: var(--coral-dark); }
.card.arc.accepted { background: var(--card); box-shadow: var(--shadow-tiny); }
.card.decision { padding: 8px 12px; }
.why-this { margin: 6px 0; font-size: 13px; }
.why-this summary { cursor: pointer; color: var(--muted); }
.stale-note { border-left: 3px solid var(--hyp); padding: 8px 12px; background: var(--badge-hyp); border-radius: 10px; margin: 8px 0; }
.badge.life { background: var(--accent-soft); color: var(--accent-ink); }
.tl { font-size: 13px; padding: 4px 0; border-bottom: 1px dotted var(--line); }
.why-box { margin: 4px 0 8px; padding: 8px 12px; border-left: 3px solid var(--accent); font-size: 13px; background: var(--accent-soft); border-radius: 10px; }
.pp-budget { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.pp-budget label { display: block; margin: 4px 0; }
.pp-budget input[type=number] { width: 70px; }
.you-form label.inline { flex-direction: row; align-items: center; flex: 0 1 auto; }
details.watch-box { margin: 10px 0 14px; }
details.watch-box > summary { cursor: pointer; font-weight: 700; font-size: 14px; }
.sum-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sum-row span { color: var(--muted); }
.sum-row b { font-weight: 800; text-align: right; }
.sum-row button, .card .controls button[data-go] { font-size: 11px; font-weight: 700; padding: 4px 11px; border: none; border-radius: 999px; background: var(--hover);
                                                   color: var(--ink); cursor: pointer; transition: background .15s ease; }
.sum-row button:hover, .card .controls button[data-go]:hover { background: var(--glow); }
.panel-open { width: 100%; margin-top: 14px; justify-content: center; text-align: center; background: var(--active); color: var(--accent-ink); font-weight: 800; }
.panel-open:hover { background: var(--glow); }
.spark-offer { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 8px 0 2px; }
.spark-offer button { font-size: 13px; font-weight: 700; padding: 7px 15px; border: none; border-radius: 999px; background: var(--coral-soft); color: var(--coral-dark);
                      cursor: pointer; box-shadow: var(--shadow-tiny); transition: background .15s ease, transform .15s ease; }
.spark-offer button:hover { background: var(--coral-hover); transform: translateY(-1px); }
.spark-offer button:disabled { opacity: .5; cursor: default; transform: none; }
/* Everything an app suggestion shows (Sparks, Bazaar, Experiences: the offer, its questions, the card it leaves) uses
   the Companion's own soft blue instead of coral. Only inside these blocks: the header buttons and other cards keep theirs. */
.spark-offer, .spark-offers, .app-offer, .app-card {
  --coral-soft: var(--accent-soft); --coral-dark: var(--accent-ink); --coral-hover: var(--glow);
}
/* Companion Suggests: an app's offer, the questions it asks in the chat, and the card it leaves behind */
.app-offer { flex-direction: column; align-items: stretch; gap: 6px; padding: 12px 14px; border: 1px solid var(--line, #e7dfd6); border-radius: 14px; background: var(--card, #fff); }
.app-offer-head { font-weight: 700; color: var(--coral-dark); }
.app-actions, .app-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.app-offer button, .app-card button { font-size: 13px; font-weight: 700; padding: 8px 16px; border: none; border-radius: 999px; background: var(--coral-soft); color: var(--coral-dark);
                                       cursor: pointer; box-shadow: var(--shadow-tiny); }
.app-offer button:hover, .app-card button:hover { background: var(--coral-hover); }
.app-offer button:disabled, .app-card button:disabled { opacity: .5; cursor: default; }
.app-offer button.app-quiet, .app-card button.app-quiet { background: transparent; box-shadow: none; color: var(--muted); font-weight: 600; text-decoration: underline; }
.app-open { font-size: 13px; font-weight: 600; color: var(--coral-dark); padding: 8px 4px; }
.app-q { font-size: 15px; font-weight: 600; margin-top: 4px; }
.app-msg { font-size: 14px; }
.app-err { color: #a33; }
.app-input { flex: 1 1 180px; min-width: 0; font: inherit; font-size: 15px; padding: 9px 12px; border: 1px solid var(--line, #d9d0c6); border-radius: 10px; background: var(--card, #fff); color: inherit; }
.app-card { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line, #e7dfd6); border-radius: 14px; background: var(--card, #fff); display: flex; flex-direction: column; gap: 8px; max-width: 540px; }
.app-card a { color: var(--coral-dark); }
.app-input-wide { flex: 1 1 calc(100% - 60px); }   /* full width, with room for the microphone beside it */
.app-offer button.app-chip { background: transparent; box-shadow: none; color: inherit; font-weight: 600; border: 1px solid var(--line, #d9d0c6); border-radius: 999px; padding: 6px 12px; }
.app-offer button.app-chip.app-picked { background: var(--coral-soft); border-color: var(--coral-dark); color: var(--coral-dark); }
.app-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.app-chip-note { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--coral-soft); overflow-wrap: anywhere; }
.app-products { max-width: 600px; }
.app-warn { padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); color: var(--ink); font-size: 13px;
            box-shadow: inset 3px 0 0 var(--accent); }
.app-why { font-size: 14px; }
/* Kindness Bazaar's questions: what was asked and answered so far (each with Edit), a microphone beside the answer box,
   and "Edit preferences" - every answer in one panel. */
.app-hist { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--coral-soft); }
.app-hist-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; align-items: center; }
.app-hist-row + .app-hist-row { border-top: 1px solid var(--line, #e7dfd6); padding-top: 8px; }
.app-hist-q { grid-column: 1; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.app-hist-a { grid-column: 1; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.app-offer button.app-edit { grid-column: 2; grid-row: 1 / span 2; padding: 4px 8px; font-size: 13px; }
.app-hist-row.editing { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.app-hist-row.editing > button.app-quiet { align-self: flex-start; padding: 4px 0; }
.app-offer button.app-mic { display: inline-flex; align-items: center; justify-content: center; padding: 8px 10px; border-radius: 8px;
  background: transparent; box-shadow: none; color: var(--ink); }
.app-offer button.app-mic:hover { background: var(--hover); }
.app-offer button.app-mic.recording { background: #fce8e6; animation: micpulse 1.2s ease-in-out infinite; }
.app-offer button.app-mic.recording svg path { stroke: #ea4335; }
.app-offer button:focus-visible { outline: 2px solid var(--coral-dark); outline-offset: 2px; }
.app-panel { display: flex; flex-direction: column; gap: 14px; }
.app-panel-row { display: flex; flex-direction: column; gap: 6px; }
.app-panel-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.app-products:has(.app-cmp) { max-width: 100%; }
.app-cmp-box { display: flex; flex-direction: column; gap: 6px; }
.app-cmp-wrap { overflow-x: auto; border: 1px solid var(--line, #e7dfd6); border-radius: 12px; }
.app-cmp { border-collapse: collapse; width: 100%; min-width: 980px; font-size: 13px; }
.app-cmp th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 8px; white-space: nowrap; }
.app-cmp td { padding: 8px; vertical-align: top; border-top: 1px solid var(--line, #e7dfd6); overflow-wrap: break-word; }
.app-cmp td.cmp-name { min-width: 210px; max-width: 280px; }
.app-cmp td.cmp-meets { min-width: 150px; }
.app-cmp td.cmp-num { white-space: nowrap; }
.app-cmp td.cmp-delivery { min-width: 200px; }
.app-cmp td.cmp-returns { min-width: 110px; }
.app-cmp tr.rec td { background: var(--coral-soft); }
.app-cmp .cmp-yes { color: #2d7a3e; font-weight: 600; }
.app-cmp .cmp-no { color: #a33; font-weight: 600; }
.app-cmp .cmp-partial { color: var(--muted); font-weight: 600; }
.app-also { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.app-also-card { display: flex; flex-direction: column; border: 1px solid var(--line, #e7dfd6); border-radius: 12px; overflow: hidden; background: #fff; }
.app-also-card img, .app-also-noimg { width: 100%; height: 120px; object-fit: contain; background: #fff; }
.app-also-noimg { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); background: var(--coral-soft); }
.app-also-body { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; min-width: 0; }
.app-product-list { display: flex; flex-direction: column; gap: 10px; }
.app-product { display: flex; gap: 12px; padding: 10px; border: 1px solid var(--line, #e7dfd6); border-radius: 12px; }
.app-product.rec { border-color: var(--coral-dark); background: var(--coral-soft); }
.app-product img { width: 72px; height: 72px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; }
.app-product-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.app-product-name { font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.app-product-price { font-size: 15px; font-weight: 700; }
.app-badge { align-self: flex-start; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
             padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff; }
.app-checks, .app-claims { margin: 2px 0 0; padding-left: 16px; font-size: 12px; color: var(--muted); }
.app-checks li.good { color: #2d7a3e; }
.app-checks li.bad { color: #a33; }
.app-shop { align-self: flex-start; padding: 6px 0; }
/* Viator results in the Experiences room: the Companion's own white and blue */
.vt-card { max-width: 640px; }
.vt-list { display: flex; flex-direction: column; gap: 12px; }
.vt-item { display: flex; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: var(--shadow-tiny); }
.vt-pic { width: 132px; height: 132px; flex: none; object-fit: cover; border-radius: 12px; background: var(--accent-soft); }
.vt-nopic { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); }
.vt-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; align-items: flex-start; }
.vt-title { font-weight: 800; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.vt-meta { font-size: 12.5px; color: var(--muted); }
.vt-desc { font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; }
.vt-card a.vt-go { margin-top: 4px; display: inline-block; font-size: 13px; font-weight: 700; padding: 8px 18px; border-radius: 999px; text-decoration: none;
                   background: var(--accent); color: #fff; box-shadow: var(--shadow-tiny); }
.vt-card a.vt-go:hover { background: var(--accent-ink); }
.vt-card a.vt-go:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 560px) { .vt-item { flex-direction: column; } .vt-pic { width: 100%; height: 170px; } }
.app-card-head { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.app-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
.app-facts dt { color: var(--muted); }
.app-facts dd { margin: 0; overflow-wrap: anywhere; }
.app-caption { padding: 10px 12px; border-radius: 10px; background: var(--coral-soft); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.app-spark { max-width: 560px; }
.sp-title { font-weight: 800; font-size: 16px; }
.sp-p { margin: 0; font-size: 14px; }
.sp-section { display: flex; flex-direction: column; gap: 2px; }
.sp-heading { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sp-list { margin: 0; padding-left: 18px; font-size: 14px; }
.sp-info { padding: 10px 12px; border-radius: 12px; background: var(--coral-soft); font-size: 14px; display: flex; flex-direction: column; gap: 3px; overflow-wrap: anywhere; }
.sp-info-head { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--coral-dark); }
.sp-note { padding: 10px 12px; border-radius: 12px; background: var(--coral-soft); font-size: 14px; font-style: italic; color: var(--muted); }
.sp-body { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.app-card button.sp-toggle { background: var(--card, #fff); border: 1px solid var(--line, #d9d0c6); }
.sp-panel { padding: 10px 12px; border: 1px solid var(--line, #e7dfd6); border-radius: 12px; display: flex; flex-direction: column; gap: 8px; }
.sp-panel[hidden], .sp-event[hidden] { display: none; }
.app-card button.sp-chip { background: var(--card, #fff); border: 1px solid var(--line, #d9d0c6); }
.app-card button.sp-chip.sp-on { background: var(--coral-soft); border-color: var(--coral-dark); }
.sp-draft { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.sp-preview { align-self: stretch; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line, #e7dfd6); background: var(--card, #fff); display: flex; flex-direction: column; gap: 6px; }
.sp-prev-head { font-size: 13px; }
.sp-subject { font-weight: 700; }
.sp-via { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.app-card a.sp-via-link { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; padding: 6px 12px 6px 9px; border-radius: 999px; background: var(--coral-soft); text-decoration: none; }
.sp-brand { flex: none; display: block; }
details.ended-ctx { margin-top: 14px; font-size: 13px; color: var(--muted); }
details.ended-ctx summary { cursor: pointer; margin-bottom: 8px; }
.spark-offers { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 2px; }
.check-in-tag { font-style: italic; margin-bottom: 4px; }

/* Presence: a pill that opens a small panel (selective presence) */
.presence-wrap { position: relative; }
.presence-btn { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; padding: 0 14px; white-space: nowrap; }
.presence-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.presence-btn[data-level=goals] .presence-dot { background: var(--ok); }
.presence-btn[data-level=notice] .presence-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.presence-btn[data-level=quiet] .presence-dot { background: var(--hyp); }
.presence-pop { position: absolute; top: calc(100% + 10px); right: 0; width: 340px; z-index: 60; padding: 16px; border: none; border-radius: 14px;
                background: var(--panel); box-shadow: var(--shadow-pop); font-size: 14px; }
.presence-pop[hidden] { display: none; }
.presence-pop .note { margin: 4px 0 0; }
.presence-pop .pp-tag { font-size: 12px; font-style: italic; color: var(--muted); margin-top: 2px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border: none; border-radius: 999px; background: var(--hover); margin: 12px 0 10px; }
.seg button { font-size: 13px; font-weight: 700; padding: 7px 6px; border: 0; border-radius: 999px; background: transparent; color: var(--ink); cursor: pointer;
              transition: background .15s ease, color .15s ease; }
.seg button:hover { background: var(--glow); }
.seg button[aria-pressed=true] { background: var(--accent); color: #fff; box-shadow: var(--shadow-tiny); }
.pp-desc { font-size: 13px; line-height: 1.5; min-height: 54px; }
.pp-desc .sub { color: var(--muted); font-size: 12px; }
.pp-quiet { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.pp-quiet .row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.pp-quiet input[type=date] { flex: 1; min-width: 0; font-size: 13px; padding: 6px 12px; border: none; border-radius: 999px; background: var(--hover); color: var(--ink); }
.pp-quiet button { font-size: 13px; font-weight: 700; padding: 6px 14px; border: none; border-radius: 999px; background: var(--card); color: var(--ink); cursor: pointer;
                   box-shadow: var(--shadow-tiny); transition: background .15s ease; }
.pp-quiet button:hover { background: var(--glow); }
@media (max-width: 760px) {
  .presence-pop { position: fixed; left: 12px; right: 12px; width: auto; }
}
/* the context bar above the chat: where you are, and how present the Companion is here */
.ctxbar { display: flex; align-items: flex-start; gap: 10px; }
.ctxbar .ctxline { flex: 1; min-width: 0; }
.ctxbar .presence-wrap { margin-left: auto; flex: none; padding-bottom: 8px; }
.ctxbar .chat-more { flex: none; width: 34px; min-height: 30px; padding: 0; display: grid; place-items: center; margin-bottom: 8px; }
.ctxbar .chat-more .ico { width: 18px; height: 18px; vertical-align: 0; }
.ctxbar .presence-btn { font-size: 12px; min-height: 30px; padding: 0 13px; }

/* the account area at the bottom of the left menu: appearance, sign in / out */
.side-foot { padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; position: relative; }
/* Settings (the gear) on the left, a small sign-in button beside it; the gear opens country and dark or light mode */
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.foot-gear { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border: none; border-radius: 50%; background: transparent;
             color: var(--ink); cursor: pointer; transition: background .15s ease; }
.foot-gear:hover, .foot-gear[aria-expanded="true"] { background: var(--hover); }
.foot-gear .ico { width: 20px; height: 20px; vertical-align: 0; }
.foot-pop { position: absolute; left: 0; right: 0; bottom: calc(100% - 4px); display: flex; flex-direction: column; gap: 8px; padding: 12px;
            background: var(--panel, #fff); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-soft); z-index: 5; }
.foot-pop[hidden] { display: none; }
.foot-btn { font-size: 13px; font-weight: 700; padding: 9px 12px; border: none; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer;
            text-align: left; transition: background .15s ease; }
.foot-btn:hover { background: var(--hover); }
.side-foot .auth-btn { width: auto; margin-left: auto; text-align: center; font-size: 12px; padding: 6px 14px; border-radius: 999px; }
.side-foot .auth-btn[hidden] { display: none; }
/* the country the person lives in (for the right emergency helplines) sits in the left menu, above the theme button */
.foot-country { display: flex; flex-direction: column; gap: 6px; }
.foot-country label { color: var(--placeholder); font-size: 12px; font-weight: 700; padding: 0 4px; }
.foot-country select { font-size: 13px; font-weight: 700; padding: 8px 12px; border: none; border-radius: 999px; background: var(--field); color: var(--ink);
                       width: 100%; cursor: pointer; outline: none; box-shadow: var(--shadow-tiny); transition: box-shadow .2s ease; }
.foot-country select:focus { box-shadow: var(--shadow-tiny), 0 0 0 3px var(--ring); }

/* the right-hand panel: a few tidy sections */
#side { padding: 18px 20px 24px; }
.side-sec { margin: 0 0 22px; }
.side-head, details.side-sec > summary { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.side-head { justify-content: space-between; }
#side .side-head h2, #side details.side-sec > summary h2 { margin: 0; }
details.side-sec { border-top: 1px solid var(--line); margin-bottom: 0; }
details.side-sec > summary { cursor: pointer; list-style: none; padding: 12px 0; margin: 0; }
details.side-sec > summary::-webkit-details-marker { display: none; }
details.side-sec > summary::after { content: "\25B8"; color: var(--muted); font-size: 12px; margin-left: auto; transition: transform .15s ease; }
details.side-sec[open] > summary::after { transform: rotate(90deg); }
details.side-sec > div { padding-bottom: 14px; }
.count { font-size: 11px; font-weight: 800; line-height: 1; background: var(--coral-soft); color: var(--coral-dark); border-radius: 999px; padding: 3px 8px; }
.count[hidden] { display: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 4px; border: none; border-radius: 14px; background: var(--card);
        color: var(--ink); cursor: pointer; box-shadow: var(--shadow-tiny); transition: box-shadow .2s ease, transform .2s ease; }
.stat b { font-size: 22px; font-weight: 800; line-height: 1.1; color: var(--accent-ink); }
.stat span { font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.stat:hover { box-shadow: var(--shadow-soft); transform: translateY(-2px); }
.side-hint { font-size: 12px; color: var(--muted); margin: 10px 2px 0; line-height: 1.5; }
.goal-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 2px; }
.goal-list li { display: flex; align-items: center; gap: 9px; font-size: 13px; padding: 7px 8px; border-radius: 10px; cursor: pointer; transition: background .15s ease; }
.goal-list li:hover { background: var(--hover); }
.goal-list .gdot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.goal-list .gdot.paused { background: var(--hyp); }
.goal-list .gtext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-list .more { color: var(--muted); font-size: 12px; padding-left: 25px; cursor: pointer; }
#side .panel-open { margin-top: 14px; }

/* Desktop: the page is exactly the screen tall (banner + header + the three columns), so the bottom of the
   left menu - where the account buttons are - is never pushed below the fold by the banner above. */
@media (min-width: 761px) {
  body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
  main { flex: 1; min-height: 0; height: auto; }
}

/* Layout without the right-hand panel: the chat takes its place. (#side stays in the page, so nothing that
   fills it breaks; it is just not shown.) */
#side { display: none !important; }
main { grid-template-columns: 270px 1fr; }
@media (max-width: 1200px) { main { grid-template-columns: 250px 1fr; } }
body.threads-collapsed main { grid-template-columns: 1fr; }
@media (max-width: 760px) { main { grid-template-columns: 1fr; } }

/* Your message bubble is only as wide as its words (up to the usual limit), not the full row */
.msg.person { width: fit-content; }

/* A question being edited: its bubble gives way to one wide box, where it stands. The words are typed straight into it
   (no second box inside), with Cancel and Send at its foot - in the green of your bubble and the Companion's blue. */
.msg.person.editing { width: 100%; max-width: 100%; }
.msg.person.editing > .body, .msg.person.editing > .acts { display: none; }
.edit-box { background: var(--bubble-user); border-radius: 24px; padding: 12px; box-shadow: var(--shadow-tiny); }
.edit-box textarea { display: block; box-sizing: border-box; width: 100%; min-height: 52px; resize: none; margin: 0; padding: 0 10px; border: none;
                     border-radius: 0; background: transparent; color: var(--ink); font: inherit; font-size: 15px; font-weight: 600; line-height: 1.6;
                     outline: none; box-shadow: none; }
.edit-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; }
.edit-actions button { font: inherit; font-size: 14px; font-weight: 700; height: 36px; padding: 0 16px; border-radius: 999px; cursor: pointer;
                       transition: background .15s ease, filter .15s ease; }
.edit-actions .edit-cancel { background: transparent; color: var(--ink); border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent); }
.edit-actions .edit-cancel:hover { background: var(--field); }
.edit-actions .edit-save { background: linear-gradient(135deg, #6A9BFF 0%, var(--accent) 100%); color: #fff; border: 1px solid transparent; }   /* as the send arrow */
.edit-actions .edit-save:hover { filter: brightness(1.06); }
.edit-actions .edit-save:disabled { opacity: .55; cursor: default; filter: none; }
.edit-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The chat sits in a centred column with breathing room on the left and right (the blue glow still fills the
   whole area). Messages, the context bar, the composer and the Library / Memory & Trust screens share one width. */
@media (min-width: 761px) {
  #chat { padding: 24px 96px 20px; }
  #chat > * { width: 100%; max-width: 860px; margin-left: auto; margin-right: auto; }
  #messages { padding-right: 12px; }
  /* The context line sits in the left corner and Presence and the three dots in the right corner, across the whole width. */
  #chat > .ctxbar { width: calc(100% + 144px); max-width: none; margin-left: -72px; margin-right: -72px; }
  /* Personalization scrolls across the whole width too, so its scrollbar is at the window's right edge; the content keeps its column. */
  #chat > #personalization-view { width: calc(100% + 192px); max-width: none; margin-left: -96px; margin-right: -96px;
                                  padding-left: max(28px, calc((100% - 668px) / 2)); padding-right: max(28px, calc((100% - 668px) / 2)); }
  /* The messages scroll across the whole width, so the scrollbar sits at the right edge of the window (as in ChatGPT);
     the words themselves stay in the same centred column. */
  #chat > #messages { width: calc(100% + 192px); max-width: none; margin-left: -96px; margin-right: -96px;
                      padding-left: max(28px, calc((100% - 668px) / 2)); padding-right: max(28px, calc((100% - 668px) / 2)); }   /* 100% is the chat's inner width = window - 192px, so (window - 860px) / 2 */
}

/* The Companion's reply, like yours, is only as wide as its words (up to the usual limit) */
.msg.companion { width: fit-content; }

/* Header links: bright, filled pills (Experiences green, Bazaar coral, Spark gold) instead of pale tints */
.exp-btn, .bazaar-btn, .sparks-btn { color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .12); }
.exp-btn { background: linear-gradient(135deg, #4CC38A 0%, #2B9A5E 100%); box-shadow: 0 6px 16px rgba(43, 154, 94, .30); }
.bazaar-btn { background: linear-gradient(135deg, #FF8A65 0%, #F4511E 100%); box-shadow: 0 6px 16px rgba(244, 81, 30, .28); }
.sparks-btn { background: linear-gradient(135deg, #FFD54F 0%, #F5A300 100%); color: #4A3000; text-shadow: none; box-shadow: 0 6px 16px rgba(245, 163, 0, .30); }
.exp-btn:hover, .bazaar-btn:hover, .sparks-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.exp-btn:hover { background: linear-gradient(135deg, #4CC38A 0%, #2B9A5E 100%); box-shadow: 0 8px 20px rgba(43, 154, 94, .38); }
.bazaar-btn:hover { background: linear-gradient(135deg, #FF8A65 0%, #F4511E 100%); box-shadow: 0 8px 20px rgba(244, 81, 30, .36); }
.sparks-btn:hover { background: linear-gradient(135deg, #FFD54F 0%, #F5A300 100%); box-shadow: 0 8px 20px rgba(245, 163, 0, .38); }

/* Sidebar toggle (replaces the hamburger): a panel icon with a chevron, as in Gemini, and a small dark tooltip */
.side-toggle { position: relative; width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%; background: transparent; box-shadow: none; color: var(--muted); }
.side-toggle:hover { background: var(--hover); color: var(--ink); transform: none; }
.side-toggle .ico { width: 22px; height: 22px; vertical-align: 0; stroke-width: 1.7; }
.side-toggle .ico-open, .side-toggle[aria-expanded="false"] .ico-close { display: none; }
.side-toggle[aria-expanded="false"] .ico-open { display: block; }
.side-toggle::after { content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%) translateX(-4px);
                      padding: 8px 14px; border-radius: 10px; background: #111; color: #fff; font-size: 13px; font-weight: 700; white-space: nowrap;
                      opacity: 0; pointer-events: none; transition: opacity .15s ease, transform .15s ease; z-index: 30; }
.side-toggle:hover::after, .side-toggle:focus-visible::after { opacity: 1; transform: translateY(-50%) translateX(0); }

/* Search chats and the chat options (•••) beside Presence are not shown in this layout */
#threads .searchbox, .ctxbar .chat-more { display: none; }

/* "Current context: Me · manage" sits on the right, beside Presence */
.ctxbar { justify-content: flex-end; align-items: center; }
.ctxbar .ctxline { flex: 0 1 auto; justify-content: flex-end; padding-bottom: 8px; }
.ctxbar .presence-wrap { margin-left: 0; }

@media (min-width: 761px) {
  /* The sidebar slides open and closed (the column narrows smoothly instead of jumping) */
  main { transition: grid-template-columns .3s ease; }
  /* (also when the browser still remembers the old right-hand panel as closed: that older rule would make one column) */
  body.threads-collapsed main, body.threads-collapsed.side-collapsed main { grid-template-columns: 64px 1fr; }

  /* Closed, the sidebar is a slim rail of icons (as in Gemini): the toggle, New chat, Library, Memory & Trust,
     and at the bottom Settings and Sign in. The words fold away smoothly; Recent is shown only when open. */
  body.threads-collapsed #threads { display: flex; padding-left: 12px; padding-right: 12px; }
  #threads { overflow: visible; }                         /* so the small tooltips can show beside the rail */
  #threads .lbl { display: inline-block; max-width: 200px; opacity: 1; margin-left: 10px; overflow: hidden; white-space: nowrap; vertical-align: middle;
                  transition: max-width .3s ease, opacity .2s ease, margin .3s ease; }
  body.threads-collapsed #threads .lbl { max-width: 0; opacity: 0; margin-left: 0; }
  #thread-list { transition: opacity .2s ease, visibility 0s; }
  body.threads-collapsed #thread-list { opacity: 0; visibility: hidden; transition: opacity .15s ease, visibility 0s linear .15s; }
  body.threads-collapsed .side-top { justify-content: flex-start; }
  body.threads-collapsed .foot-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  body.threads-collapsed .side-foot { border-top-color: transparent; }
  body.threads-collapsed .foot-pop { right: auto; width: 260px; }
  /* tooltips beside the rail icons, only while the sidebar is closed (the toggle always has one) */
  body.threads-collapsed #threads [data-tip]:hover::after, body.threads-collapsed #threads [data-tip]:focus-visible::after { opacity: 1; transform: translateY(-50%) translateX(0); }

  /* A narrower, slightly taller message bar */
  #chat > #composer, #chat > #attachbar, #chat > #systemline, #chat > #sparks-bar { max-width: 540px; }

  /* A new, empty chat: the greeting and the message bar sit together in the middle of the page;
     once you send something they move down to their usual place at the bottom */
  #chat:has(#messages > :is(.empty-chat, .mode-hero):only-child) > #messages { flex: 0 0 auto; margin-top: auto; overflow: visible; }
  #chat:has(#messages > :is(.empty-chat, .mode-hero):only-child) > #systemline { margin-bottom: auto; }
  #chat:has(#messages > :is(.empty-chat, .mode-hero):only-child) :is(.empty-chat, .mode-hero) { margin: 0 auto 26px; }
}

/* The sidebar's top row holds its open / close toggle (on the right while open, as in Gemini) */
.side-top { display: flex; justify-content: flex-end; align-items: center; margin: -6px 0 6px; min-height: 40px; }
/* Sidebar items: icon first, then the words (the words fold away when the sidebar closes) */
.new-chat, #threads .lib-btn { display: flex; align-items: center; padding: 10px 11px; white-space: nowrap; overflow: visible; }
.new-chat .ico, #threads .lib-btn .ico { width: 18px; height: 18px; vertical-align: 0; }
#threads [data-tip] { position: relative; }
#threads [data-tip]::after { content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%) translateX(-4px);
                             padding: 8px 14px; border-radius: 10px; background: #111; color: #fff; font-size: 13px; font-weight: 700; white-space: nowrap;
                             opacity: 0; pointer-events: none; transition: opacity .15s ease, transform .15s ease; z-index: 30; }
#threads .side-toggle:hover::after, #threads .side-toggle:focus-visible::after { opacity: 1; transform: translateY(-50%) translateX(0); }
/* Settings, then Sign in (a person icon with its word), at the bottom of the sidebar */
.foot-row { justify-content: flex-start; }
.foot-gear { width: 40px; height: 40px; }
.foot-auth { display: flex; align-items: center; height: 40px; padding: 0 11px; border: none; border-radius: 999px; background: transparent; color: var(--ink);
             font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; white-space: nowrap; transition: background .15s ease; }
.foot-auth .ico { width: 20px; height: 20px; vertical-align: 0; color: var(--accent); }
.foot-auth:hover { background: var(--hover); }
.foot-auth[hidden] { display: none; }
/* Phones: the sidebar is a drawer, opened from the header's own sidebar button */
#open-threads-m { display: none; }
@media (max-width: 760px) { #open-threads-m { display: inline-flex; } }
/* A guest (not signed in): no Recent list - nothing from earlier visits is kept or shown */
body.guest #thread-list { display: none; }
#threads .lbl { margin-left: 10px; }
.side-foot { margin-top: auto; }   /* Settings and Sign in stay at the bottom, also when Recent is not shown */
/* Sign out, inside Settings (only while signed in) */
.foot-signout { display: flex; align-items: center; gap: 8px; color: var(--danger); }
.foot-signout .ico { width: 17px; height: 17px; vertical-align: 0; }
.foot-signout[hidden] { display: none; }

/* ---- Settings > Personalization ---- */
.foot-personalize { display: flex; align-items: center; gap: 10px; }
.foot-personalize .ico { width: 17px; height: 17px; vertical-align: 0; }
#chat.pers-open > :not(#personalization-view) { display: none; }
#personalization-view { flex: 1; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; min-height: 0; position: relative; }
#personalization-view[hidden] { display: none; }
.pers-body { display: flex; flex-direction: column; gap: 14px; max-width: 640px; width: 100%; }
.pers-where { font-size: 13px; color: var(--muted); }
.pers-where b { color: var(--ink); }
.pers-body h3 { margin: 6px 0 0; font-size: 16px; font-weight: 800; }
.pers-card { background: var(--card); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow-tiny); }
.pers-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.pers-title { font-size: 15px; font-weight: 800; }
.pers-desc { font-size: 13px; color: var(--muted); line-height: 1.65; margin-top: 4px; }
.pers-desc b { color: var(--ink); }
.switch { position: relative; flex: none; width: 46px; height: 26px; margin-top: 2px; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch .knob { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .2s ease; }
.switch .knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
                       box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s ease; }
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::after { transform: translateX(20px); }
.switch input:focus-visible + .knob { box-shadow: 0 0 0 3px var(--ring); }
.pers-freq { border: 0; margin: 14px 0 0; padding: 14px 0 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.pers-freq[hidden] { display: none; }
.pers-freq legend { font-size: 13px; font-weight: 800; padding: 0 0 8px; }
.pers-freq label { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; cursor: pointer; flex-wrap: wrap; }
.pers-num { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.pers-num input { width: 76px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); color: var(--ink); font: inherit; font-weight: 700; }
.pers-num input:disabled { opacity: .5; }
.pers-link { display: inline; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 800; text-decoration: underline;
             text-underline-offset: 2px; cursor: pointer; }
.pers-link:hover { color: var(--accent-ink, var(--accent)); }
.pers-link:disabled { opacity: .55; cursor: wait; }
#pers-resume[hidden] { display: none; }
.pers-check-result { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.5; }
.pers-check-result:empty { display: none; }
.pers-check-result button { margin-left: 4px; }
.pers-pause { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.pers-pause input[type="date"] { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--field); color: var(--ink); font: inherit; font-size: 13px; font-weight: 700; }
.pers-paused { font-size: 13px; font-weight: 700; color: var(--ink); }
#pers-status { min-height: 20px; font-size: 13px; color: var(--muted); }
#pers-status.error { color: var(--danger); }
/* a guest sees the page blurred, with a note on top, and cannot change anything */
.pers-lock { position: absolute; inset: 0; display: grid; place-items: center; z-index: 5; }
.pers-lock[hidden] { display: none; }
.pers-lock-card { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 28px; border-radius: 18px; background: var(--panel, #fff); box-shadow: var(--shadow-soft); font-size: 15px; }
.pers-lock-card .auth-btn { padding: 0 24px; min-height: 38px; }
#personalization-view.locked .pers-body { filter: blur(6px); pointer-events: none; user-select: none; }

/* ---- A guest (not signed in) ---- */
/* No context and no Presence for a guest: the context line, Presence and the chat's own menu are not shown, and Settings
   offers only country and light or dark mode */
body.guest .ctxbar, body.guest #foot-ctx { display: none; }
/* After the free messages: the message bar is off and a sign-in note takes its place */
.limit-note { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 12px 18px; margin-top: 12px; border-radius: 999px;
              background: var(--accent-soft); color: var(--ink); font-size: 14px; font-weight: 800; letter-spacing: .6px; text-align: center; }
.limit-note[hidden] { display: none; }
.limit-note .auth-btn { padding: 0 20px; min-height: 36px; letter-spacing: normal; }
body.guest-limit #composer { opacity: .55; pointer-events: none; }
body.guest-limit #composer input { cursor: not-allowed; }
@media (min-width: 761px) { #chat > .limit-note { max-width: 540px; } }

/* ---- Signed in: the person's initials and name at the bottom of the sidebar, and the menu they open ---- */
.user-row { display: flex; align-items: center; gap: 0; width: 100%; min-width: 0; padding: 6px 8px 6px 6px; border: none; border-radius: 14px; background: transparent;
            color: var(--ink); font: inherit; font-size: 14px; font-weight: 800; text-align: left; cursor: pointer; transition: background .15s ease; }
.user-row:hover, .user-row[aria-expanded="true"] { background: var(--hover); }
.user-row[hidden], .foot-gear[hidden] { display: none; }
.avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 800; letter-spacing: .5px;
          background: linear-gradient(135deg, #6A9BFF 0%, var(--accent) 100%); box-shadow: 0 4px 10px rgba(76, 111, 224, .28); }
.user-row .user-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu { position: absolute; left: 0; right: 0; bottom: calc(100% - 4px); display: flex; flex-direction: column; gap: 2px; padding: 6px;
             background: var(--panel, #fff); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-soft); z-index: 6; }
.user-menu[hidden] { display: none; }
.user-menu-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: none; border-radius: 9px; background: none; cursor: pointer;
                  font: inherit; font-size: 14px; font-weight: 700; color: var(--ink); text-align: left; }
.user-menu-item:hover, .user-menu-item:focus-visible { background: var(--hover); outline: none; }
.user-menu-item .ico { width: 18px; height: 18px; vertical-align: 0; }
.user-menu-item.danger { color: var(--danger); }
.user-menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }
body.threads-collapsed .user-menu { right: auto; width: 220px; }
body.threads-collapsed .user-row { padding: 2px; width: auto; background: transparent; }

/* ---- The sidebar's drag handle: drag the right edge to make it wider or narrower (the width is remembered) ---- */
.side-resize { display: none; }
@media (min-width: 761px) {
  main { grid-template-columns: var(--side-w, 270px) 1fr; }
  body.threads-collapsed main, body.threads-collapsed.side-collapsed main { grid-template-columns: 64px 1fr; }
}
@media (min-width: 761px) and (max-width: 1200px) { main { grid-template-columns: var(--side-w, 250px) 1fr; } body.threads-collapsed main { grid-template-columns: 64px 1fr; } }
@media (min-width: 761px) {
  .side-resize { display: block; position: absolute; top: 0; bottom: 0; right: -6px; width: 12px; cursor: col-resize; z-index: 8; touch-action: none; }
  .side-resize::after { content: ''; position: absolute; top: 0; bottom: 0; left: 5px; width: 3px; border-radius: 3px; background: transparent; transition: background .15s ease; }
  .side-resize:hover::after, .side-resize:focus-visible::after, body.resizing .side-resize::after { background: var(--accent); opacity: .7; }
  .side-resize:focus-visible { outline: none; }
  body.resizing { cursor: col-resize; user-select: none; }
  body.resizing main { transition: none; }
}

/* ---- The page is exactly as tall as the window: it never scrolls itself (the conversation scrolls inside it), and a new, empty
   chat has nothing to scroll at all - the greeting and the message bar sit in the exact middle of the page, as in ChatGPT ---- */
@media (min-width: 761px) {
  html, body { overflow: hidden; }
  body > main { height: auto; flex: 1 1 0; min-height: 0; overflow: hidden; grid-template-rows: minmax(0, 1fr); }
  #threads, #chat { min-height: 0; }
  #chat { position: relative; }
  #chat:has(#messages > :is(.empty-chat, .mode-hero):only-child) { overflow: hidden; justify-content: center; padding-bottom: 48px; }
  #chat:has(#messages > :is(.empty-chat, .mode-hero):only-child) > #messages { overflow: hidden; margin-top: 0; flex: 0 0 auto; }
  #chat:has(#messages > :is(.empty-chat, .mode-hero):only-child) > #systemline { margin-bottom: 0; }
  #chat:has(#messages > :is(.empty-chat, .mode-hero):only-child) > .ctxbar { position: absolute; top: 24px; left: 24px; right: 24px; width: auto; max-width: none; margin: 0; }
}

/* ---- The footer note, as on Kindness Spark: two small centred lines of plain text at the bottom of the page, with
   nothing behind them. The sidebar keeps its full height (Settings stays at the bottom-left corner). ---- */
.site-foot { text-align: center; color: var(--muted); font-weight: 600; line-height: 1.5; padding: 0 16px; pointer-events: none; }
.site-foot p { margin: 0; font-size: 12px; }
.site-foot p + p { font-size: 11px; }
@media (min-width: 761px) {
  #chat { padding-bottom: 56px; }
  #chat > .site-foot { position: absolute; left: 0; right: 0; bottom: 8px; width: auto; max-width: none; margin: 0; }
  #chat.pers-open, #chat.pers-open:has(#messages > .empty-chat:only-child) { padding-bottom: 12px; }   /* no footer note on this page: it scrolls right down to the bottom */
  #chat:has(#messages > :is(.empty-chat, .mode-hero):only-child) { padding-bottom: 48px; }   /* centred between the top bar and the footer note */
  /* (on the Library and Memory & Trust screens the note is hidden with everything else that is not the screen: chat page only) */
}
@media (max-width: 760px) { .site-foot { margin-top: 10px; padding-bottom: 8px; } }

/* The Companion's own dialog (askDialog in app.js), in place of the browser's confirm and prompt boxes */
.kc-dialog {
  position: fixed; inset: 0; margin: auto; height: fit-content;
  width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; overflow: auto;
  border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--ink);
  font: inherit; box-shadow: var(--shadow-pop);
}
.kc-dialog form { padding: 24px; }   /* on the form, so a click on the dialog element itself is always outside it */
.kc-dialog[open] { animation: kc-dialog-in .14s ease-out; }
.kc-dialog::backdrop { background: rgba(20, 24, 34, .45); }
@keyframes kc-dialog-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .kc-dialog[open] { animation: none; } }
.kc-dialog h2 { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.35; color: var(--ink); overflow-wrap: anywhere; }
.kc-dialog p { margin: 8px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.kc-dialog input, .kc-dialog textarea {
  display: block; box-sizing: border-box; width: 100%; margin-top: 14px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--field); color: var(--ink);
  font: inherit; font-size: 14px; line-height: 1.5; resize: vertical;
}
.kc-dialog input:focus, .kc-dialog textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.kc-dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.kc-dialog-actions button {
  min-height: 38px; padding: 8px 18px; border: none; border-radius: 999px;
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.kc-dialog-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kc-dialog-cancel { background: var(--accent-soft); color: var(--accent-ink); }
.kc-dialog-cancel:hover { background: var(--glow); }
.kc-dialog-action { background: var(--accent); color: #fff; }
.kc-dialog-action.danger { background: var(--danger); }
.kc-dialog-action:hover:not(:disabled) { filter: brightness(1.08); }
.kc-dialog-action:disabled { opacity: .5; cursor: default; }
[data-theme="dark"] .kc-dialog::backdrop { background: rgba(0, 0, 0, .6); }
[data-theme="dark"] .kc-dialog-action { color: #14171C; }

/* The wave beside the microphone while speaking a message (it follows the voice; see "Speaking a message" in app.js) */
#composer .msgfield #mic-wave {
  position: absolute; right: 94px; top: 50%; transform: translateY(-50%); z-index: 1; pointer-events: none;
  display: inline-flex; align-items: center; gap: 3px; height: 30px;
}
.msgfield:has(#mic-wave:not([hidden])) #text { padding-right: 182px; }
#composer .msgfield #mic-wave[hidden] { display: none; }
#mic-wave span {
  display: block; width: 3px; height: 26px; border-radius: 999px; transform: scaleY(.14); transition: transform 90ms linear;
  background: linear-gradient(180deg, var(--accent), var(--green-ink));
}
#mic-wave.finishing span { transform: scaleY(.14) !important; opacity: .5; }
@media (max-width: 480px) {
  #mic-wave span:nth-child(odd) { display: none; }
  .msgfield:has(#mic-wave:not([hidden])) #text { padding-right: 136px; }
}
@media (prefers-reduced-motion: reduce) { #mic-wave span { transform: scaleY(.5); transition: none; } }

.campus-btn { color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .12); background: linear-gradient(135deg, #5BB5F0 0%, #1E78C8 100%); box-shadow: 0 6px 16px rgba(30, 120, 200, .28); }
.campus-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
@media (max-width: 700px) { .campus-btn { order: 10; font-size: 12px; min-height: 34px; padding: 0 12px; } }
/* Guild: opens kindnessguild.org in a new tab, like Experiences and Sparks. */
.guild-btn { font-size: 13px; font-weight: 800; letter-spacing: .2px; padding: 0 18px; text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .12);
  background: linear-gradient(135deg, #A98BF0 0%, #6A45C8 100%); box-shadow: 0 6px 16px rgba(106, 69, 200, .28); }
.guild-btn:hover { background: linear-gradient(135deg, #A98BF0 0%, #6A45C8 100%); filter: brightness(1.06); transform: translateY(-1px); }
@media (max-width: 700px) { .guild-btn { order: 10; font-size: 12px; min-height: 34px; padding: 0 12px; } }

/* Kindness Campus: strip, cards, path page, quick questions */
.campus-strip { display: flex; align-items: center; align-self: flex-start; width: fit-content; margin: 0; padding: 0;
  background: none; color: #1F3A2E; font-size: 13px; }
.campus-strip[hidden], .campus-view[hidden] { display: none; }
.sparks-strip .cs-link.sp-back { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 8px; border-radius: 999px; background: var(--field, rgba(0, 0, 0, .05)); }
.sparks-strip .cs-link.sp-back:hover { background: var(--accent-soft); }
[data-theme="dark"] .sparks-strip .cs-link.sp-back { color: var(--ink); }
.campus-strip .cs-link { border: none; background: none; padding: 0; font: inherit; font-weight: 700; color: #1F3A2E; text-decoration: underline; cursor: pointer; }
.cc-wrap { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; max-width: 560px; }
.cc-card { border: 1px solid #D9E2DC; border-radius: 14px; background: #FFFEFA; padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.cc-next { border-color: #1F3A2E; }
.cc-label { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #4F6B5C; margin-bottom: 8px; }
.cc-q { font-weight: 700; margin-bottom: 10px; }
.cc-sub { font-size: 12.5px; color: #4F6B5C; margin: 10px 0 6px; }
.cc-input { width: 100%; box-sizing: border-box; border: 1px solid #C9D3CC; border-radius: 10px; padding: 9px 11px; font: inherit; background: #fff; }
.cc-input:focus { outline: 2px solid #B8430C33; border-color: #B8430C; }
.cc-row { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.cc-plates { display: flex; gap: 6px; flex-wrap: wrap; }
.cc-plate { border: 1px solid #1F3A2E; background: #fff; color: #1F3A2E; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 12.5px; cursor: pointer; }
.cc-plate.on { background: #1F3A2E; color: #fff; }
.cc-go { border: none; background: #1F3A2E; color: #fff; border-radius: 999px; padding: 8px 16px; font: inherit; font-weight: 700; cursor: pointer; }
.cc-outline { border: 1px solid #1F3A2E; background: #fff; color: #1F3A2E; border-radius: 999px; padding: 7px 14px; font: inherit; font-weight: 700; cursor: pointer; margin-top: 10px; }
.cc-quiet { border: none; background: none; color: #4F6B5C; text-decoration: underline; font: inherit; font-size: 12.5px; cursor: pointer; }
.cc-step { margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cc-step.small { font-size: 12.5px; -webkit-line-clamp: 4; }
.cc-why { font-size: 12.5px; margin-bottom: 12px; }
.cc-added { display: inline-block; margin-top: 8px; font-size: 12.5px; font-weight: 700; color: #2F7A4F; }
.cc-also { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 600px) { .cc-also { grid-template-columns: 1fr; } }
.campus-view { flex: 1; overflow-y: auto; padding: 16px; max-width: 720px; width: 100%; margin: 0 auto; box-sizing: border-box; }
.cv-back { border: none; background: none; font: inherit; color: #4F6B5C; cursor: pointer; padding: 0; margin-bottom: 8px; }
.cv-hello { font-family: Georgia, 'Times New Roman', serif; font-weight: 400; font-size: 26px; margin: 4px 0; }
.cv-now { font-size: 13px; color: #4F6B5C; margin-bottom: 12px; }
.cv-card { border: 1px solid #D9E2DC; border-radius: 16px; background: #FFFEFA; padding: 16px; margin-bottom: 12px; }
.cv-h { font-weight: 700; margin-bottom: 6px; }
.cv-focus { font-size: 13px; margin-bottom: 8px; }
.cv-tick { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.cv-tick input { width: 18px; height: 18px; margin-top: 1px; accent-color: #1F3A2E; }
.cv-tick small { display: block; color: #6B7F73; font-size: 11px; }
.cv-progress { display: flex; justify-content: space-between; font-size: 11.5px; color: #4F6B5C; margin: 10px 0 4px; }
.cv-bar { height: 8px; border-radius: 99px; background: #ECEFEA; overflow: hidden; }
.cv-bar i { display: block; height: 100%; background: #4F8A6B; border-radius: 99px; }
.cv-steps { list-style: none; padding: 0; margin: 16px 0 0; }
.cv-step { position: relative; display: flex; gap: 14px; padding: 0 0 16px; }
.cv-step:not(:last-child)::before { content: ''; position: absolute; left: 7px; top: 18px; bottom: 0; border-left: 1px solid #C9D3CC; }
.cv-dot { flex: none; width: 14px; height: 14px; margin-top: 2px; border-radius: 50%; border: 1.5px solid #9FB0A6; background: #fff; position: relative; z-index: 1; }
.cv-step.done .cv-dot { background: #4F8A6B; border-color: #4F8A6B; }
.cv-step.current .cv-dot { background: #1F3A2E; border-color: #1F3A2E; box-shadow: 0 0 0 4px #DCEBC8; }
.cv-title { font-weight: 700; font-size: 13.5px; }
.cv-step.done .cv-title { text-decoration: line-through; color: #6B7F73; }
.cv-detail { font-size: 12px; color: #4F6B5C; margin-top: 2px; }
.cv-mark { margin-top: 8px; border: 1px solid #1F3A2E; background: #fff; color: #1F3A2E; border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.cv-link { display: block; margin-top: 4px; border: none; background: none; padding: 0; font: inherit; font-size: 12px; color: #4F6B5C; text-decoration: underline; cursor: pointer; }
.cv-note { font-size: 11.5px; color: #6B7F73; margin-top: 4px; }
.cv-me label { display: block; font-size: 12.5px; color: #4F6B5C; margin-bottom: 10px; }
.cv-me .cc-input { margin-top: 4px; }
[data-theme="dark"] .cc-card, [data-theme="dark"] .cv-card { background: #1E2420; border-color: #34403A; }
[data-theme="dark"] .campus-strip .cs-link, [data-theme="dark"] .cc-label, [data-theme="dark"] .cc-sub { color: #CFE3D6; }
.ctxbar .campus-strip { flex: none; align-self: center; padding-bottom: 8px; margin-right: auto; }   /* far left; the context stays right */
.cc-saved { font-size: 12.5px; color: #2F5A43; }
.cc-saved .cc-quiet { padding: 0; }
/* Local shops in Bazaar's result: photo cards, three to a row where there is room, one to a row on a phone. */
.shop-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.shop-card { display: flex; flex-direction: column; border: 1px solid var(--line, #e7dfd6); border-radius: 14px; overflow: hidden; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .05); min-width: 0; }
.shop-card img, .shop-noimg { width: 100%; height: 110px; object-fit: cover; background: var(--coral-soft); display: block; }
.shop-noimg { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); }
.shop-body { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px 10px; min-width: 0; flex: 1; }
.shop-name { font-weight: 700; font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
.shop-body .meta { overflow-wrap: anywhere; font-size: 11.5px; line-height: 1.4; }
.shop-acts { margin-top: auto; padding-top: 6px; font-size: 12px; font-weight: 700; }
.shop-acts a { color: #1E63C8; }
@media (max-width: 760px) { .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .shop-grid { grid-template-columns: 1fr; } }
/* Campus's question cards stay once answered; contacts and sources; the path page's "Saved" line. */
.cc-answer { font-size: 15px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; margin: 2px 0 6px; }
.cc-status, .cv-status { font-size: 12.5px; color: #2F5A43; min-height: 1em; }
.cc-status.error, .cv-status.error { color: #B3261E; }
.cv-status { margin-left: 8px; align-self: center; }
textarea.cc-input { resize: vertical; min-height: 56px; font: inherit; }
.cc-contact { padding: 6px 0; border-top: 1px solid var(--line, #e7dfd6); }
.cc-contact:first-of-type { border-top: 0; }
.cc-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.cc-src, .cc-sources a { font-size: 12.5px; color: #1E63C8; overflow-wrap: anywhere; }
.cc-sources { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.cc-cleared { color: var(--muted); }

/* The logo: before the name in the header, above it on the start page and in a room's title, and on the sign-in card. */
header h1 { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 36px; height: 36px; border-radius: 9px; flex: none; display: block; }
.mode-logo, .empty-logo { display: block; width: 76px; height: 76px; border-radius: 17px; margin: 0 auto 10px; box-shadow: 0 6px 18px rgba(60, 90, 160, .18); }
.empty-chat .mode-brand { font-size: 20px; line-height: 1.2; margin-bottom: 14px; }
.signin-logo { display: block; width: 64px; height: 64px; border-radius: 14px; margin: 0 auto 14px; }
@media (max-width: 760px) {
  .brand-logo { width: 30px; height: 30px; border-radius: 8px; }
  .mode-logo, .empty-logo { width: 60px; height: 60px; border-radius: 14px; margin-bottom: 8px; }
  .empty-chat .mode-brand { font-size: 18px; margin-bottom: 10px; }
}
/* While the student looks at their path there is no message bar. */
body.campus-view-open #composer, body.campus-view-open #attachbar { display: none; }
.empty-chat { line-height: 1.55; }
.empty-chat .empty-logo { margin-bottom: 8px; }
.empty-chat .mode-brand { margin-bottom: 10px; }

/* The header's five app buttons: a flat, matte colour - no gradient, no gloss, no shadow, no lift on hover. */
.exp-btn, .bazaar-btn, .campus-btn, .guild-btn, .sparks-btn,
.exp-btn:hover, .bazaar-btn:hover, .campus-btn:hover, .guild-btn:hover, .sparks-btn:hover {
  background-image: none; box-shadow: none; text-shadow: none; transform: none; filter: none; }
.exp-btn { background-color: #3AAE74; color: #fff; }
.bazaar-btn { background-color: #F2653F; color: #fff; }
.campus-btn { background-color: #3A8FD9; color: #fff; }
.guild-btn { background-color: #7E62D4; color: #fff; }
.sparks-btn { background-color: #F6B21A; color: #3F2B00; }
.exp-btn:hover { background-color: #329B66; }
.bazaar-btn:hover { background-color: #DE5632; }
.campus-btn:hover { background-color: #2F7FC7; }
.guild-btn:hover { background-color: #6E52C2; }
.sparks-btn:hover { background-color: #E5A30F; }
/* The room that is open is marked with a plain outline, not a glow. */
body.mode-bazaar #bazaar, body.mode-campus #campus, body.mode-guild #guild, body.mode-sparks #sparks, body.mode-experiences #experiences { box-shadow: none; outline: 2px solid var(--ink); outline-offset: 2px; }
/* Kindness Sparks: a serious card on a message that may need real help, and the found-pet flyer. */
.sp-warn { margin: 6px 0 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid #C62828; background: rgba(198, 40, 40, .09); color: var(--ink); font-weight: 600; }
/* Kindness Sparks' opening screen: the tiles sit under the message bar, as on the Sparks website - white rounded squares in the Companion's own colours. */
.sp-start { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 18px; }
.sp-tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.sp-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 78px; padding: 0; border: none; background: none; color: var(--muted);
           cursor: pointer; font: inherit; }
.sp-tile-ico { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; font-size: 24px; line-height: 1; border-radius: 14px;
               background: var(--card, #fff); box-shadow: var(--shadow-soft, 0 2px 8px rgba(0, 0, 0, .08)); transition: transform .15s ease, box-shadow .15s ease; }
.sp-tile-name { font-size: 11px; font-weight: 700; line-height: 1.25; text-align: center; color: var(--muted); }
.sp-tile:hover .sp-tile-ico, .sp-tile:focus-visible .sp-tile-ico { transform: translateY(-2px); box-shadow: 0 0 0 3px var(--ring), var(--shadow-soft, none); }
.sp-tile:focus-visible { outline: none; }
.sp-tile-info { opacity: .6; }
.sp-back { border: none; background: none; color: var(--accent); font: inherit; font-weight: 700; font-size: 13px; cursor: pointer; padding: 4px 8px; }
.sp-note-line { max-width: 420px; text-align: center; }
body.sparks-start #chat > #messages { flex: 0 0 auto; margin-top: auto !important; overflow: visible; }
body.sparks-start #chat > #sparks-start { margin-bottom: auto; }
@media (min-width: 761px) { body.sparks-start #chat:has(#messages > .mode-hero:only-child) > #systemline { margin-bottom: 0; } }
@media (min-width: 761px) { #chat > #sparks-start { max-width: 540px; } }
/* the camera button sits left of the mic, only while the chat is in Kindness Sparks */
#composer .msgfield #camera { display: none; position: absolute; right: 93px; top: 50%; margin-top: -19px; width: 38px; height: 38px; padding: 0;
  align-items: center; justify-content: center; border: none; border-radius: 8px; background: transparent; color: var(--ink); box-shadow: none;
  cursor: pointer; transition: background .15s ease; }
#composer .msgfield #camera:hover { background: var(--hover); transform: none; }
body.mode-sparks #composer .msgfield #camera { display: inline-flex; }
body.mode-sparks .msgfield #text { padding-right: 144px; }
@media (max-width: 480px) { body.mode-sparks .msgfield #text { padding-right: 138px; } }
/* The Sparks card, laid out as on the Sparks page: bordered table, boxes with small coloured icons, the actions - in the Companion's colours. */
.sp-cardonly > .body { display: none; }
.app-spark .sp-title { font-size: 15px; font-weight: 800; margin-bottom: 8px; }
.app-spark .sp-heading { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 8px 0 3px; }
.sp-table { width: 100%; border-collapse: collapse; margin: 10px 0; border: 1px solid var(--line, #d8d8d8); border-radius: 10px; overflow: hidden; font-size: 12.5px; }
.sp-table th, .sp-table td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line, #d8d8d8); }
.sp-table tr:last-child th, .sp-table tr:last-child td { border-bottom: none; }
.sp-table th { width: 34%; font-size: 10.5px; font-weight: 800; letter-spacing: .06em; color: var(--muted); }
.app-spark .sp-info { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line, #d8d8d8); border-radius: 12px; background: var(--field, rgba(0, 0, 0, .03)); font-size: 12.5px; }
.app-spark .sp-info-head { display: flex; align-items: center; gap: 8px; font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.sp-ico { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 5px; font-size: 11px; line-height: 1; color: #fff; flex: none; }
.sp-ico-red { background: #E5484D; } .sp-ico-blue { background: #4C6FE0; } .sp-ico-purple { background: #8E5BD6; } .sp-ico-orange { background: #F5A300; } .sp-ico-green { background: #2EA66F; }
.sp-line { display: flex; gap: 8px; align-items: flex-start; margin: 3px 0; }
.sp-line-ico { flex: none; width: 16px; text-align: center; opacity: .8; }
.sp-maplink { display: inline-block; margin-top: 4px; font-size: 12px; }
.app-spark .sp-note { font-style: italic; margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line, #d8d8d8); border-radius: 12px; background: var(--field, rgba(0, 0, 0, .03)); font-size: 12.5px; color: var(--muted); }
.app-spark .sp-toggle { display: inline-flex; align-items: center; gap: 8px; }
.app-spark .sp-chip { display: inline-flex; align-items: center; gap: 6px; }
.sp-drafts-only { margin-top: 8px; font-size: 11px; }
/* The Focus Break Router's card and its timer. */
.sp-nudge { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0; padding: 10px 12px; border-radius: 10px; border-left: 3px solid #F5A300; background: rgba(245, 163, 0, .13); font-size: 12.5px; }
.sp-kind { margin: 10px 0; padding: 10px 12px; border-radius: 10px; border-left: 3px solid #E8B923; background: rgba(232, 185, 35, .14); font-size: 12.5px; }
.sp-kind-head { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.app-spark.sp-reset-card .sp-or { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }
.sp-resets { gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.app-card button.sp-rpill { display: inline-flex; align-items: center; gap: 6px; background: var(--card, #fff); border: 1px solid var(--line, #d9d0c6); }
.sp-reset-card .sp-toggle { margin-top: 2px; }
.app-card button.sp-start-break { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border: none; border-radius: 999px; background: var(--accent); color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.app-card button.sp-start-break:hover { filter: brightness(1.06); }
/* Kindness Verified: the Simulate Checkout button and window, and the Order Confirmed card. */
.sp-checkout-row { display: flex; justify-content: center; margin: 12px 0 16px; }
.sp-simulate { display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border: 1px solid var(--line, #d8d8d8); border-radius: 999px; background: var(--field, rgba(0, 0, 0, .04)); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.sp-simulate:hover { background: var(--accent-soft); }
.sp-checkout { display: flex; flex-direction: column; gap: 10px; }
.sp-modal-card.sp-checkout input[type=text] { width: 100%; height: 44px; margin: 0; padding: 0 16px; border: 1px solid var(--placeholder); border-radius: 12px; background: var(--panel); color: var(--ink); font: inherit; box-sizing: border-box; }
.sp-modal-card.sp-checkout input[type=text]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.sp-checkout-err { color: #C62828; }
.sp-checkout-err[hidden] { display: none; }
.sp-checkout-go { height: 44px; border: 1px solid #2EA66F; border-radius: 12px; background: rgba(46, 166, 111, .12); color: var(--ink); font: inherit; font-weight: 800; cursor: pointer; }
.sp-checkout-go:disabled { opacity: .5; cursor: default; }
.sp-verified-card .sp-title { display: flex; align-items: center; gap: 8px; }
.sp-spirit { margin: 10px 0 6px; padding: 4px 10px; border: 1px solid var(--line, #d8d8d8); border-radius: 10px; font-size: 11px; font-style: italic; color: var(--muted); }
.sp-alts { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
.app-card button.sp-alt { text-align: left; padding: 8px 14px; border: 1px solid var(--line, #d8d8d8); border-radius: 999px; background: var(--card, #fff); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.app-card button.sp-alt[aria-pressed="true"] { outline: 2px solid var(--accent); }
.sp-did-row { gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.app-card button.sp-did { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 999px; background: #2EA66F; color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.app-card button.sp-did:disabled { opacity: .7; cursor: default; }
.app-card button.sp-later, .app-card button.sp-sched { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: 1px solid var(--line, #d8d8d8); border-radius: 999px; background: var(--card, #fff); font: inherit; font-weight: 700; cursor: pointer; }
.sp-did-msg { min-height: 1.1em; margin-bottom: 4px; }
.sp-timer { text-align: center; }
.sp-timer-head { font-size: 13px; font-weight: 700; color: #2EA66F; margin-bottom: 10px; }
.sp-clock { font-size: 40px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; margin: 4px 0 10px; }
.sp-timer-text { margin: 0 0 14px; font-size: 14px; }
.sp-timer-btns { display: flex; justify-content: center; gap: 10px; }
.sp-timer-btns button { padding: 8px 16px; border: 1px solid var(--line, #d8d8d8); border-radius: 999px; background: var(--card, #fff); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.sp-timer-msg { margin-top: 12px; min-height: 1.2em; font-size: 13px; color: var(--muted); }
.sp-timer .sp-pill { padding: 6px 14px; font-weight: 600; border: 1px solid var(--line, #d8d8d8); background: var(--card, #fff); }
.sp-timer .sp-pill:disabled { opacity: .5; cursor: default; }
.sp-timer [hidden] { display: none; }
/* Kindness Sparks' form under the message bar: the location, the pin, the pet chip, and the chosen tile in full colour. */
.sp-sub { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.sp-bar { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; margin: 0 auto; padding-top: 10px; }
.sp-bar[hidden] { display: none; }
.sp-bar + #composer { padding-top: 8px; }
body.campus-view-open #sparks-bar, body.guild-view-open #sparks-bar { display: none; }
.sp-chip-line { display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px; border-radius: 999px; background: var(--field); font-size: 13px; box-shadow: var(--shadow-soft, none); }
.sp-chip-line button { border: none; background: none; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.sp-tile-on .sp-tile-ico { outline: 2px solid var(--ink); outline-offset: 1px; }
.sp-tile-on .sp-tile-name { color: var(--ink); }
.sp-armed .sp-tile:not(.sp-tile-on) { opacity: .45; }
.sp-modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .35); }
.sp-modal-card { width: min(380px, 92vw); padding: 20px; border-radius: 20px; background: var(--card, #fff); color: var(--ink); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.sp-modal-head { display: flex; align-items: center; justify-content: space-between; font-weight: 800; margin-bottom: 14px; }
.sp-modal-q { font-size: 12px; font-weight: 700; color: var(--muted); margin: 12px 0 8px; text-align: center; }
.sp-modal-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.sp-modal-row button, .sp-modal-card input { font: inherit; }
.sp-pill { padding: 10px 16px; border: none; border-radius: 999px; background: var(--field); color: var(--ink); font-weight: 700; cursor: pointer; box-shadow: var(--shadow-soft, none); }
.sp-pill[aria-pressed="true"] { outline: 2px solid var(--ink); }
.sp-modal-card input[type=text] { width: 100%; height: 44px; padding: 0 16px; border: none; border-radius: 999px; background: var(--field); color: var(--ink); margin-top: 12px; }
.sp-done { width: 100%; height: 44px; margin-top: 16px; border: none; border-radius: 999px; background: var(--accent); color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.sp-done:disabled { opacity: .5; cursor: default; }
@media (max-width: 760px) { .mode-hero .mode-brand { font-size: 16px; } .mode-title { font-size: 22px; margin-top: 10px; } }

/* Kindness Guild: the three places under the room's title, the application's cards, the answer cards. */
.t-tag-guild { background: #E9E2FA; color: #4B2FA0; }
[data-theme="dark"] .t-tag-guild { background: #2F2650; color: #C9B8F5; }
.t-tag-experiences, .t-tag.t-tag-experiences { background: #DDF3E6; color: #17623B; }
[data-theme="dark"] .t-tag-experiences, [data-theme="dark"] .t-tag.t-tag-experiences { background: #1F3A2C; color: #9BE0B8; }
/* Experiences' consent card: its question and two buttons, under the message that asks. */
.exp-consent .bz-row { margin-top: 2px; }
.guild-strip { position: relative; }
.gd-btn { display: inline-flex; align-items: center; gap: 5px; border: none; background: none; padding: 0; font: inherit; font-weight: 700; color: #1F3A2E; cursor: pointer; }
.gd-btn:hover { text-decoration: underline; }
.gd-caret { font-size: 11px; }
.gd-menu { position: absolute; top: calc(100% + 8px); left: 0; z-index: 40; min-width: 180px; display: flex; flex-direction: column; padding: 6px;
  background: #fff; border: 1px solid #D9E2DC; border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); }
.gd-menu[hidden] { display: none; }
.gd-item { text-align: left; border: none; background: none; padding: 9px 12px; border-radius: 8px; font: inherit; font-size: 13.5px; color: var(--ink); cursor: pointer; }
.gd-item:hover, .gd-item:focus-visible { background: #EFE9FB; color: #4B2FA0; outline: none; }
[data-theme="dark"] .gd-btn { color: #CFE3D6; }
[data-theme="dark"] .gd-menu { background: #1E2420; border-color: #34403A; }
[data-theme="dark"] .gd-item:hover, [data-theme="dark"] .gd-item:focus-visible { background: #2F2650; color: #C9B8F5; }
.gh-home { margin-top: 18px; text-align: center; }
.gh-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.gh-chip { border: 1px solid var(--line, #d9d2c8); background: transparent; color: var(--ink); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 12.5px; cursor: pointer; }
.gh-ask { color: var(--muted); }
.gc-stack { display: flex; flex-direction: column; gap: 10px; }
.gc-key { font-size: 12px; font-weight: 700; color: #4F6B5C; margin: 10px 0 4px; }
.gc-ans { margin-bottom: 4px; }
.gc-ans .cc-answer { white-space: pre-wrap; }
.gc-mini { display: flex; gap: 12px; }
.gc-count { font-size: 12px; color: var(--muted); margin-top: 4px; }
.gc-count.over { color: #B3261E; font-weight: 700; }
.gc-venues { margin-bottom: 4px; }
.gc-steps { margin: 4px 0 0 18px; padding: 0; font-size: 13.5px; }
.gc-steps li { margin: 5px 0; }
.gc-item + .gc-item { margin-top: 8px; }
[data-theme="dark"] .gc-key { color: #CFE3D6; }

/* The sidebar tags carry their app's header colour: Campus blue, Guild purple (the plain .t-tag colour comes later in this file and used to win). */
.t-tag.t-tag-campus { background: #DDEEFB; color: #12507F; }
[data-theme="dark"] .t-tag.t-tag-campus { background: #1E3A52; color: #9CCBF0; }
.t-tag.t-tag-guild { background: #E9E2FA; color: #4B2FA0; }
[data-theme="dark"] .t-tag.t-tag-guild { background: #2F2650; color: #C9B8F5; }
.t-tag.t-tag-sparks { background: #FFF0C2; color: #6B4A00; }
[data-theme="dark"] .t-tag.t-tag-sparks { background: #4A3A10; color: #F5D98A; }
.t-tag-sparks { background: #FFF0C2; color: #6B4A00; }

/* Kindness Guild's own guilds: notices, search, results, status, review. Drawn only while the chat is in Guild. */
.gd-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #D14B2F; margin: 0 2px 1px 2px; vertical-align: middle; }
/* the number of chat messages not read yet, beside "Guilds" */
.gd-count { display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 999px; background: #D14B2F; color: #fff; font-size: 11px; font-weight: 800; line-height: 16px; text-align: center; margin: 0 2px; }
/* the demo's mailbox */
.gc-mail-item { margin-top: 8px; border: 1px solid rgba(0,0,0,.12); border-radius: 10px; padding: 8px 12px; background: rgba(255,255,255,.6); }
.gc-mail-item summary { cursor: pointer; }
.gc-mail-at { color: #6b7280; font-size: 12px; margin-left: 6px; }
.gc-mail { white-space: pre-wrap; margin-top: 8px; font-size: 13px; line-height: 1.45; }
[data-theme="dark"] .gc-mail-item { border-color: rgba(255,255,255,.16); background: rgba(255,255,255,.05); }
.gh-notice { display: block; margin: 0 auto 10px; border: 1px solid #7E62D4; background: #EFE9FB; color: #4B2FA0; border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.gh-note { margin-top: 12px; font-size: 12px; color: var(--muted); text-align: center; }
.gg-stats { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.gg-search { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 600px) { .gg-search { grid-template-columns: 1fr; } }
.gg-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.gg-item { border: 1px solid var(--line, #e7dfd6); border-radius: 12px; padding: 10px 12px; background: rgba(255, 255, 255, .6); margin-top: 8px; }
.gg-list .gg-item { margin-top: 0; }
.gg-name { font-weight: 800; color: var(--ink); overflow-wrap: anywhere; }
.gg-desc { font-size: 13.5px; margin-top: 2px; overflow-wrap: anywhere; }
.gg-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.gg-extra { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.gg-chip { display: inline-block; font-size: 11.5px; font-weight: 800; padding: 2px 10px; border-radius: 999px; background: #E9E2FA; color: #4B2FA0; }
.gg-chip.gg-live { background: #DDF0E4; color: #1F5A3B; }
.gg-chip.gg-pending { background: #FBEFD2; color: #7A5200; }
.gg-chip.gg-declined { background: #F8DCD6; color: #8A2A18; }
.gg-new { display: inline-block; font-size: 10.5px; font-weight: 800; padding: 1px 7px; border-radius: 999px; background: #D14B2F; color: #fff; }
[data-theme="dark"] .gg-item { background: rgba(255, 255, 255, .04); border-color: #34403A; }
[data-theme="dark"] .gh-notice { background: #2F2650; color: #C9B8F5; }

/* Phase 2: guild buttons, how people join, requests, meetups. */
.gg-acts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
a.gg-act, button.gg-act { margin-top: 0; padding: 5px 12px; font-size: 12.5px; }
.gg-small { padding: 4px 12px; font-size: 12.5px; }
.gg-conf { width: 100%; border: 1px solid #E0B9AE; background: #FDF3EF; border-radius: 10px; padding: 8px 12px; }
.gg-modes, .gg-reqs { width: 100%; }
.gg-req { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; border-top: 1px solid var(--line, #e7dfd6); }
.gg-req:first-of-type { border-top: 0; }
.gg-meet { margin-top: 10px; }
[data-theme="dark"] .gg-conf { background: #3A2620; border-color: #6A3D31; }

/* The leader's page for one guild: header, three numbers, what is left to do, two columns (the guild's things, and its people). */
body.guild-view-open #composer, body.guild-view-open #attachbar { display: none; }
.guild-view { max-width: 980px; }
.guild-view[hidden] { display: none; }
.gp { display: flex; flex-direction: column; gap: 14px; padding-bottom: 40px; }
.gp-head { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.gp-back { padding: 0; }
.gp-title { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -.3px; color: var(--ink); overflow-wrap: anywhere; }
.gp-desc { max-width: 620px; color: var(--muted); overflow-wrap: anywhere; }
.gp-banner { border: 1px solid #E0B9AE; background: #FDF3EF; border-radius: 12px; padding: 10px 14px; font-size: 13.5px; }
.gp-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.gp-stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; }
.gp-stat b { font-size: 26px; line-height: 1.1; }
.gp-stat span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.gp-todo { border-color: #F2B49F; }
.gp-todo-title { margin-bottom: 8px; }
.gp-left { color: #D14B2F; font-weight: 800; }
.gp-todo-row { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line, #e7dfd6); border-radius: 12px; padding: 10px 12px; margin-top: 8px; }
.gp-todo-row > div { flex: 1; }
.gp-todo-row.done { opacity: .6; }
.gp-tick { width: 20px; height: 20px; border: 2px solid #D14B2F; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; color: #fff; flex: none; }
.gp-todo-row.done .gp-tick { background: #2F7A4F; border-color: #2F7A4F; }
.gp-todo-go { flex: none; margin: 0; }
.gp-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.gp-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.gp-card .cc-why { margin-bottom: 8px; }
.gp-big { font-size: 20px; font-weight: 800; margin-bottom: 4px; overflow-wrap: anywhere; }
.gp-req { align-items: flex-start; flex-wrap: wrap; }
.gp-req-btns { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.gp-member { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line, #e7dfd6); }
.gp-member:first-of-type { border-top: 0; }
.gp-avatar { width: 38px; height: 38px; border-radius: 50%; color: #fff; font-weight: 800; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.gp-mbody { min-width: 0; }
.gp-mname { font-weight: 700; overflow-wrap: anywhere; }
.gp-vnote { font-size: 12px; color: var(--muted); margin-top: 2px; }
.gp-status { min-height: 1.2em; }
@media (max-width: 760px) { .gp-cols { grid-template-columns: 1fr; } .gp-stats { gap: 8px; } .gp-title { font-size: 22px; } }
[data-theme="dark"] .gp-banner { background: #3A2620; border-color: #6A3D31; }

/* Guild: chat, report, delete (Phase 4) */
.gk-chat { display: flex; flex-direction: column; gap: 8px; }
.gk-list { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; padding-right: 2px; }
.gk-msg { border: 1px solid var(--line, #e7dfd6); border-radius: 12px; padding: 8px 12px; background: var(--card, #fff); }
.gk-msg.mine { background: #FFF6F1; border-color: #F2D4C7; }
.gk-who { font-size: 12.5px; color: var(--muted); }
.gk-who b { color: var(--ink); }
.gk-when { margin-left: 6px; font-size: 11.5px; }
.gk-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.gk-acts { display: flex; gap: 10px; margin-top: 2px; }
.gk-link { padding: 0 !important; font-size: 12px !important; min-height: 0 !important; text-decoration: underline; }
.gg-report { margin-top: 6px; }
.cc-status.ok { color: #2F7A4F; }
.gp-danger { background: #B3261E !important; border-color: #B3261E !important; color: #fff !important; }
[data-theme="dark"] .gk-msg { background: #2A2522; border-color: #4A403A; }
[data-theme="dark"] .gk-msg.mine { background: #3A2A24; border-color: #6A4A3C; }

/* Guild: the leader's panel in My guilds, and the chat's live line */
.gl-panel { display: flex; flex-direction: column; gap: 8px; }
.gl-town { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.gl-name { font-size: 19px; font-weight: 800; overflow-wrap: anywhere; }
.gl-state { color: #2F7A4F; font-weight: 700; font-size: 13px; margin-top: 4px; }
.gl-state.paused { color: #B3631A; }
.gl-sep { border: 0; border-top: 1px solid var(--line, #e7dfd6); margin: 2px 0; width: 100%; }
.gl-sec { margin-top: 10px; }
.gl-link { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: #EAF1FE; border: 1px solid #C9D9F7; border-radius: 10px; padding: 10px 12px; overflow-wrap: anywhere; }
.gl-share { display: flex; gap: 8px; flex-wrap: wrap; }
.gl-pill { border: 1px solid var(--line, #e0d6cb); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--ink); text-decoration: none; background: var(--card, #fff); }
.gl-pill:hover { border-color: #D14B2F; }
.gk-live { font-size: 12px; color: var(--muted); }
.gk-live.error { color: #B3261E; }
[data-theme="dark"] .gl-link { background: #1F2A3F; border-color: #38507E; }
.gl-toggle { all: unset; box-sizing: border-box; display: flex; width: 100%; align-items: flex-start; justify-content: space-between; gap: 10px; cursor: pointer; border-radius: 10px; padding: 2px; }
.gl-toggle:focus-visible { outline: 2px solid #D14B2F; outline-offset: 2px; }
.gl-headtext { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gl-arrow { flex: none; width: 30px; height: 30px; border: 1px solid var(--line, #e0d6cb); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; transition: transform .15s; }
.gl-panel.open .gl-arrow { transform: rotate(180deg); }
.gl-toggle:hover .gl-arrow { border-color: #D14B2F; }
.gl-details { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.gl-details[hidden] { display: none; }

/* Guild chat as a conversation: others on the left, you on the right, in bubbles */
.gk-list { gap: 10px; padding: 4px 2px; }
.gk-msg { max-width: 82%; align-self: flex-start; border: 0; background: #F1ECE6; border-radius: 16px 16px 16px 4px; padding: 8px 12px; }
.gk-msg.mine { align-self: flex-end; background: #DCE8FB; border-radius: 16px 16px 4px 16px; }
.gk-msg .gk-who { display: flex; gap: 8px; align-items: baseline; }
.gk-msg.mine .gk-who { justify-content: flex-end; }
.gk-msg .gk-text { font-size: 15px; }
.gk-msg .gk-acts { opacity: .75; }
.gk-msg.mine .gk-acts { justify-content: flex-end; }
[data-theme="dark"] .gk-msg { background: #332D29; }
[data-theme="dark"] .gk-msg.mine { background: #2B3B57; }
.gl-pill { display: inline-flex; align-items: center; gap: 8px; }
.gl-ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.gl-ico svg { width: 18px; height: 18px; display: block; }

/* A guild's chat: pictures and PDFs, the + button, the mic, and the frame shown while files are dragged over it */
.gk-row { align-items: center; gap: 8px; flex-wrap: wrap; }
.cc-outline.gk-tool { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0 !important;
  border: none; border-radius: 8px; background: transparent; color: var(--ink); }
.cc-outline.gk-tool:hover { background: var(--hover); }
.gk-tool .ico { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.gk-mic.recording { background: #fce8e6 !important; border-color: #ea4335 !important; color: #ea4335 !important; animation: micpulse 1.2s ease-in-out infinite; }
.gk-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gk-chips[hidden] { display: none; }
.gk-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 8px; border: 1px solid var(--line, #e7dfd6); border-radius: 999px; font-size: 12.5px; background: var(--card, #fff); color: var(--ink); max-width: 100%; }
.gk-chip.pic { padding-left: 4px; }
.gk-chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; display: block; }
.gk-x { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 6px; cursor: pointer; }
.gk-x:hover { color: var(--ink); }
.gk-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.gk-pic { display: block; border-radius: 10px; overflow: hidden; line-height: 0; }
.gk-pic img { max-width: 220px; max-height: 180px; display: block; object-fit: cover; }
.gk-doc { display: inline-block; padding: 6px 10px; border-radius: 10px; background: rgba(0,0,0,.05); color: var(--ink); font-size: 13px; text-decoration: none; overflow-wrap: anywhere; }
.gk-doc:hover { text-decoration: underline; }
.gk-hint { font-size: 12px; }
.gk-problem:empty { display: none; }
.gk-chat.gk-drop { position: relative; outline: 2px dashed var(--accent); outline-offset: 3px; border-radius: 12px; }
.gk-chat.gk-drop::after { content: "Drop pictures or PDFs here to send them to the guild"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px;
                          font-weight: 800; color: var(--accent-ink); background: color-mix(in srgb, var(--bg) 85%, transparent); border-radius: 12px; pointer-events: none; }
.gg-who { overflow-wrap: anywhere; }
[data-theme="dark"] .gk-doc { background: rgba(255,255,255,.08); }

/* Not signed in: the locked controls, and the sign-in prompt */
.locked-ctl { cursor: pointer; }   /* a signed-out person sees the controls normally; clicking one asks them to sign in */
.signin-prompt { position: fixed; inset: 0; z-index: 9999; background: rgba(30, 25, 20, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sp-box { background: var(--card, #fff); color: var(--ink, #2a2420); border-radius: 16px; max-width: 420px; width: 100%; padding: 22px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.sp-title { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.sp-text { color: var(--muted, #6b6058); font-size: 14.5px; margin-bottom: 16px; }
.sp-row { display: flex; gap: 10px; }
.sp-go { background: #D14B2F; color: #fff; border: 0; border-radius: 999px; padding: 10px 20px; font: inherit; font-weight: 700; cursor: pointer; }
.sp-close { background: transparent; border: 1px solid var(--line, #e0d6cb); border-radius: 999px; padding: 10px 18px; font: inherit; cursor: pointer; color: inherit; }

/* Kindness Sparks' location chip sits inside the message box: the box grows to hold it above the words. */
#loc-chip-row { display: flex; min-width: 0; padding: 2px 12px 0; }
#loc-chip-row[hidden] { display: none; }
.msgfield.has-loc { flex-direction: column; align-items: stretch; padding-top: 8px; border-radius: 22px; background: var(--field);
  box-shadow: var(--shadow-soft), 0 0 0 1.5px color-mix(in srgb, var(--accent) 30%, transparent); }
.msgfield.has-loc:focus-within { box-shadow: var(--shadow-soft), 0 0 0 3px var(--ring); }
#composer .msgfield.has-loc #text, #composer .msgfield.has-loc #text:hover, #composer .msgfield.has-loc #text:focus {
  flex: 0 0 48px; height: 48px; background: transparent; box-shadow: none; }
#composer .msgfield.has-loc #attach { top: auto; bottom: 5px; transform: none; }
#composer .msgfield.has-loc #mic, #composer .msgfield.has-loc #camera, #composer .msgfield.has-loc #send { top: auto; bottom: 5px; margin-top: 0; }
#composer .msgfield.has-loc #mic-wave { top: auto; bottom: 9px; transform: none; }
.loc-chip { display: inline-flex; align-items: center; max-width: 100%; min-width: 0; border: 1px dashed #E3B341; border-radius: 999px;
  background: #FFF6D8; color: #6B4500; }
.loc-chip.set { border: 1px solid #F2B8C0; background: #FFF0F2; color: #7C1D2E; }
[data-theme="dark"] .loc-chip { border-color: #8A6D24; background: #3A3016; color: #F5D98A; }
[data-theme="dark"] .loc-chip.set { border-color: #7D3F4A; background: #3B2229; color: #FFC7D0; }
#composer #loc-chip-row button { display: inline-flex; align-items: center; gap: 6px; min-width: 0; height: 28px; padding: 0 10px; border: none;
  border-radius: 999px; background: transparent; color: inherit; box-shadow: none; font-size: 12.5px; font-weight: 700; transform: none; filter: none; }
#composer #loc-chip-row button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.loc-chip-text { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.loc-chip-text em { font-style: normal; font-weight: 600; opacity: .75; }
#composer #loc-chip-row .loc-clear { flex: none; padding: 0 9px; border-left: 1px solid color-mix(in srgb, currentColor 25%, transparent);
  border-radius: 0 999px 999px 0; font-size: 11px; }
/* ...and the card it opens. */
.loc-card { position: fixed; z-index: 60; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; box-sizing: border-box;
  padding: 14px; border-radius: 16px; background: var(--card); color: var(--ink); box-shadow: var(--shadow-pop);
  border: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); text-align: left; }
.loc-card button { font-family: inherit; cursor: pointer; }
.loc-card > * { flex: none; }
.loc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 8px; font-size: 14px; font-weight: 800;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); }
.loc-x { border: none; background: none; color: var(--muted); font-size: 14px; padding: 2px 6px; border-radius: 6px; }
.loc-x:hover { background: var(--hover); color: var(--ink); }
.loc-gps { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); background: color-mix(in srgb, var(--accent) 9%, transparent);
  color: var(--accent); font-size: 13px; font-weight: 800; text-align: left; }
.loc-gps:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.loc-gps:disabled { opacity: .6; cursor: default; }
.loc-acc { font-size: 11px; font-weight: 600; opacity: .8; white-space: nowrap; }
.loc-type { display: flex; gap: 8px; }
.loc-input { flex: 1; min-width: 0; height: 36px; padding: 0 12px; border-radius: 10px; font: inherit; font-size: 13px; color: var(--ink);
  background: var(--field); border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); }
.loc-input:focus { outline: none; box-shadow: 0 0 0 3px var(--ring); }
@media (max-width: 480px) { .loc-input { font-size: 16px; } }   /* 16px stops phones zooming in */
.loc-set { height: 36px; padding: 0 16px; border: none; border-radius: 10px; color: #fff; font-size: 13px; font-weight: 800;
  background: linear-gradient(135deg, #6A9BFF 0%, var(--accent) 100%); }
.loc-msg { font-size: 12.5px; color: var(--muted); }
.loc-list-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 800; letter-spacing: .6px;
  text-transform: uppercase; color: var(--muted); }
.loc-forget { border: none; background: none; padding: 0; color: var(--accent); font-size: 11px; font-weight: 700; }
.loc-list { display: flex; flex-direction: column; gap: 2px; margin-top: -4px; }
.loc-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 8px; border: none; border-radius: 8px;
  background: none; color: var(--ink); font-size: 13px; text-align: left; }
.loc-item:hover, .loc-item:focus-visible { background: var(--hover); outline: none; }
.loc-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.loc-code { flex: none; font-size: 11.5px; color: var(--muted); }
.loc-hint { padding: 4px 8px; font-size: 12.5px; color: var(--muted); }
/* The place a message was sent with, inside its bubble under a thin line. */
.msg.person .loc-line { margin-top: 8px; padding-top: 7px; font-size: 12px; font-weight: 700; color: var(--green-ink); white-space: normal;
  overflow-wrap: anywhere; border-top: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); }
