:root {
  --bg: #ffffff; --side: #f9f9f9; --hover: #ececec; --active: #e3e3e3;
  --line: #e5e5e5; --text: #0d0d0d; --muted: #6b6b6b; --bubble: #f4f4f4;
  --field: #ffffff; --field-line: #d9d9d9; --code-bg: #f6f6f6; --code-head: #ececec;
  --accent: #2f5fd0; --accent-text: #ffffff; --danger: #c0291f; --ok: #1f9d55;
  --shadow: 0 4px 24px rgba(0, 0, 0, .12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #212121; --side: #181818; --hover: #2a2a2a; --active: #333333;
    --line: #333333; --text: #ececec; --muted: #a3a3a3; --bubble: #2f2f2f;
    --field: #2b2b2b; --field-line: #424242; --code-bg: #171717; --code-head: #2a2a2a;
    --accent: #8eaeff; --accent-text: #10131c; --danger: #ff8a80; --ok: #5fd08a;
    --shadow: 0 4px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #212121; --side: #181818; --hover: #2a2a2a; --active: #333333;
  --line: #333333; --text: #ececec; --muted: #a3a3a3; --bubble: #2f2f2f;
  --field: #2b2b2b; --field-line: #424242; --code-bg: #171717; --code-head: #2a2a2a;
  --accent: #8eaeff; --accent-text: #10131c; --danger: #ff8a80; --ok: #5fd08a;
  --shadow: 0 4px 24px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; overflow: hidden; background: var(--bg); color: var(--text);
  font: 16px/1.6 system-ui, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
svg {
  width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.spacer { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.text-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px;
  border-radius: 18px; font-size: 14px;
}
.text-btn:hover { background: var(--hover); }
.text-btn svg { width: 18px; height: 18px; }

/* Sidebar */
#sidebar {
  width: 260px; flex: none; display: flex; flex-direction: column;
  background: var(--side); border-right: 1px solid var(--line);
  transition: margin-left .18s ease;
}
.sidebar-closed #sidebar { margin-left: -260px; }
.side-top { display: flex; align-items: center; gap: 2px; padding: 10px 8px 6px 16px; }
.brand { flex: 1; font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.nav-item {
  display: flex; align-items: center; gap: 10px; margin: 2px 8px; padding: 8px 10px;
  border-radius: 10px; font-size: 14.5px; text-align: left;
}
.nav-item:hover { background: var(--hover); }
#search-box { padding: 6px 8px 2px; }
#search {
  width: 100%; font: inherit; font-size: 14px; color: inherit; background: var(--field);
  border: 1px solid var(--field-line); border-radius: 10px; padding: 7px 10px; outline: none;
}
#search:focus { border-color: var(--accent); }
#chat-list { flex: 1; overflow-y: auto; padding: 6px 8px 8px; scrollbar-width: thin; }
.section-label { padding: 14px 10px 4px; font-size: 13px; color: var(--muted); }
.list-empty { padding: 10px; font-size: 13.5px; color: var(--muted); }
.chat-row { position: relative; display: flex; align-items: center; border-radius: 10px; }
.chat-row:hover, .chat-row.menu-open { background: var(--hover); }
.chat-row.active { background: var(--active); }
.chat-row .open {
  flex: 1; min-width: 0; padding: 7px 10px; font-size: 14.5px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-row .more {
  width: 30px; height: 30px; margin-right: 3px; border-radius: 7px; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; opacity: 0;
}
.chat-row:hover .more, .chat-row.active .more, .chat-row.menu-open .more,
.chat-row .more:focus-visible { opacity: 1; }
.chat-row .more:hover { color: var(--text); }
.chat-row input {
  flex: 1; min-width: 0; margin: 3px; padding: 4px 7px; font: inherit; font-size: 14.5px;
  color: inherit; background: var(--field); border: 1px solid var(--accent);
  border-radius: 7px; outline: none;
}
.side-bottom {
  display: flex; align-items: center; gap: 2px; padding: 10px 8px 10px 14px;
  border-top: 1px solid var(--line);
}
.side-bottom .icon-btn { flex: none; }
.model-badge { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.model-badge strong { display: block; font-size: 14px; font-weight: 600; line-height: 1.25; }
.model-badge > div { min-width: 0; }
.model-badge small {
  display: block; font-size: 12px; color: var(--muted); line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }

/* Main column */
main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
#topbar { display: flex; align-items: center; gap: 4px; height: 52px; padding: 0 10px; flex: none; }
#chat-title {
  padding: 0 8px; font-size: 17px; font-weight: 550; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.only-closed { display: none; }
.sidebar-closed .only-closed { display: inline-flex; }

#thread { flex: 1; overflow-y: auto; scrollbar-gutter: stable both-edges; }
#messages { max-width: 800px; margin: 0 auto; padding: 12px 20px 28px; }
.msg { margin-bottom: 22px; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.bubble {
  max-width: 78%; background: var(--bubble); border-radius: 20px; padding: 9px 16px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .12s; }
.msg:hover .actions, .msg.last .actions, .actions:focus-within { opacity: 1; }
.actions button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; color: var(--muted);
}
.actions button:hover { background: var(--hover); color: var(--text); }
.actions svg { width: 17px; height: 17px; }
.streaming .actions { visibility: hidden; }
/* Reading aloud is offered only when there is a voice to read with. */
body:not(.can-speak) .speak-btn { display: none; }
.actions button.speaking { color: var(--accent); }
.actions button.given { color: var(--accent); }
.chip.recording[aria-pressed="true"] {
  color: var(--danger); border-color: var(--danger); background: none;
}
.chip.recording svg { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* Tool steps inside a reply */
.steps { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.steps:empty { display: none; }
.step { border: 1px solid var(--line); border-radius: 12px; font-size: 14px; }
.step > summary {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; cursor: pointer;
  list-style: none; color: var(--muted);
}
.step > summary::-webkit-details-marker { display: none; }
.step > summary:hover { color: var(--text); }
.step .mark { width: 16px; height: 16px; flex: none; }
.step .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step .state { flex: none; font-size: 12.5px; }
.step.done .mark { color: var(--ok); }
.step.failed .mark, .step.invalid .mark, .step.denied .mark { color: var(--danger); }
.step.repeated .mark, .step.repeated .state { color: var(--muted); }
.step.failed .state, .step.invalid .state, .step.denied .state { color: var(--danger); }
.step.running .mark, .step.waiting .mark { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.step-body { padding: 0 12px 10px; }
.step-body h4 { margin: 8px 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.step-body pre {
  margin: 0; padding: 8px 10px; max-height: 240px; overflow: auto; border-radius: 8px;
  background: var(--code-bg); font: 12.5px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.approval {
  margin: 0 12px 12px; padding: 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}
.approval p { margin: 0 0 4px; color: var(--text); }
.approval small { display: block; margin-bottom: 10px; color: var(--muted); }
.approval .caution {
  margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; font-size: 13.5px;
  color: var(--danger); border: 1px solid var(--danger);
}
.approval-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.approval-buttons button {
  padding: 6px 14px; border-radius: 16px; font-size: 14px; border: 1px solid var(--field-line);
  background: var(--field);
}
.approval-buttons button:hover { background: var(--hover); }
.approval-buttons button.primary {
  background: var(--accent); color: var(--accent-text); border-color: var(--accent);
}
.approval-buttons button.primary:hover { filter: brightness(1.08); background: var(--accent); }
.md:empty { display: none; }
@media (prefers-reduced-motion: reduce) {
  .step.running .mark, .step.waiting .mark { animation: none; }
}

/* Tools dialog */
dialog {
  width: min(560px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 48px));
  padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--bg);
  color: var(--text); box-shadow: var(--shadow); overflow: auto;
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
.dialog-head { display: flex; align-items: center; padding: 14px 12px 4px 20px; }
.dialog-head h2 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; }
.dialog-note { margin: 0; padding: 0 20px 10px; font-size: 14px; color: var(--muted); }
#tools-list { padding: 0 20px 16px; }
.tool-row { padding: 12px 0; border-top: 1px solid var(--line); }
.tool-row-head { display: flex; align-items: center; gap: 8px; }
.tool-row-head strong { font-size: 14.5px; font-weight: 600; }
.tier {
  font-size: 11.5px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--field-line);
  color: var(--muted);
}
.tool-row p { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }
.tool-row label {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; white-space: nowrap;
}

/* Documents in use: a count on the button and the file names above the message box */
.chip.has-docs { color: var(--accent); border-color: var(--accent); }
.chip .count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 12px;
  line-height: 20px; text-align: center; font-weight: 600;
  background: var(--accent); color: var(--accent-text);
}
#docs-strip { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 4px 8px; }
.doc-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 260px; height: 28px;
  padding: 0 10px; border-radius: 14px; font-size: 13px; color: var(--muted);
  background: var(--bubble);
}
.msg-attachments { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-bottom: 6px; }
.msg-attachments .doc-chip { border: 1px solid var(--line); background: none; }
.doc-chip svg { width: 15px; height: 15px; }
.doc-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sharing exists only where there is a login, and only for a chat with messages. */
body:not(.can-share) #btn-share, body.home #btn-share { display: none; }
#share-list { padding: 0 20px 16px; }
.share-row {
  display: flex; align-items: center; gap: 6px; padding: 9px 0; border-top: 1px solid var(--line);
}
.share-row .share-what { flex: 1; min-width: 0; }
.share-row .share-title { font-size: 14.500px; overflow-wrap: anywhere; }
.share-row .share-link { font-size: 12.500px; color: var(--muted); overflow-wrap: anywhere; }
.share-row.other .share-title { color: var(--muted); }

/* Activity dialog */
#activity-list { padding: 0 20px 16px; }
.activity-row { padding: 9px 0; border-top: 1px solid var(--line); }
.activity-row .what { font-size: 14.5px; overflow-wrap: anywhere; }
.activity-row.refused .what, .activity-row.removed .what { color: var(--danger); }
.activity-row .detail {
  margin-top: 2px; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere;
}

/* Feedback dialog (D126) */
.feedback-form { display: flex; flex-direction: column; gap: 6px; padding: 0 20px 16px; }
.feedback-verdicts {
  display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 6px; padding: 0; border: 0;
}
.feedback-verdicts legend { padding: 0; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.feedback-verdicts label { display: inline-flex; align-items: center; gap: 6px; font-size: 14.5px; }
.feedback-form > label { font-size: 14px; color: var(--muted); }
.feedback-form textarea {
  font: inherit; font-size: 14.5px; color: inherit; background: var(--field);
  border: 1px solid var(--field-line); border-radius: 10px; padding: 7px 10px; outline: none;
  resize: vertical;
}
.feedback-form textarea:focus { border-color: var(--accent); }
#feedback-error {
  padding: 8px 12px; border-radius: 10px; font-size: 13.5px;
  color: var(--danger); border: 1px solid var(--danger);
}
.feedback-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* Memory dialog */
.memory-add { display: flex; gap: 8px; padding: 0 20px 12px; }
.memory-add input, .memory-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 14.5px; color: inherit;
  background: var(--field); border: 1px solid var(--field-line); border-radius: 10px;
  padding: 7px 10px; outline: none;
}
.memory-add input:focus, .memory-row input:focus { border-color: var(--accent); }
#memory-error {
  margin: 0 20px 12px; padding: 8px 12px; border-radius: 10px; font-size: 13.5px;
  color: var(--danger); border: 1px solid var(--danger);
}
#memory-list { padding: 0 20px 16px; }
.memory-row {
  display: flex; align-items: center; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line);
}
.memory-row .memory-text { flex: 1; min-width: 0; font-size: 14.5px; overflow-wrap: anywhere; }

/* Documents dialog */
.docs-actions { display: flex; align-items: center; gap: 12px; padding: 0 20px 12px; }
.text-btn.primary { background: var(--accent); color: var(--accent-text); }
.text-btn.primary:hover { background: var(--accent); filter: brightness(1.08); }
.text-btn:disabled { opacity: .5; }
#docs-status { font-size: 13.5px; color: var(--muted); }
#docs-error {
  margin: 0 20px 12px; padding: 8px 12px; border-radius: 10px; font-size: 13.5px;
  color: var(--danger); border: 1px solid var(--danger); white-space: pre-line;
}
#docs-list { padding: 0 20px 16px; }
.doc-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.doc-row .doc-name { flex: 1; min-width: 0; }
.doc-row strong {
  display: block; font-size: 14.5px; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.doc-row small { display: block; font-size: 12.5px; color: var(--muted); }
.docs-empty { padding: 14px 0; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }

/* Rendered Markdown */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 14px; }
.md h1, .md h2, .md h3, .md h4 { margin: 22px 0 10px; line-height: 1.3; font-weight: 650; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; }
.md h3 { font-size: 1.1em; } .md h4 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 14px; padding-left: 26px; }
.md li { margin: 4px 0; }
.md li > ul, .md li > ol { margin: 4px 0 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.md a { color: var(--accent); text-underline-offset: 2px; }
.md blockquote {
  margin: 0 0 14px; padding: 2px 0 2px 14px; border-left: 3px solid var(--line);
  color: var(--muted);
}
.md code {
  font: .875em/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--code-bg); border-radius: 5px; padding: .15em .4em;
}
.code { margin: 0 0 14px; border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 8px 5px 14px; font-size: 12.5px; color: var(--muted); background: var(--code-head);
}
.code-head button { font-size: 12.5px; padding: 3px 8px; border-radius: 6px; color: var(--muted); }
.code-head button:hover { background: var(--hover); color: var(--text); }
.code pre { margin: 0; padding: 14px; overflow-x: auto; }
.code pre code { background: none; padding: 0; font-size: 13.5px; white-space: pre; }
.table-wrap { overflow-x: auto; margin: 0 0 14px; }
.md table { border-collapse: collapse; font-size: .94em; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 7px 14px 7px 0; text-align: left; }
.md th { font-weight: 600; border-bottom-width: 2px; }

