/* aios web UI */

/* Design: pure Cursor (cursor.com), chosen by the user on 2026-10-14.
   Colours are Cursor's own theme values (--color-theme-*): warm off-white #f7f7f4, ink #26251e,
   cards stepping darker, borders/text as ink at 2.5–60% alpha, accent orange #f54e00 used sparingly.
   Type (user's choice): IBM Plex Serif 22px for the conversation; the UI is a smaller sans (Inter);
   mono for tool steps. Corners stay sharp (3px) per the user's standing preference. */

:root {
  --fg: #26251e;
  --bg: #f7f7f4;
  --bg-subtle: #f2f1ed;       /* card */
  --bg-sidebar: #f2f1ed;
  --bg-hover: color-mix(in oklab, var(--fg) 5%, transparent);
  --bg-active: color-mix(in oklab, var(--fg) 8%, transparent);
  --bg-muted: #ebeae5;        /* card-02: user message */
  --border: color-mix(in oklab, var(--fg) 10%, transparent);
  --border-strong: color-mix(in oklab, var(--fg) 20%, transparent);
  --text: var(--fg);
  --text-2: color-mix(in oklab, var(--fg) 60%, var(--bg));
  --text-3: color-mix(in oklab, var(--fg) 40%, var(--bg));
  --accent: var(--fg);        /* primary buttons are ink, like Cursor's */
  --accent-hover: #3b3a33;
  --accent-text: #f7f7f4;
  --brand: #f54e00;           /* Cursor orange: spinners, selection, small highlights only */
  --link: var(--fg);
  --accent-soft: color-mix(in oklab, #f54e00 14%, transparent);
  --danger: #cf2d56;
  --danger-soft: color-mix(in oklab, #cf2d56 8%, var(--bg));
  --danger-border: color-mix(in oklab, #cf2d56 30%, var(--bg));
  --success: #1f8a65;
  --code-bg: #f2f1ed;
  --shadow-sm: 0 1px 2px color-mix(in oklab, var(--fg) 6%, transparent);
  --shadow-md: 0 0 0 1px color-mix(in oklab, var(--fg) 4%, transparent), 0 6px 24px color-mix(in oklab, var(--fg) 7%, transparent);
  --shadow-lg: 0 16px 48px color-mix(in oklab, var(--fg) 18%, transparent);
  --focus: 0 0 0 3px color-mix(in oklab, var(--fg) 12%, transparent);

  --font: "Inter", system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --radius: 3px;
  --radius-sm: 2px;
  --content: 720px;
  --topbar-h: calc(44px + env(safe-area-inset-top, 0px));
  --logo: #d4480b;            /* the bot logo: a deep orange on light… */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  color-scheme: light;
}

/* Dark is a soft charcoal, never true black: the darkest surface is #333 (the user's preference).
   Theme: automatic (follows the device) unless the user picked Light or Dark in the menu;
   the choice lives in the aios_theme cookie and the server puts data-theme on <html>. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fg: #e6e4e0;
    --logo: #ff9152;          /* …a bright, happy orange on dark */
    --bg: #333333;
    --bg-subtle: #3a3a3a;
    --bg-sidebar: #383838;
    --bg-muted: #444444;      /* card-03: your messages */
    --accent-hover: #d3d1cd;
    --accent-text: #333333;
    --code-bg: #3d3d3d;
    --danger: #f06c8a;
    --success: #4cc38a;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.25);
    --shadow-md: 0 0 0 1px color-mix(in oklab, var(--fg) 8%, transparent), 0 8px 28px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 16px 48px rgb(0 0 0 / 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fg: #e6e4e0;
  --logo: #ff9152;
  --bg: #333333;
  --bg-subtle: #3a3a3a;
  --bg-sidebar: #383838;
  --bg-muted: #444444;      /* card-03: your messages */
  --accent-hover: #d3d1cd;
  --accent-text: #333333;
  --code-bg: #3d3d3d;
  --danger: #f06c8a;
  --success: #4cc38a;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.25);
  --shadow-md: 0 0 0 1px color-mix(in oklab, var(--fg) 8%, transparent), 0 8px 28px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 16px 48px rgb(0 0 0 / 0.4);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 400 13px/18px var(--font);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

[hidden] { display: none !important; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:disabled { cursor: default; opacity: 0.4; }
:focus-visible { outline: none; box-shadow: var(--focus); }

::selection { background: var(--accent-soft); }
.dots i { background: var(--brand) !important; }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border: 3px solid transparent; background-clip: padding-box; border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: -0.01em;
}

/* Buttons */
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: inline-grid;
  place-items: center;
  color: var(--text-2);
  flex-shrink: 0;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.icon-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.icon-btn:active:not(:disabled) { background: var(--bg-active); }
/* Send / stop: quiet, blending with the composer (the user found solid ink buttons too loud). */
.icon-btn.filled { background: var(--bg-active); color: var(--text); }
.icon-btn.filled:hover:not(:disabled) { background: color-mix(in oklab, var(--fg) 14%, transparent); color: var(--text); }
.icon-btn.filled:disabled { background: transparent; color: var(--text-3); opacity: 1; }

.btn-filled, .btn-tonal, .btn-text {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 11px;
  transition: background 120ms var(--ease), border-color 120ms var(--ease);
}
.btn-filled { background: var(--accent); color: var(--accent-text); box-shadow: var(--shadow-sm); }
.btn-filled:hover:not(:disabled) { background: var(--accent-hover); }
.btn-tonal { background: var(--bg); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-tonal:hover { background: var(--bg-subtle); }
.btn-text { color: var(--text-2); }
.btn-text:hover { background: var(--bg-hover); color: var(--text); }
.btn-filled.danger { background: var(--danger); }

/* --- login ---------------------------------------------------------------- */

.login-body {
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg-sidebar);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px 32px 32px;
}
.login-card h1 { margin: 0; display: flex; justify-content: center; font-size: 20px; font-weight: 600; }
.tagline { margin: 4px 0 28px; text-align: center; color: var(--text-3); font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card .btn-filled { margin-top: 6px; height: 36px; font-size: 14px; }
.login-error {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.field input:hover { border-color: var(--text-3); }
.field input:focus { border-color: var(--text-3); }
.field input:focus-visible { box-shadow: var(--shadow-sm); }

/* --- chat layout ---------------------------------------------------------- */

.chat-body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

.main {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-2);
  font-size: 12.5px;
}
.banner .icon { width: 14px; height: 14px; }
.banner.flash { color: var(--text); cursor: pointer; text-align: center; }

/* --- top bar ---------------------------------------------------------------
   The same on every page (the user's design, 2026-10-15): the agent menu (bot logo), the apps
   (conversations, Files, Terminal…), then on the right the current app's own buttons and the bell.
   On a phone the apps fold into the logo's menu. Full-window quick looks (PDF, photo…) cover it. */

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--topbar-h);
  padding: env(safe-area-inset-top, 0px) 8px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
/* On scaled screens (Windows 150 %, phones) 1px draws as 2+ device pixels; keep it one device pixel. */
@media (min-resolution: 1.5dppx) { .topbar { border-bottom-width: 0.5px; } }
@media (min-resolution: 3dppx) { .topbar { border-bottom-width: 0.34px; } }
.topbar-logo, .topbar-app {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  color: var(--text-3);
  transition: background 100ms var(--ease), color 100ms var(--ease);
}
.topbar-logo { color: var(--logo); margin-right: 6px; }
.topbar-logo .icon { width: 22px; height: 22px; }
.topbar-app .icon { width: 18px; height: 18px; }
.topbar-logo:hover, .topbar-logo[aria-expanded="true"] { background: var(--bg-hover); }
.topbar-app:hover, .topbar-app[aria-expanded="true"] { background: var(--bg-hover); color: var(--text); }
.topbar-app.current { color: var(--text); background: var(--bg-active); }
.topbar-apps { display: flex; gap: 2px; }
/* The conversation's name, centred on the screen (not between its neighbours), in the conversation's
   serif at its size (16px), in the logo's colour so it stands out (the user's choice). */
.topbar-title {
  position: absolute;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 22px);
  transform: translate(-50%, -50%);
  max-width: calc(100% - 360px);
  margin: 0;
  font: 500 16px/22px var(--serif);
  color: var(--logo);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
@media (max-width: 640px) { .topbar-title { max-width: calc(100% - 120px); } }
.topbar-tools { margin-left: auto; }
/* The current app's own buttons (moved here from its view by core.js), before the bell. */
.topbar-tools { display: flex; align-items: center; gap: 2px; }
.topbar-tools .viewer-tools { display: flex; align-items: center; gap: 2px; }
.topbar .viewer-btn { color: var(--text-3); opacity: 1; }
.topbar .viewer-btn:hover { background: var(--bg-hover); color: var(--text); }
.topbar .viewer-btn.active { background: var(--bg-active); color: var(--text); }
.topbar .viewer-btn[disabled] { opacity: 0.3; pointer-events: none; }
.topbar .viewer-btn .icon { width: 16px; height: 16px; }
.topbar-tools .viewer-btn[data-icon="close"] { display: none; }  /* an app page isn't closed */
.topbar .bell { width: 34px; height: 34px; margin-left: 2px; }

/* Menus dropping from the top bar: the agent menu and the conversation list. */
.menu-panel {
  position: fixed;
  top: calc(var(--topbar-h) + 4px);
  z-index: 1000;  /* above full-window app views (200+) */
  max-height: calc(100dvh - var(--topbar-h) - 16px);
  overflow-y: auto;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.sys-menu { left: 8px; width: 240px; }
.conv-menu { left: 48px; width: min(432px, calc(100vw - 56px)); display: flex; flex-direction: column; }
.conv-menu[hidden], .menu-panel[hidden] { display: none; }
.menu-label {
  padding: 8px 8px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.menu-apps { display: none; border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: 6px; }
@media (max-width: 640px) {
  .topbar-apps { display: none; }
  .menu-apps { display: block; }
  .sys-menu, .conv-menu { left: 8px; right: 8px; width: auto; }
}

.drawer-list { list-style: none; margin: 0 -8px; padding: 0 8px; overflow-y: auto; flex: 1; }
.drawer-list li + li { margin-top: 1px; }
.drawer-list li.muted { padding: 6px 8px; color: var(--text-3); font-size: 11px; }
.conv-menu .drawer-list { margin: 0; padding: 0; }

.history-item, .nav-item {
  width: 100%;
  border-radius: var(--radius);
  padding: 6px 8px;
  text-align: left;
  color: var(--text-2);
  transition: background 100ms var(--ease), color 100ms var(--ease);
}
.history-item:hover, .nav-item:hover { background: var(--bg-hover); color: var(--text); }
.history-item { display: flex; align-items: baseline; gap: 8px; }
a.history-item, a.nav-item, a.icon-btn { text-decoration: none; box-sizing: border-box; }
.history-item.current { background: var(--bg-active); color: var(--text); }
.history-item.current .history-title { font-weight: 500; }
.history-title {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-size { font-size: 10px; color: var(--text-3); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.history-date { font-size: 10px; color: var(--text-3); flex-shrink: 0; font-variant-numeric: tabular-nums; }
/* Delete: appears on hover on a PC, always there (quietly) on a phone */
#history-list li:not(.muted) { display: flex; align-items: center; gap: 2px; }
#history-list .history-item { flex: 1; min-width: 0; }
.history-delete { width: 24px; height: 24px; flex-shrink: 0; opacity: 0; color: var(--text-3); }
.history-delete:hover { color: var(--text); }
#history-list li:hover .history-delete, .history-delete:focus-visible { opacity: 1; }
@media (pointer: coarse) { .history-delete { opacity: 0.6; } }
.history-delete .icon { width: 13px; height: 13px; }

.nav-item { display: flex; align-items: center; gap: 10px; font-size: 11px; height: 30px; }
.nav-item .icon { width: 16px; height: 16px; }
.push-opt { color: var(--text-3); }
.push-opt.current { color: var(--text); font-weight: 600; }

/* Files and Terminal pages (Aios.appPage in core.js): the page's app fills the window under the top bar,
   no conversation behind it. Its own bar is hidden: its buttons are in the top bar. */
.app-page .main { display: none; }
.app-page .topbar-title { visibility: hidden; }  /* the highlighted app icon says where you are */
.viewer.app-layer { top: var(--topbar-h); }
.app-layer > .viewer-bar { display: none; }


/* --- messages ----------------------------------------------------------- */

.log {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overscroll-behavior: contain;
}
.log > * { max-width: var(--content); width: 100%; margin-inline: auto; }
.log { container-type: inline-size; }
.log > .earlier {
  align-self: center; width: auto; margin-bottom: 4px; padding: 6px 14px;
  font-size: 12px; color: var(--text-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.log > .earlier:hover { background: var(--bg-hover); color: var(--text); }

.empty {
  margin: auto !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 13px;
}
.empty .brand { font-size: 22px; font-weight: 600; color: var(--text); }
/* The top-left bot logo, four times its size, in the same orange (the user's choice). */
.empty .empty-logo { width: 88px; height: 88px; color: var(--logo); }
.msg { overflow-wrap: anywhere; font-size: 15px; line-height: 1.65; }
/* The user's rule: serif for the conversation (soft, homely), sans/mono for technical parts. */
.msg.assistant, .msg.user { font-family: var(--serif); font-size: 16px; line-height: 1.6; }
.msg.assistant table, .msg.error, .msg-files, .file-link { font-family: var(--font); }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3 { line-height: 1.25; }
.msg.user {
  width: fit-content;
  max-width: min(80%, 560px);
  margin-right: max(0px, calc((100% - var(--content)) / 2));
  margin-left: auto;
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-muted);
  color: var(--text);
  white-space: pre-wrap;
}
.msg.assistant { padding: 0 2px; color: var(--text); }
.msg.assistant.streaming { white-space: pre-wrap; }
.msg.assistant > :first-child { margin-top: 0; }
.msg.assistant > :last-child { margin-bottom: 0; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  margin: 1.4em 0 0.5em;
}
.msg.assistant h1 { font-size: 22px; font-weight: 600; }
.msg.assistant h2 { font-size: 19px; font-weight: 600; }
.msg.assistant h3 { font-size: 16px; font-weight: 600; }
.msg.assistant p, .msg.assistant ul, .msg.assistant ol { margin: 0.65em 0; }
.msg.assistant ul, .msg.assistant ol { padding-left: 1.4em; }
.msg.assistant li + li { margin-top: 0.25em; }
.msg.assistant li::marker { color: var(--text-3); }
.msg.assistant strong { font-weight: 600; }
.msg.assistant blockquote {
  margin: 0.9em 0;
  padding: 2px 14px;
  border-left: 2px solid var(--border-strong);
  color: var(--text-2);
}
.msg.error {
  padding: 8px 12px;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.5;
}

.msg pre, .tool-output, .permission pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  overflow-x: auto;
  font: 12.5px/1.6 var(--mono);
  white-space: pre;
}
.code-block { position: relative; }
.code-block pre { padding-right: 44px; }
.copy-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  background: var(--code-bg);
}
.copy-btn:hover { color: var(--text); background: var(--border); }
.copy-btn.done { color: var(--text); }
.copy-btn .icon { width: 15px; height: 15px; }
.msg code { font-family: var(--mono); font-size: 0.86em; }
.msg :not(pre) > code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 0.05em 0.35em;
  border-radius: var(--radius-sm);
}
.msg table {
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  margin: 0.9em 0;
  font-size: 13.5px;
  line-height: 1.5;
}
.msg th, .msg td { padding: 7px 14px 7px 0; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.msg th { font-weight: 600; color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; border-bottom-color: var(--border-strong); }
.msg a { color: var(--link); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.msg a:hover { text-decoration-color: currentColor; }
.msg.user a { color: inherit; }
.msg hr { border: 0; border-top: 1px solid var(--border); margin: 1.2em 0; }

/* --- tool activity --------------------------------------------------------- */

.tool { font-size: 12.5px; line-height: 18px; color: var(--text-3); }
.tool-group { font-size: 12px; color: var(--text-3); margin-block: -6px; }
.tool-group > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  margin-left: -6px;
  border-radius: var(--radius);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 100ms var(--ease), color 100ms var(--ease);
}
.tool-group > summary::-webkit-details-marker { display: none; }
.tool-group > summary:hover { background: var(--bg-hover); color: var(--text-2); }
.tool-group > summary .icon { width: 13px; height: 13px; }
.tool-group > summary .spin { color: var(--brand); }
.tool-group > summary .chevron { opacity: 0.6; transition: transform 150ms var(--ease); }
.tool-group[open] > summary .chevron { transform: rotate(180deg); }
.tool-group-body { padding: 4px 0 2px 8px; margin-left: 0; border-left: 1px solid var(--border); }
.tool-group-body .tool summary { margin-left: 0; }
.tool.sub { padding-left: 20px; }
.tool summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  list-style: none;
  padding: 3px 6px;
  margin-left: -6px;
  border-radius: var(--radius);
  width: fit-content;
  max-width: calc(100% + 6px);
  transition: background 100ms var(--ease);
}
.tool summary:hover { background: var(--bg-hover); color: var(--text-2); }
.tool summary::-webkit-details-marker { display: none; }
.tool .icon { width: 14px; height: 14px; }
.tool .state-running { color: var(--brand); }
.tool .state-done { color: var(--text-3); }
.tool .state-failed { color: var(--danger); }
.tool-name { font-weight: 500; color: var(--text-2); flex-shrink: 0; }
.tool-summary {
  font: 12px/18px var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.tool-output { margin: 6px 0 8px; max-height: 320px; overflow: auto; color: var(--text-2); }

/* --- permission requests (unused while prompts are off) ------------------- */

.permission {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 14px 16px;
}
.perm-title { font-weight: 600; }
.perm-desc { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.permission details { margin: 10px 0; font-size: 13px; }
.permission summary { cursor: pointer; color: var(--accent); }
.permission pre { max-height: 260px; overflow: auto; margin: 8px 0 0; }
.perm-actions { display: flex; gap: 8px; justify-content: flex-end; }
.perm-note { font-size: 12.5px; color: var(--text-3); }

/* --- composer -------------------------------------------------------------- */

.composer-wrap {
  flex-shrink: 0;
  padding: 0 24px calc(20px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, transparent, var(--bg) 14px);
}
.composer-wrap > * { max-width: var(--content); margin-inline: auto; }

.working {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 2px 10px;
  font-size: 12.5px;
  color: var(--text-3);
}
.dots { display: inline-flex; gap: 3px; }
.dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-3);
  animation: pulse 1.2s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

.composer {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 8px;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.composer:focus-within { border-color: var(--text-3); }
.composer textarea:focus-visible { box-shadow: none; }
.composer textarea {
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: 16px/1.5 var(--serif);
  padding: 6px 8px 10px;
  max-height: 240px;
  width: 100%;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer-actions { display: flex; align-items: center; gap: 2px; }
.composer-actions .icon-btn { width: 30px; height: 30px; }
.composer-actions .icon-btn:not(.filled):not(.recording) { color: var(--text-3); }
.spacer { flex: 1; }

.mic.recording {
  width: auto !important;
  padding: 0 10px 0 8px;
  gap: 6px;
  display: inline-flex;
  background: var(--danger) !important;
  color: #fff !important;
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.mic.recording .icon { width: 14px; height: 14px; }
.mic.busy .icon { animation: spin 0.9s linear infinite; }

/* --- attachments ------------------------------------------------------------ */

.attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 4px 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  max-width: 100%;
  padding: 0 4px 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  font-size: 12.5px;
  color: var(--text-2);
}
.chip .icon { width: 16px; height: 16px; color: var(--text-3); }
.chip.uploading { opacity: 0.6; }
.chip.failed { border-color: var(--danger-border); color: var(--danger); background: var(--danger-soft); }
.chip-thumb { width: 24px; height: 24px; object-fit: cover; border-radius: var(--radius-sm); }
.chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-remove { width: 24px; height: 24px; border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--text-3); }
.chip-remove:hover { background: var(--bg-hover); color: var(--text); }
.chip-remove .icon { width: 14px; height: 14px; }

.msg-files { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.msg-files:last-child { margin-bottom: 2px; }
.file-image img { display: block; max-width: 100%; max-height: 280px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.file-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-2);
  text-decoration: none;
  font-size: 12.5px;
}
.file-link:hover { border-color: var(--border-strong); color: var(--text); }
.file-link .icon { width: 15px; height: 15px; color: var(--text-3); }

body.dragging .composer { border-color: var(--accent); border-style: dashed; }

/* --- phones ------------------------------------------------------------------ */

@media (max-width: 600px) {
  .log { padding: 8px 14px 24px; }
  .composer-wrap { padding: 0 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
  /* Not typing: lift the box clear of the phone's gesture bar; it drops back while the keyboard is up. */
  .composer-wrap:not(:has(#input:focus)) { padding-bottom: calc(26px + env(safe-area-inset-bottom, 0px)); }
  .msg { font-size: 15px; }
  .msg.user { max-width: 88%; }
  .icon-btn { width: 36px; height: 36px; }
  .composer-actions .icon-btn { width: 34px; height: 34px; }
}

/* Images in replies (e.g. screenshots I show the user) */
.msg.assistant img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 200px);
  width: auto;
  height: auto;
  cursor: zoom-in;
  margin: 10px 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* --- notifications --------------------------------------------------------- */

.topbar .bell { position: relative; opacity: 0.35; }
.topbar .bell:hover, .topbar .bell[aria-expanded="true"] { opacity: 1; }
.topbar .bell.unread { color: var(--text); opacity: 1; }
.topbar .bell.unread::after {
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--bg);
}

.notif-panel {
  position: fixed;
  top: calc(var(--topbar-h) + 4px);
  right: 8px;
  z-index: 1000;
  width: min(360px, calc(100% - 20px));
  max-height: min(480px, 70vh);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}
.text-btn {
  padding: 3px 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-3);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.text-btn:hover { background: var(--bg-hover); color: var(--text); }
.notif-list { list-style: none; margin: 0; padding: 4px; overflow-y: auto; }
.notif-list:empty::before { content: "No notifications"; display: block; padding: 12px; font-size: 13px; color: var(--text-3); }
.notif-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 8px 32px 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
}
button.notif-item { cursor: pointer; }
button.notif-item:hover { background: var(--bg-hover); }
.notif-item.fresh .notif-title::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 6px 1px 0;
  border-radius: 50%;
  background: var(--brand);
}
.notif-title { display: block; font-size: 13px; font-weight: 500; }
.notif-body { display: block; margin-top: 2px; font-size: 12.5px; color: var(--text-2); white-space: pre-line; }
.notif-time { display: block; margin-top: 4px; font-size: 11px; color: var(--text-3); }
.notif-row { position: relative; }
.notif-row .notif-dismiss {
  position: absolute;
  top: 6px;
  right: 4px;
  width: 24px;
  height: 24px;
  opacity: 0;
}
.notif-row:hover .notif-dismiss, .notif-dismiss:focus-visible { opacity: 1; }
@media (pointer: coarse) { .notif-row .notif-dismiss { opacity: 0.6; } }
.notif-dismiss .icon { width: 14px; height: 14px; }
.notif-item.focused { background: var(--bg-active); }

/* Camera button: phones and tablets only; on a PC the paperclip covers it. */
.camera-btn { display: none; }
@media (pointer: coarse) { .camera-btn { display: inline-grid; } }

/* Big images and tables break out of the text column on a PC (see widen() in app.js). */
@media (min-width: 1000px) {
  .msg.assistant img.wide, .msg table.wide {
    max-width: 90cqw;
    margin-left: 50%;
    transform: translateX(-50%);
  }
  .msg table.wide { width: max-content; }
}

.file-image img { cursor: zoom-in; }

/* Full-screen image viewer */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 2vh 2vw;
  background: rgba(20, 18, 11, 0.88);
  cursor: zoom-out;
}
.lightbox img {
  max-width: 96vw;
  max-height: 96dvh;
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: zoom-in;
}
.lightbox.actual { place-items: start; }
.lightbox.actual img { max-width: none; max-height: none; cursor: zoom-out; }

/* ---- Viewers (viewers.js): full-window views of library files ---- */
a.view-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  font-family: var(--font);
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}
a.view-link:hover { background: var(--bg-active); }
/* An album link: a full-width box; the link (title, photo count) on top, a strip of thumbnail links under it. */
.album-box {
  margin: 6px 0;
  padding: 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-subtle);
}
a.view-link.album-link {
  display: grid;
  gap: 2px;
  width: 100%;
  box-sizing: border-box;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
a.view-link.album-link:hover { background: transparent; }
a.view-link.album-link:hover .album-link-title { text-decoration: underline; }
.album-link-title { font-weight: 500; }
.album-link-count { color: var(--text-3); font-size: 12px; }
/* Up to 20 thumbnails in two rows of 10 (phone: two rows of 5), filling the width. */
.album-link-strip { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-top: 12px; }
.album-link-strip:empty { display: none; }
a.album-thumb { position: relative; display: block; aspect-ratio: 1; cursor: pointer; min-width: 0; }
.msg a.album-thumb img {
  width: 100%; height: 100%; max-height: none; object-fit: cover; display: block;
  margin: 0; border: 0; border-radius: 0; cursor: pointer; background: var(--bg-active);
}
a.album-thumb:hover img { opacity: 0.8; }
a.album-more span {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgb(0 0 0 / 0.55); color: #fff; font-family: var(--font); font-size: 14px; font-weight: 500;
}
@media (max-width: 600px) {
  .album-link-strip { grid-template-columns: repeat(5, 1fr); }
  a.album-thumb:nth-child(n+11) { display: none; }
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #0d0c09;
  color: #edecec;
  font-family: var(--font);
  outline: none;
}
.viewer-pdf { background: #2a2923; }
.viewer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  background: rgb(13 12 9 / 0.75);
  z-index: 2;
}
.viewer-image .viewer-bar { position: absolute; inset: 0 0 auto 0; background: linear-gradient(rgb(0 0 0 / 0.55), transparent); }
.viewer-title { flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.85; }
.viewer-tools { display: flex; gap: 2px; }
.viewer-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  color: #edecec;
  background: transparent;
  opacity: 0.8;
}
.viewer-btn:hover { background: rgb(255 255 255 / 0.12); opacity: 1; }
.viewer-btn.active { background: rgb(255 255 255 / 0.16); opacity: 1; }
.viewer-btn .icon { width: 18px; height: 18px; }
.viewer-body { position: relative; min-height: 0; grid-row: 1 / -1; grid-column: 1; display: grid; }
.viewer-pdf .viewer-body, .viewer-error .viewer-body { grid-row: 2; }

/* image */
.viewer-image .viewer-body { place-items: center; }
.viewer-image .viewer-image { max-width: 100vw; max-height: 100dvh; object-fit: contain; display: block; }
.viewer-prev, .viewer-next { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; }
.viewer-prev { left: 8px; }
.viewer-next { right: 8px; }

/* pdf: every page fits the screen whole; "fit width" for reading small print */
.viewer-pdf .viewer-body { grid-template-columns: 1fr; }
.viewer-pdf.with-translation .viewer-body { grid-template-columns: 1fr 1fr; }
.viewer-pages { overflow: auto; min-height: 0; padding: 12px 0; scroll-snap-type: y proximity; }
.viewer-page { display: flex; justify-content: center; padding: 0 12px 12px; scroll-snap-align: start; }
.viewer-page img { display: block; background: #fff; box-shadow: 0 2px 12px rgb(0 0 0 / 0.4); }
.fit-page .viewer-page { height: calc(100dvh - 46px - 24px); box-sizing: border-box; }
.fit-page .viewer-page img { max-width: 100%; max-height: 100%; object-fit: contain; }
.fit-width .viewer-page img { width: 100%; height: auto; }
.viewer-translation { overflow: auto; min-height: 0; background: var(--bg); color: var(--text); border-left: 1px solid #000; }
.viewer-translation-head {
  position: sticky; top: 0;
  padding: 10px 24px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3); background: var(--bg); border-bottom: 1px solid var(--border);
}
.viewer-translation-text { padding: 16px 24px 48px; font-family: var(--serif); font-size: 16px; line-height: 1.6; white-space: pre-wrap; }
.viewer-pdf.with-translation.alt-translation .viewer-body { grid-template-columns: 1fr; }
.viewer-pdf.with-translation.alt-translation .viewer-translation { display: none; }
@media (max-width: 800px) {
  .viewer-pdf.with-translation .viewer-body { grid-template-columns: 1fr; }
  .viewer-pdf.with-translation .viewer-translation { display: none; }
  .viewer-pdf.with-translation.alt-translation .viewer-translation { display: block; }
  .viewer-pdf.with-translation.alt-translation .viewer-pages { display: none; }
}

/* the ⓘ panel: everything the catalog knows about the file */
.viewer-info {
  position: absolute;
  top: 46px; right: 0; bottom: 0;
  width: min(380px, 100vw);
  overflow: auto;
  z-index: 3;
  padding: 18px 20px 32px;
  background: var(--bg);
  color: var(--text);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
}
.viewer-info[hidden] { display: none; }
.viewer-info h2 { font-family: var(--serif); font-size: 17px; font-weight: 600; margin: 0 0 8px; }
.viewer-info .viewer-desc { font-family: var(--serif); font-size: 15px; line-height: 1.5; margin: 0 0 14px; }
.viewer-info dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; }
.viewer-info dt { color: var(--text-3); font-size: 11px; padding-top: 2px; }
.viewer-info dd { margin: 0; overflow-wrap: anywhere; }

.viewer-menu-wrap { position: relative; }
.viewer-menu {
  position: absolute;
  top: 38px; right: 0;
  z-index: 5;
  min-width: 200px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.viewer-menu[hidden] { display: none; }
.viewer-menu-item {
  display: block; width: 100%;
  padding: 8px 10px;
  text-align: left; font-size: 13px; white-space: nowrap;
  color: var(--text); background: transparent; border-radius: var(--radius-sm);
}
.viewer-menu-item:hover { background: var(--bg-hover); }

/* history: background conversations */
.history-busy { width: 13px; height: 13px; flex-shrink: 0; align-self: center; color: var(--brand); }
.history-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; align-self: center; background: var(--fg); }
.history-dot.waiting { background: var(--brand); }

/* In-app question (Aios.ui.ask): small card over everything, ink primary button. */
dialog.ask {
  max-width: min(420px, calc(100vw - 32px));
  padding: 20px 20px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.25);
}
dialog.ask::backdrop { background: rgb(0 0 0 / 0.35); }
.ask-title { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.ask-message { margin: 0 0 18px; font-size: 14px; line-height: 1.5; color: var(--text-2); overflow-wrap: anywhere; }
.ask-buttons { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.ask-btn {
  height: 32px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: transparent; color: var(--text); font-family: var(--font); font-size: 13px; cursor: pointer;
}
.ask-btn:hover { background: var(--bg-active); }
.ask-btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.ask-btn.primary:hover { opacity: 0.88; background: var(--fg); }
