/* HyperLink on the web: the app's look, in one sheet. Colours are tokens. */
/* Dark, whatever the system says: HyperLink on the web is a dark app. */
:root {
  color-scheme: dark;
  --bg: #0e0e13;
  --panel: #17171f;
  --panel-2: #20202b;
  --text: #ececf3;
  --muted: #9a9aab;
  --line: #2b2b38;
  --accent: #8475ff;
  --accent-text: #ffffff;
  --bubble-them: #262633;
  --danger: #ff6b6b;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button {
  border: 0; border-radius: 10px; padding: 8px 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
}
button:disabled { opacity: .5; cursor: default; }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); padding: 9px 11px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); }

.app { display: grid; grid-template-columns: 300px 1fr; height: 100vh; height: 100dvh; }
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-right: 1px solid var(--line);
}
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 8px; }
.logo { width: 32px; height: 32px; }
.logo.big { width: 64px; height: 64px; }
.brand { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button {
  background: transparent; color: var(--text); padding: 6px 10px; font-size: 18px;
  border-radius: 8px;
}
.icon-button:hover { background: var(--panel-2); }
.icon-button.danger { color: var(--danger); }
.tabs { display: flex; gap: 4px; padding: 4px 10px 8px; }
.tab { flex: 1; background: transparent; color: var(--muted); padding: 6px 4px; font-size: 13px; }
.tab.active { background: var(--panel-2); color: var(--text); }
.search { margin: 0 10px 8px; width: auto; }
.sessions { list-style: none; margin: 0; padding: 0 6px; overflow-y: auto; flex: 1; }
.sessions li {
  padding: 9px 10px; border-radius: 10px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sessions li:hover { background: var(--panel-2); }
.sessions li.active { background: var(--accent); color: var(--accent-text); }
.sessions li small { display: block; opacity: .7; font-size: 12px; }
.sidebar-foot { padding: 10px 14px; border-top: 1px solid var(--line); }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.view { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow-y: auto; }
#view-runner, #view-memory, #view-settings { padding: 16px 24px 40px; max-width: 760px; width: 100%; }
.chat-head, .page-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.page-head { background: transparent; border: 0; padding: 0 0 8px; }
.chat-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.chat-title h1, .page-head h1 { font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title select { width: auto; max-width: 45%; padding: 4px 8px; font-size: 13px; }
.only-narrow { display: none; }

.thread { flex: 1; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; flex-direction: column; max-width: 78%; }
.row.me { align-self: flex-end; align-items: flex-end; }
.row.them { align-self: flex-start; align-items: flex-start; }
.bubble {
  position: relative; padding: 9px 14px; border-radius: var(--radius);
  white-space: normal; overflow-wrap: anywhere;
}
.row.me .bubble { background: var(--accent); color: var(--accent-text); }
.row.them .bubble { background: var(--bubble-them); }
/* The tail, on the last bubble of a run, as in the app. */
.row.tail.me .bubble { border-bottom-right-radius: 6px; }
.row.tail.them .bubble { border-bottom-left-radius: 6px; }
.row.tail.me .bubble::after, .row.tail.them .bubble::after {
  content: ""; position: absolute; bottom: 0; width: 12px; height: 14px;
}
.row.tail.me .bubble::after {
  right: -5px; background: var(--accent);
  clip-path: path("M0 0 C 0 8 4 12 12 14 C 6 14 2 12 0 10 Z");
}
.row.tail.them .bubble::after {
  left: -5px; background: var(--bubble-them);
  clip-path: path("M12 0 C 12 8 8 12 0 14 C 6 14 10 12 12 10 Z");
}
.meta { font-size: 11px; color: var(--muted); padding: 2px 6px 6px; }
.meta.error { color: var(--danger); font-size: 13px; max-width: 78%; }
.bubble p { margin: 0 0 .5em; } .bubble p:last-child { margin-bottom: 0; }
.bubble pre {
  background: rgba(0,0,0,.18); padding: 8px 10px; border-radius: 10px;
  overflow-x: auto; margin: .4em 0; white-space: pre;
}
.bubble a { color: inherit; }
/* Markdown (0.72.8a3): CommonMark, GFM and Markdown Extra. */
.bubble h1, .bubble h2, .bubble h3, .bubble h4, .bubble h5, .bubble h6 { margin: .6em 0 .3em; line-height: 1.25; }
.bubble h1 { font-size: 1.3em; } .bubble h2 { font-size: 1.18em; } .bubble h3 { font-size: 1.06em; }
.bubble h4, .bubble h5, .bubble h6 { font-size: 1em; }
.bubble ul, .bubble ol { margin: .3em 0 .5em; padding-left: 1.4em; }
.bubble li > ul, .bubble li > ol { margin: .15em 0; }
.bubble li.task { list-style: none; margin-left: -1.2em; }
.bubble li.task input { display: inline-block; width: auto; min-width: 0; height: auto; padding: 0; margin: 0 .35em 0 0; vertical-align: -1px; }
.bubble blockquote { margin: .4em 0; padding: .1em .8em; border-left: 3px solid var(--line); color: var(--muted); }
.bubble hr { border: 0; border-top: 1px solid var(--line); margin: .7em 0; }
.bubble .table-wrap { overflow-x: auto; margin: .4em 0; }
.bubble table { border-collapse: collapse; font-size: .95em; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 4px 8px; vertical-align: top; }
.bubble th { background: rgba(127,127,127,.12); font-weight: 600; }
.bubble dl { margin: .3em 0; } .bubble dt { font-weight: 600; } .bubble dd { margin: 0 0 .3em 1.2em; }
.bubble img { max-width: 100%; border-radius: 8px; }
.bubble kbd { font: .85em ui-monospace, SFMono-Regular, Menlo, monospace; padding: 1px 5px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; }
.bubble mark { background: rgba(255,214,0,.35); color: inherit; }
.bubble abbr[title] { text-decoration: underline dotted; cursor: help; }
.bubble :not(pre) > code { background: rgba(127,127,127,.16); padding: .05em .3em; border-radius: 4px; }
.bubble .footnotes { font-size: .9em; color: var(--muted); }
.bubble .footnotes ol { padding-left: 1.2em; } .bubble sup.fnref a { text-decoration: none; }
.chip {
  display: inline-block; font-size: 12px; padding: 2px 9px; margin: 2px 0;
  border-radius: 999px; background: var(--panel-2); color: var(--muted);
}
.chip.bad { color: var(--danger); }
.typing::after { content: "▍"; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.composer {
  display: flex; gap: 8px; align-items: flex-end; padding: 10px 16px 16px;
  border-top: 1px solid var(--line); background: var(--panel);
}
.composer textarea { resize: none; max-height: 200px; border-radius: 20px; padding: 10px 14px; }
.send { width: 40px; height: 40px; border-radius: 50%; padding: 0; font-size: 18px; flex: none; }
.send.stop { background: var(--danger); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 10px 0; }
.card h2 { font-size: 15px; margin: 0 0 6px; }
h2 { font-size: 15px; margin: 18px 0 8px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px;
}
.list li .grow { flex: 1; min-width: 0; }
.list li button { padding: 6px 10px; font-size: 13px; }
.list li button.secondary { background: var(--panel-2); color: var(--text); }
.inline-form { display: flex; gap: 8px; margin: 6px 0 14px; }
.inline-form button { flex: none; }
.settings { display: flex; flex-direction: column; gap: 12px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.settings label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.settings label.check input { width: auto; }
.settings button { align-self: flex-start; }

.sign-in { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.sign-in-card { max-width: 420px; width: 100%; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.sign-in-card label { text-align: left; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.sign-in-card h1 { margin: 0; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0; z-index: 5; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .only-narrow { display: inline-block; }
  .row { max-width: 88%; }
  #view-runner, #view-memory, #view-settings { padding: 12px 16px 40px; }
}

/* The two-layer ring beside the composer (0.72.8): inner is context,
   outer is usage, or GPU / CPU load. */
.ring { flex: none; display: flex; align-items: center; cursor: help; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.5; stroke-linecap: round; }
.ring .ring-track { stroke: var(--line); }
.ring .ring-inner { stroke: var(--accent); stroke-dasharray: 0 100; transition: stroke-dasharray .4s; }
.ring .ring-outer { stroke: #3fb984; stroke-dasharray: 0 100; transition: stroke-dasharray .4s; }
.ring .ring-outer.gpu, .ring .ring-outer.cpu { stroke: #e0a440; }
.ring .warn { stroke: #e05050; }
.chip.doc { cursor: pointer; border: 1px solid var(--line); }

/* Attachments and parts of datasets (0.72.8a3). */
.attach { flex: none; align-self: center; }
.tray { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px 0; background: var(--panel); border-top: 1px solid var(--line); }
.tray + .composer { border-top: 0; }
.chip.attached { display: inline-flex; align-items: center; gap: 4px; color: var(--text); border: 1px solid var(--line); }
.chip.attached.picked { border-color: var(--accent); }
.chip.attached.code { border-color: #3fb984; }
.chip-button { background: transparent; color: var(--muted); padding: 0 4px; font-size: 12px; border-radius: 6px; }
.chip-button:hover { background: var(--panel); color: var(--text); }
.dataset-panel { margin: 0 16px 8px; max-height: 55vh; overflow-y: auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
.ds-grid label, .code-bar label.check { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
button.secondary { background: var(--panel-2); color: var(--text); }
.output {
  background: #0a0a0f; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 8px 0;
  max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Code (0.72.8a3). */
#view-code { padding: 16px 24px 40px; width: 100%; }
.code-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.code-bar input, .code-bar select { flex: 1; min-width: 140px; width: auto; }
.code-bar button { flex: none; }
.code-bar label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; flex: 1; }
.code-bar label.check input { width: auto; min-width: 0; flex: none; }
.code-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; margin-top: 8px; }
.code-side, .code-main { min-width: 0; }
.files { list-style: none; margin: 0 0 8px; padding: 0; max-height: 40vh; overflow-y: auto; }
.files li {
  padding: 6px 9px; border-radius: 8px; cursor: pointer; font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.files li:hover { background: var(--panel-2); }
.files li.active { background: var(--accent); color: var(--accent-text); }
.files li small { opacity: .6; }
.editor {
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; tab-size: 4;
  min-height: 300px; resize: vertical; white-space: pre; overflow: auto;
}

@media (max-width: 760px) {
  .ds-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .code-layout { grid-template-columns: 1fr; }
  #view-code { padding: 12px 16px 40px; }
}