.md .katex-display { margin: 0 0 14px; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.md .katex { font-size: 1.08em; }

.typing { display: inline-flex; gap: 4px; padding: 10px 0; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .typing i { animation: none; opacity: .6; }
  #sidebar { transition: none; }
}

/* Composer */
#dock { flex: none; padding: 0 20px 10px; }
#greeting {
  display: none; margin: 0 0 26px; font-size: 28px; font-weight: 500; text-align: center;
  letter-spacing: -.01em;
}
#composer {
  max-width: 768px; margin: 0 auto; background: var(--field);
  border: 1px solid var(--field-line); border-radius: 26px; padding: 10px 10px 8px 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
}
#composer:focus-within { border-color: var(--muted); }
#input {
  display: block; width: 100%; resize: none; border: 0; outline: none; background: none;
  color: inherit; font: inherit; padding: 6px 8px; max-height: 220px;
}
#input::placeholder { color: var(--muted); }
.composer-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border-radius: 17px; font-size: 14px; color: var(--muted); border: 1px solid transparent;
}
.chip svg { width: 18px; height: 18px; }
.chip:hover { background: var(--hover); color: var(--text); }
.chip[aria-pressed="true"] {
  color: var(--accent); border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
#btn-send {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent);
  color: var(--accent-text); display: inline-flex; align-items: center; justify-content: center;
}
#btn-send svg { stroke-width: 2.4; }
#btn-send:disabled { opacity: .35; }
#btn-send .icon-stop { display: none; }
.busy #btn-send .icon-stop { display: block; }
.busy #btn-send .icon-send { display: none; }
.disclaimer { margin: 8px 0 0; text-align: center; font-size: 12.5px; color: var(--muted); }
#error {
  max-width: 768px; margin: 0 auto 8px; padding: 8px 14px; border-radius: 12px;
  font-size: 14px; color: var(--danger); border: 1px solid var(--danger);
}

