/* Test client. Visual language of the first LUNDO Mac client: green accent,
   268px sidebar, soft rounded bubbles, centered 760px conversation. */
:root {
  --accent: #296357;
  --accent-10: rgba(41, 99, 87, .10);
  --accent-12: rgba(41, 99, 87, .12);
  --accent-13: rgba(41, 99, 87, .13);
  --bg: #ececec;
  --canvas: #ffffff;
  --bubble: #f2f2f2;
  --text: #1d1d1f;
  --muted: rgba(29, 29, 31, .72);
  --line: rgba(0, 0, 0, .10);
  --error: #b3261e;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #4f9a89;
    --accent-10: rgba(79, 154, 137, .16);
    --accent-12: rgba(79, 154, 137, .22);
    --accent-13: rgba(79, 154, 137, .24);
    --bg: #262626;
    --canvas: #1e1e1e;
    --bubble: #2c2c2e;
    --text: #f2f2f2;
    --muted: rgba(242, 242, 242, .68);
    --line: rgba(255, 255, 255, .12);
    --error: #ff8a80;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* login */
.screen { height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px;
  background: var(--canvas); padding: 28px; border-radius: 16px; border: 1px solid var(--line); }
.login-card h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
input, textarea, select { background: var(--canvas); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
textarea { resize: vertical; }
.primary { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 500; }
.error { color: var(--error); margin: 0; font-size: 13px; }

/* layout */
.app { display: flex; height: 100%; }
.sidebar { width: 268px; flex: none; display: flex; flex-direction: column; background: var(--bg);
  border-right: 1px solid var(--line); }
.brand { font-size: 20px; font-weight: 600; padding: 20px 18px 18px; }
.new-chat { margin: 0 12px; text-align: left; border: 0; border-radius: 10px; padding: 9px 12px;
  background: var(--accent-10); font-weight: 500; }
.icon { display: inline-flex; width: 16px; margin-right: 10px; justify-content: center; flex: none; }
.svg-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
  stroke-linejoin: round; vertical-align: middle; }
.send .svg-icon { width: 16px; height: 16px; stroke-width: 2.6; }
.send.stop .svg-icon { width: 12px; height: 12px; fill: currentColor; }
.send { display: inline-flex; align-items: center; justify-content: center; }
.icon-button { display: inline-flex; align-items: center; }
#project-settings { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.row { display: flex; align-items: center; width: 100%; text-align: left; border: 0; background: transparent;
  border-radius: 9px; padding: 9px 12px; }
.row .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.selected { background: var(--accent-13); }
.row:hover:not(.selected) { background: var(--accent-10); }
#all-chats { margin: 12px 12px 0; width: calc(100% - 24px); }
.scroll { flex: 1; overflow-y: auto; padding: 0 12px 16px; }
.section-head { display: flex; justify-content: space-between; align-items: center; padding: 22px 12px 5px;
  font-size: 12px; font-weight: 600; color: var(--muted); }
.icon-button { border: 0; background: transparent; font-size: 16px; padding: 2px 6px; border-radius: 6px; }
.icon-button:hover { background: var(--accent-10); }
.empty { color: var(--muted); padding: 8px 12px; }
.account { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border-top: 1px solid var(--line); padding: 12px 18px; font-weight: 500; }
.link { border: 0; background: transparent; color: var(--accent); padding: 0; }

.canvas { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--canvas); }
.chat-header { display: flex; align-items: center; gap: 12px; padding: 18px 30px; border-bottom: 1px solid var(--line); }
.chat-header h2 { flex: 1; min-width: 0; margin: 0; font-size: 18px; font-weight: 600; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; cursor: text; }
.picker { position: relative; flex: none; }
.model-button { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--canvas);
  border-radius: 10px; padding: 7px 12px; font-weight: 500; max-width: 46vw; }
.model-button:hover { background: var(--accent-10); }
.model-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-effort { font-size: 12px; font-weight: 500; color: var(--accent); background: var(--accent-10); border-radius: 6px;
  padding: 1px 6px; white-space: nowrap; }
.model-caret { font-size: 11px; color: var(--muted); }
.model-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 290px; max-height: 70vh; overflow-y: auto;
  background: var(--canvas); border: 1px solid var(--line); border-radius: 14px; padding: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .14); }
.menu-group { font-size: 11px; font-weight: 600; color: var(--muted); padding: 10px 10px 4px; letter-spacing: .02em; }
.menu-item { display: flex; justify-content: space-between; width: 100%; border: 0; background: transparent;
  border-radius: 8px; padding: 8px 10px; text-align: left; }
.menu-item:hover, .menu-item.selected { background: var(--accent-10); }
.menu-check { color: var(--accent); font-weight: 700; }
.effort-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 10px 6px; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.menu-hint { font-size: 11px; color: var(--muted); padding: 2px 10px 6px; }
.menu-button { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 22px 28px; }
.messages > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.msg { display: flex; margin-bottom: 18px; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: min(620px, 92%); padding: 11px 16px; border-radius: 16px; font-size: 15px;
  white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bubble); }
.msg.user .bubble { background: var(--accent-12); }
.bubble pre { white-space: pre; overflow-x: auto; background: rgba(127, 127, 127, .12); border-radius: 8px;
  padding: 10px 12px; margin: 8px 0; font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.bubble code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: rgba(127, 127, 127, .12);
  padding: 1px 4px; border-radius: 4px; }