/* Home: nothing in the thread yet, so the composer sits in the middle. */
body.home #thread { display: none; }
body.home #dock { margin: auto 0; padding-bottom: 14vh; }
body.home #greeting { display: block; }

/* Popup menu and toast */
#menu {
  position: fixed; z-index: 30; min-width: 170px; padding: 6px; background: var(--field);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
#menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border-radius: 8px; font-size: 14.5px; text-align: left;
}
#menu button:hover, #menu button:focus-visible { background: var(--hover); outline: none; }
#menu button.danger { color: var(--danger); }
#menu svg { width: 18px; height: 18px; }
#toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 40;
  background: var(--text); color: var(--bg); font-size: 14px; padding: 7px 14px;
  border-radius: 18px; box-shadow: var(--shadow);
}

/* Narrow screens: the sidebar slides over the chat. */
#scrim { display: none; }
@media (max-width: 760px) {
  #sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; box-shadow: var(--shadow); }
  .sidebar-closed #sidebar { box-shadow: none; }
  html:not(.sidebar-closed) #scrim {
    display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .4);
  }
  .bubble { max-width: 90%; }
  #messages { padding: 8px 14px 20px; }
  #dock { padding: 0 10px 8px; }
  #greeting { font-size: 24px; }
  .actions { opacity: 1; }
}

/* The login page (login.html). Kept last, where its own <style> used to follow this
   file: the content policy refuses inline style (D116). */
body.page-login { display: grid; place-items: center; min-height: 100vh; margin: 0; }
.login { width: min(360px, 90vw); }
.login h1 { font-size: 26px; margin: 0 0 6px; }
.login p { margin: 0 0 18px; color: var(--muted); font-size: 14.500px; }
.login input {
  width: 100%; box-sizing: border-box; font: inherit; color: inherit;
  background: var(--field); border: 1px solid var(--field-line); border-radius: 12px;
  padding: 11px 14px; outline: none;
}
.login input:focus { border-color: var(--accent); }
.login button {
  width: 100%; margin-top: 12px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 12px;
  padding: 11px 14px;
}
.login button:disabled { opacity: .6; cursor: default; }
#login-error { margin-top: 12px; color: var(--danger); font-size: 14px; min-height: 20px; }
/* The accounts' page (account.html, D162): several fields, and links between its forms. */
.login input + input, .login input + .password-field, .password-field + .password-field { margin-top: 10px; }
/* A password field with a button to show or hide what is typed. */
.password-field { position: relative; }
.login .password-field input { padding-right: 46px; }
.login .pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 34px; height: 34px; margin: 0; padding: 0; border-radius: 8px;
  display: grid; place-items: center; background: none; color: var(--muted);
}
.login .pw-toggle:hover { background: var(--hover); color: var(--text); }
.login .pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pw-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.800; stroke-linecap: round; stroke-linejoin: round; }
.login input[hidden] { display: none; }
.account-links { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; font-size: 14px; }
.account-links a { color: var(--accent); }
.account-links a[hidden] { display: none; }