.bubble pre code { background: none; padding: 0; }
.meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.msg.assistant .col { display: flex; flex-direction: column; max-width: min(620px, 92%); }
.msg.assistant .col .bubble { max-width: 100%; }
.typing::after { content: "▍"; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.placeholder { text-align: center; color: var(--muted); padding-top: 100px; }
.placeholder .big { font-size: 18px; font-weight: 500; color: var(--text); margin-bottom: 6px; }

.composer-wrap { padding: 8px 28px 20px; }
.composer-wrap > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.notice { font-size: 12px; color: var(--muted); padding: 0 12px 8px; margin-top: 0; margin-bottom: 0; }
.notice.bad { color: var(--error); }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 7px 13px; border-radius: 18px;
  border: 1px solid var(--line); background: var(--canvas); }
.composer textarea { flex: 1; border: 0; padding: 8px 0; resize: none; max-height: 40vh; outline: none;
  font-size: 15px; background: transparent; }
.send { width: 30px; height: 30px; flex: none; border: 0; border-radius: 50%; background: var(--accent);
  color: #fff; font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.send:disabled { background: rgba(127, 127, 127, .45); cursor: default; }
.send.stop { font-size: 11px; }

dialog { border: 0; border-radius: 16px; padding: 0; background: var(--canvas); color: var(--text);
  width: min(520px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
.dialog-card { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.dialog-card h3 { margin: 0; font-size: 20px; font-weight: 600; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 10px; }
.dialog-buttons button:not(.primary) { border: 1px solid var(--line); background: transparent; border-radius: 10px; padding: 9px 14px; }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 5; }
@media (max-width: 800px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 6; transform: translateX(-100%); transition: transform .2s; }
  .app.menu-open .sidebar { transform: none; }
  .menu-button { display: inline-flex; }
  .wide-only { display: none; }
  .chat-header h2 { font-size: 16px; }
  .chat-header { padding: 12px 16px; gap: 8px; }
  .model-button { max-width: 52vw; padding: 6px 9px; }
  .model-menu { width: min(290px, 86vw); }
  .messages { padding: 16px; }
  .composer-wrap { padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); }
}

/* failed / stopped reply */
.retry-card { background: transparent; border: 1px solid var(--line); display: flex; flex-direction: column;
  gap: 4px; align-items: flex-start; }
.retry-title { font-weight: 500; }
.retry-reason { font-size: 13px; color: var(--muted); }
.retry-button { margin-top: 6px; border: 1px solid var(--line); background: var(--canvas); border-radius: 9px;
  padding: 5px 12px; font-size: 13px; }
.retry-button:hover:not(:disabled) { background: var(--accent-10); }
.retry-button:disabled { opacity: .5; cursor: default; }

/* search and memory sources */
.search { margin: 12px 12px 0; width: calc(100% - 24px); font-size: 13px; }
.search-hit .label { display: flex; flex-direction: column; gap: 2px; white-space: normal; }
.hit-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hit-snippet { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.memory-toggle { font-size: 12px; }
.memory-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.memory-item { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; text-align: left; border: 1px solid var(--line);
  background: transparent; border-radius: 10px; padding: 8px 10px; font-size: 12px; }
.memory-item:hover { background: var(--accent-10); }
.memory-n { grid-row: span 2; font-weight: 600; color: var(--accent); }
.memory-where { color: var(--muted); }
.memory-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* sidebar: expandable projects, unread dots, chat actions */
.project-row { cursor: pointer; padding-left: 4px; }
.caret { border: 0; background: transparent; width: 18px; height: 18px; flex: none; display: inline-flex;
  align-items: center; justify-content: center; color: var(--muted); font-size: 15px; transition: transform .15s;
  margin-right: 2px; border-radius: 4px; }
.caret:hover { background: var(--accent-10); }
.caret.open { transform: rotate(90deg); }
.row.nested { padding-left: 34px; }
.empty.nested { padding-left: 46px; font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #2f7cf6; flex: none; margin-left: auto; }
.row .label { flex: 1; min-width: 0; }
.actions-menu { width: 240px; }
.menu-item:disabled { cursor: default; opacity: .7; }
#chat-actions .svg-icon { stroke-width: 3.2; }

/* chronicle */
.recorded-line { margin-top: 6px; text-align: left; border: 0; background: var(--accent-10); color: var(--text);
  border-radius: 8px; padding: 5px 9px; font-size: 12px; }
.recorded-mark { color: var(--accent); font-weight: 600; }
.chronicle-dialog { width: min(640px, calc(100% - 32px)); }
.chronicle-head { display: flex; justify-content: space-between; align-items: center; }
.chronicle-hint { margin: 0; font-size: 13px; color: var(--muted); }
.chronicle-list { display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow-y: auto; }
.ch-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.ch-row { display: flex; justify-content: space-between; gap: 12px; }
.ch-key { font-weight: 500; }
.ch-value { font-weight: 600; color: var(--accent); text-align: right; }
.ch-meta { font-size: 12px; color: var(--muted); }
.ch-actions { display: flex; gap: 14px; margin-top: 4px; font-size: 12px; }
.ch-history { margin-top: 6px; border-top: 1px dashed var(--line); padding-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.ch-old { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.danger { color: var(--error); }
.chronicle-add { display: grid; grid-template-columns: 2fr 1.4fr .8fr 1.2fr auto; gap: 6px; }
@media (max-width: 800px) { .chronicle-add { grid-template-columns: 1fr 1fr; } }
.chronicle-add input { min-width: 0; }
.chronicle-dialog .dialog-card { overflow: hidden; }