/* A shared chat (share.html), likewise. */
body.page-share { display: block; margin: 0; }
.shared { max-width: 780px; margin: 0 auto; padding: 28px 20px 60px; }
.shared header { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 22px; }
.shared h1 { font-size: 22px; margin: 0 0 4px; overflow-wrap: anywhere; }
.shared .note { color: var(--muted); font-size: 13.500px; margin: 0; }
.shared .msg { margin: 0 0 22px; }
.shared .msg.user { display: flex; justify-content: flex-end; }
#share-error { color: var(--danger); }

/* The administrators' page (admin.html, D166). */
body.page-admin { display: block; margin: 0; padding: 0 16px 48px; max-width: 1040px; margin-inline: auto; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 0 8px; }
.admin-head h1 { font-size: 22px; margin: 0; }
.admin-tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.admin-tab { font: inherit; color: var(--muted); background: none; border: 0; border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.admin-tab:hover { background: var(--hover); color: var(--text); }
.admin-tab.active { background: var(--active); color: var(--text); font-weight: 600; }
.admin-main { padding-top: 16px; }
.admin-error { margin: 12px 0 0; color: var(--danger); }
.admin-muted { color: var(--muted); font-size: 13.500px; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 0; }
.admin-stats div { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.admin-stats dt { color: var(--muted); font-size: 13.500px; }
.admin-stats dd { margin: 4px 0 0; font-size: 26px; font-weight: 600; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.admin-actions input {
  flex: 1; min-width: 160px; font: inherit; color: inherit; background: var(--field);
  border: 1px solid var(--field-line); border-radius: 10px; padding: 8px 12px; outline: none;
}
.admin-actions input:focus { border-color: var(--accent); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
.admin-table th { color: var(--muted); font-weight: 600; }
.admin-row-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.text-btn.danger { color: var(--danger); }
.admin-pager { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--muted); font-size: 13.500px; }
.admin-pager .text-btn:disabled { opacity: .5; cursor: default; }
.admin-code { margin: 16px 0 0; border: 1px solid var(--accent); border-radius: 12px; padding: 12px 16px; }
.admin-code h2 { font-size: 16px; margin: 0 0 4px; }
.admin-code p { margin: 4px 0; }
.admin-code-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.admin-code-row code { font-size: 16px; padding: 6px 10px; background: var(--code-bg); border-radius: 8px; overflow-wrap: anywhere; user-select: all; }
@media (max-width: 640px) {
  .admin-table thead { display: none; }
  .admin-table tr { display: block; border-bottom: 1px solid var(--line); padding: 6px 0; }
  .admin-table td { display: block; border: 0; padding: 2px 0; }
}
