/* ScholarFolk app styles. Colours follow the ScholarFolk Group palette. */

@font-face {
  font-family: 'Geist';
  src: url('/fonts/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('/fonts/GeistMono-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #ffffff;
  --sunken: #f4f6f5;
  --raised: #ffffff;
  --ink: #181818;
  --ink-soft: #2f3a37;
  --muted: #5f6b67;
  --line: #dde5e1;
  --line-strong: #c3cfc9;
  --brand: #187868;
  --brand-dark: #0f6e63;
  --brand-deep: #0b5247;
  --brand-soft: #e4f3ef;
  --brand-tint: #f3f9f7;
  --on-brand: #ffffff;
  --mint: #b2e3d5;
  --navy: #132238;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a5b06;
  --warn-soft: #fff4e2;
  --code-bg: #f6f8f7;
  --overlay: rgba(19, 34, 56, 0.42);
  --shadow: 0 10px 34px rgba(19, 34, 56, 0.14), 0 2px 8px rgba(19, 34, 56, 0.06);
  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --syntax-keyword: #8250df;
  --syntax-string: #0b5247;
  --syntax-number: #b54708;
  --syntax-comment: #7a8581;
  --syntax-title: #0550ae;
  --syntax-attr: #953800;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0f1716;
  --sunken: #0a1110;
  --raised: #162120;
  --ink: #e9efed;
  --ink-soft: #cfd9d5;
  --muted: #8fa09a;
  --line: #23312e;
  --line-strong: #33443f;
  --brand: #3fb39d;
  --brand-dark: #56c4af;
  --brand-deep: #8fdccb;
  --brand-soft: #14302b;
  --brand-tint: #11211e;
  --on-brand: #06211c;
  --danger: #f97066;
  --danger-soft: #3a1a17;
  --warn: #f5b658;
  --warn-soft: #33260f;
  --code-bg: #0b1211;
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  --syntax-keyword: #c4a7ff;
  --syntax-string: #8fdccb;
  --syntax-number: #f5b658;
  --syntax-comment: #7f918b;
  --syntax-title: #79c0ff;
  --syntax-attr: #ffa657;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0f1716;
    --sunken: #0a1110;
    --raised: #162120;
    --ink: #e9efed;
    --ink-soft: #cfd9d5;
    --muted: #8fa09a;
    --line: #23312e;
    --line-strong: #33443f;
    --brand: #3fb39d;
    --brand-dark: #56c4af;
    --brand-deep: #8fdccb;
    --brand-soft: #14302b;
    --brand-tint: #11211e;
    --on-brand: #06211c;
    --danger: #f97066;
    --danger-soft: #3a1a17;
    --warn: #f5b658;
    --warn-soft: #33260f;
    --code-bg: #0b1211;
    --overlay: rgba(0, 0, 0, 0.6);
    --shadow: 0 10px 34px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    --syntax-keyword: #c4a7ff;
    --syntax-string: #8fdccb;
    --syntax-number: #f5b658;
    --syntax-comment: #7f918b;
    --syntax-title: #79c0ff;
    --syntax-attr: #ffa657;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

#app {
  height: 100dvh;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

a {
  color: var(--brand-deep);
  text-underline-offset: 3px;
}

.icon {
  flex: none;
}

.mono {
  font-family: var(--mono);
  font-size: 0.9em;
}

.splash {
  height: 100dvh;
  display: grid;
  place-items: center;
}

/* ---------------------------------------------------------- small parts */

.spinner {
  display: inline-block;
  flex: none;
  border: 2px solid var(--line-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--raised);
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover:not(:disabled) {
  background: var(--sunken);
}

a.btn {
  color: var(--ink);
  text-decoration: none;
}

a.btn-primary {
  color: var(--on-brand);
}

a.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-primary {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-brand);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn .spinner {
  border-top-color: currentColor;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 8px;
  color: var(--muted);
}

.icon-btn:hover:not(:disabled) {
  background: var(--sunken);
  color: var(--ink);
}

.link {
  color: var(--brand-deep);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='url'],
input[type='number'],
input[type='search'],
textarea,
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--bg);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

select {
  width: auto;
  padding-right: 28px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-soft);
}

.field-hint,
.field-error {
  font-size: 12.5px;
  color: var(--muted);
}

.field-error,
.form-error {
  color: var(--danger);
}

.form-error {
  font-size: 13.5px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--danger-soft);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-narrow {
  max-width: 380px;
  align-items: stretch;
}

.form-narrow .btn {
  align-self: flex-start;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.inline {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline input {
  flex: 1;
  min-width: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--sunken);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-brand {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand-deep);
}

.badge-wait {
  background: var(--warn-soft);
  border-color: transparent;
  color: var(--warn);
}

.badge-fail {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.dot {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
}

.dot-on {
  background: #22a06b;
}

.callout {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--sunken);
  font-size: 14px;
}

.callout .icon {
  margin-top: 2px;
}

.callout-good {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.callout-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.empty {
  color: var(--muted);
  font-size: 14px;
  padding: 6px 0;
}

.notes {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--sunken);
  border: 1px solid var(--line);
  gap: 2px;
}

.segmented button {
  padding: 5px 13px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
}

.segmented .segment-on {
  background: var(--raised);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 0;
  padding: 0;
  margin: 0;
}

.choices legend {
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-soft);
  padding: 0 0 6px;
}

.choice {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.choice input {
  flex: none;
  align-self: flex-start;
  margin-top: 4px;
  accent-color: var(--brand);
  box-shadow: none;
}

.choice span {
  display: flex;
  flex-direction: column;
}

.choice small {
  color: var(--muted);
  font-size: 13px;
}

.choice-on {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  max-width: min(92vw, 520px);
  padding: 9px 15px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.toast-error {
  background: var(--danger);
  color: #fff;
}

/* ------------------------------------------------------- popovers, menus */

.popover-anchor {
  position: relative;
  display: inline-flex;
  min-width: 0;
}

.popover {
  position: fixed;
  z-index: 60;
  min-width: 210px;
  max-width: calc(100vw - 16px);
  max-height: min(72vh, 560px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--raised);
  box-shadow: var(--shadow);
}

.popover-wide {
  width: 320px;
}

.menu {
  display: flex;
  flex-direction: column;
}

.menu-title {
  padding: 9px 10px 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.menu-note {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-rule {
  height: 1px;
  margin: 5px 4px;
  background: var(--line);
}

.menu-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: left;
  font-size: 14px;
}

.menu-item .icon,
.menu-item .dot {
  margin-top: 3px;
}

.menu-item .dot {
  margin: 7px 4px 0;
}

.menu-item span {
  min-width: 0;
  flex: 1;
}

.menu-item small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.menu-item:hover:not(:disabled) {
  background: var(--sunken);
}

.menu-on {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.menu-on:hover:not(:disabled) {
  background: var(--brand-soft);
}

.menu-danger {
  color: var(--danger);
}

.menu-path {
  font-family: var(--mono);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

/* ----------------------------------------------------------------- modals */

.modal-backdrop,
.settings-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--overlay);
}

.modal-backdrop {
  z-index: 70;
}

.modal {
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: min(88dvh, 760px);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-small {
  width: min(430px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px 20px;
}

.modal-head h2 {
  font-size: 17px;
  font-weight: 600;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 20px 18px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
}

.steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.steps li > span {
  display: block;
  margin-bottom: 5px;
}

.command {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--code-bg);
}

.command code {
  flex: 1;
  min-width: 0;
  font: 12.5px/1.5 var(--mono);
  overflow-wrap: anywhere;
}

.waiting {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 14px;
}

.folders {
  display: flex;
  flex-direction: column;
  min-height: 180px;
  max-height: 46dvh;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.folder {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 7px;
  text-align: left;
  color: var(--ink-soft);
}

.folder:hover {
  background: var(--sunken);
}

.more summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
}

.more[open] {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.82);
  cursor: zoom-out;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}

/* ------------------------------------------------------------------- auth */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(60rem 30rem at 85% -10%, color-mix(in srgb, var(--mint) 38%, transparent), transparent 60%),
    radial-gradient(40rem 20rem at 0% 110%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 60%),
    var(--brand-tint);
}

.auth-card {
  width: min(430px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-card h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-lead {
  color: var(--muted);
  margin-top: -8px;
}

.auth-switch {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

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

.app {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  height: 100dvh;
}

.app-preview {
  grid-template-columns: 272px minmax(0, 1fr) minmax(360px, 46%);
}

.app-panel {
  grid-template-columns: 272px minmax(0, 1fr) 316px;
}

.scrim {
  display: none;
}

.only-narrow,
.sidebar-close {
  display: none;
}

/* ---------------------------------------------------------------- sidebar */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: calc(10px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
  background: var(--sunken);
  border-right: 1px solid var(--line);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--raised);
  font-weight: 500;
}

.new-chat:hover {
  border-color: var(--brand);
  color: var(--brand-deep);
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--muted);
}

.search:focus-within {
  background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.search input {
  min-height: 34px;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  font-size: 14px;
}

.conversations {
  flex: 1;
  min-height: 0;
  margin: 8px -4px 0;
  padding: 0 4px;
  overflow-y: auto;
}

.conversations h3 {
  padding: 14px 8px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.conversations-empty {
  padding: 14px 8px;
  color: var(--muted);
  font-size: 13.5px;
}

.conv {
  display: flex;
  align-items: center;
  border-radius: 8px;
}

.conv a {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  color: var(--ink-soft);
  font-size: 14px;
  text-decoration: none;
}

.conv-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.conv:hover,
.conv-active {
  background: color-mix(in srgb, var(--line) 62%, transparent);
}

.conv-active a {
  color: var(--ink);
  font-weight: 500;
}

.conv-more {
  width: 28px;
  height: 28px;
  margin-right: 3px;
  opacity: 0;
}

.conv:hover .conv-more,
.conv:focus-within .conv-more,
.conv-active .conv-more {
  opacity: 1;
}

.sidebar-foot {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-foot .popover-anchor {
  display: flex;
  flex: 1;
  min-width: 0;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border-radius: 10px;
  text-align: left;
}

.account:hover {
  background: color-mix(in srgb, var(--line) 62%, transparent);
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 12.5px;
  font-weight: 600;
}

.account-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.account-text strong {
  font-size: 14px;
  font-weight: 550;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.account-text small {
  color: var(--muted);
  font-size: 12.5px;
}

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

.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100dvh;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 50px;
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
}

.chat-title {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 8px;
  text-align: left;
  font-weight: 550;
}

.chat-title span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

button.chat-title:hover {
  background: var(--sunken);
}

.offline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12.5px;
  white-space: nowrap;
}

.chat-status {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
}

.thread-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

.thread {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.thread-inner {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 800px;
  margin: 0 auto;
  padding: 18px 20px 30px;
}

.turn {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.turn-user {
  align-items: flex-end;
}

.bubble {
  max-width: min(86%, 620px);
  padding: 10px 15px;
  border-radius: 18px 18px 5px 18px;
  background: var(--brand-soft);
  color: var(--ink);
}

.bubble-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* A message sent while a reply is in progress, until the work reads it. */
.turn-waiting {
  gap: 5px;
}

.turn-waiting .bubble {
  background: transparent;
  border: 1px dashed var(--line-strong);
  color: var(--ink-soft);
}

.waiting-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  max-width: min(86%, 620px);
  color: var(--muted);
  font-size: 12.5px;
  text-align: right;
}

.waiting-note .link {
  font-size: 12.5px;
}

.pictures {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.picture {
  display: block;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: zoom-in;
  line-height: 0;
}

.picture img {
  max-width: 100%;
  max-height: 300px;
}

.picture-small img {
  max-height: 120px;
}

.turn-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: -4px;
  color: var(--muted);
}

.turn-tools .icon-btn {
  width: 28px;
  height: 28px;
}

.turn-model {
  font-size: 12.5px;
}

.turn-retry {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 4px;
  padding: 3px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  font-size: 12.5px;
  cursor: pointer;
}

.turn-retry:hover {
  background: var(--sunken);
}

/* The model's short account of its reasoning. */
.thought {
  color: var(--muted);
  font-size: 13.5px;
}

.thought summary {
  cursor: pointer;
  width: fit-content;
  font-size: 12.5px;
}

.thought div {
  margin-top: 4px;
  padding-left: 11px;
  border-left: 2px solid var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.thinking {
  display: inline-flex;
  gap: 5px;
  padding: 8px 2px;
}

.thinking i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  animation: pulse 1.1s ease-in-out infinite;
}

.thinking i:nth-child(2) {
  animation-delay: 0.16s;
}

.thinking i:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: scale(0.85);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

.to-bottom {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--raised);
  box-shadow: var(--shadow);
  color: var(--ink-soft);
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 13px;
  border-radius: 11px;
  background: var(--sunken);
  color: var(--ink-soft);
  font-size: 14px;
}

.notice .icon {
  margin-top: 2px;
}

.notice strong {
  font-weight: 550;
}

.notice small {
  display: block;
  color: inherit;
  opacity: 0.85;
  overflow-wrap: anywhere;
}

.notice-error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* --------------------------------------------------------------- markdown */

.md {
  min-width: 0;
  overflow-wrap: anywhere;
}

.md > :first-child {
  margin-top: 0;
}

.md > :last-child {
  margin-bottom: 0;
}

.md p,
.md ul,
.md ol,
.md blockquote,
.md table,
.md .code {
  margin: 0 0 12px;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  margin: 20px 0 8px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.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 {
  padding-left: 22px;
}

.md li {
  margin: 3px 0;
}

.md li > p {
  margin-bottom: 6px;
}

.md blockquote {
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
}

.md hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

.md :not(pre) > code {
  padding: 1.5px 5px;
  border-radius: 5px;
  background: var(--sunken);
  border: 1px solid var(--line);
  font: 0.88em var(--mono);
}

.md table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 14px;
}

.md th,
.md td {
  padding: 6px 11px;
  border: 1px solid var(--line);
  text-align: left;
}

.md th {
  background: var(--sunken);
  font-weight: 600;
}

.md img {
  max-width: 100%;
  border-radius: 8px;
}

.md-live > :last-child::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -2px;
  border-radius: 2px;
  background: var(--brand);
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.code {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--code-bg);
  overflow: hidden;
}

.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px 4px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

.code-actions {
  display: flex;
  gap: 2px;
}

.code-btn {
  padding: 3px 9px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}

.code-btn:hover {
  background: var(--line);
  color: var(--ink);
}

.code pre,
.plain {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font: 13px/1.6 var(--mono);
  tab-size: 2;
}

.code pre code {
  font: inherit;
}

.hljs-keyword,
.hljs-literal,
.hljs-built_in,
.hljs-selector-tag,
.hljs-doctag,
.hljs-meta .hljs-keyword {
  color: var(--syntax-keyword);
}

.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-attribute {
  color: var(--syntax-string);
}

.hljs-number,
.hljs-symbol,
.hljs-bullet,
.hljs-variable,
.hljs-template-variable {
  color: var(--syntax-number);
}

.hljs-comment,
.hljs-quote,
.hljs-meta {
  color: var(--syntax-comment);
}

.hljs-title,
.hljs-section,
.hljs-name,
.hljs-type,
.hljs-selector-id,
.hljs-selector-class {
  color: var(--syntax-title);
}

.hljs-attr,
.hljs-tag,
.hljs-property {
  color: var(--syntax-attr);
}

.hljs-deletion {
  color: var(--danger);
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: 600;
}

/* ---------------------------------------------------------------- actions */

.action {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--raised);
  overflow: hidden;
}

.action-waiting {
  border-color: var(--warn);
}

.action-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 40px;
  padding: 6px 10px 6px 11px;
  text-align: left;
  color: var(--muted);
}

.action-head:hover {
  background: var(--sunken);
}

.action-icon {
  display: grid;
  place-items: center;
  color: var(--brand);
}

.action-label {
  flex: none;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 550;
}

.action-summary {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font: 12.5px var(--mono);
  color: var(--muted);
}

.action-marker {
  display: inline-flex;
  align-items: center;
  color: var(--brand);
}

.action-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.action-body .code {
  margin: 0;
}

.plain {
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--code-bg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.plain-command {
  color: var(--ink-soft);
  font-weight: 500;
}

.plain-removed {
  background: var(--danger-soft);
  border-color: transparent;
}

.plain-added {
  background: var(--brand-soft);
  border-color: transparent;
}

.plain-error {
  color: var(--danger);
}

.approval {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--warn-soft);
}

.approval p {
  flex: 1 1 220px;
  color: var(--warn);
  font-size: 13.5px;
  font-weight: 500;
}

.approval-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.approval .btn {
  min-height: 33px;
  font-size: 13.5px;
}

/* ----------------------------------------------------- welcome, composer */

.welcome {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 20px 16px calc(40px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.welcome-inner {
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-top: -6vh;
}

.welcome h1 {
  font-size: clamp(26px, 4.4vw, 36px);
  font-weight: 550;
  letter-spacing: -0.025em;
  text-align: center;
}

.welcome .composer {
  width: 100%;
}

.ideas {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.idea {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 13.5px;
}

.idea:hover {
  border-color: var(--brand);
  background: var(--brand-tint);
  color: var(--brand-deep);
}

.install-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 6px 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--brand-tint);
  color: var(--ink-soft);
  font-size: 13.5px;
  text-align: left;
}

.install-hint > .icon {
  flex: none;
  color: var(--brand-deep);
}

.install-hint > div {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.install-hint strong {
  color: var(--ink);
  font-weight: 600;
}

.dock {
  padding: 0 16px calc(14px + env(safe-area-inset-bottom));
}

.composer {
  max-width: 800px;
  margin: 0 auto;
  padding: 10px 10px 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--raised);
  box-shadow: 0 2px 12px rgba(19, 34, 56, 0.06);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.composer:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 28px;
  max-height: 320px;
  padding: 4px 2px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  resize: none;
  font-size: 15.5px;
  line-height: 1.5;
}

.composer textarea:focus-visible,
.search input:focus-visible {
  outline: none;
}

.composer-roomy textarea {
  min-height: 58px;
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}

.composer-left,
.composer-right {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.composer-left {
  margin-left: -6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--ink-soft);
  font-size: 13.5px;
  white-space: nowrap;
}

button.chip:hover:not(:disabled) {
  background: var(--sunken);
}

.chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-sub {
  padding-left: 7px;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
}

.chip-static {
  color: var(--muted);
}

.send {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
}

.send:hover:not(:disabled) {
  background: var(--brand-dark);
}

.send:disabled {
  background: var(--line-strong);
  color: var(--bg);
  opacity: 1;
}

.send-stop {
  background: var(--ink);
  color: var(--bg);
}

.send-stop:hover:not(:disabled) {
  background: var(--ink-soft);
}

.send-stop + .send {
  margin-left: 4px;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0 8px;
}

.attachment {
  position: relative;
  line-height: 0;
}

.attachment img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.attachment button {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
}

/* ---------------------------------------------------------------- preview */

.preview {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100dvh;
  border-left: 1px solid var(--line);
  background: var(--bg);
}

.preview-head {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 50px;
  padding: calc(6px + env(safe-area-inset-top)) 8px 6px 12px;
  border-bottom: 1px solid var(--line);
}

.preview-spacer {
  flex: 1;
}

.tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: 9px;
  background: var(--sunken);
  gap: 2px;
}

.tabs button {
  padding: 4px 12px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
}

.tabs .tab-on {
  background: var(--raised);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.preview-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

.preview-code {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

/* --------------------------------------------------------------- settings */

.settings-backdrop {
  z-index: 50;
}

.settings {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  width: min(1000px, 100%);
  height: min(740px, 100%);
  border-radius: 18px;
  background: var(--bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 10px;
  background: var(--sunken);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.settings-nav h2 {
  padding: 0 10px 10px;
  font-size: 17px;
  font-weight: 600;
}

.settings-nav h3 {
  padding: 16px 10px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.settings-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: left;
  color: var(--ink-soft);
  font-size: 14px;
  white-space: nowrap;
}

.settings-link:hover {
  background: color-mix(in srgb, var(--line) 62%, transparent);
}

.settings-link-on {
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 550;
}

.settings-link-on:hover {
  background: var(--brand-soft);
}

.settings-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 8px 26px;
}

.settings-head h2 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.settings-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 26px 28px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.group > h3 {
  font-size: 14.5px;
  font-weight: 600;
}

.group-text {
  color: var(--muted);
  font-size: 14px;
}

.group-text code {
  padding: 1.5px 5px;
  border-radius: 5px;
  background: var(--sunken);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font: 0.88em var(--mono);
  user-select: all;
}

.group-actions {
  display: flex;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.row-text strong {
  font-weight: 500;
}

.row-text small {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.row-side {
  flex: none;
}

.cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.card-tall {
  align-items: flex-start;
}

/* A card whose parts lie under each other: a model and its engines. */
.card-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.card-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.engines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.engine {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--sunken);
}

.engine-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.engine-main strong {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-weight: 550;
}

.engine-main small {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.engine-main .connected,
.engine-main .problem {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  color: var(--brand-deep);
  font-weight: 500;
}

.engine-main .problem {
  color: var(--danger);
}

.engine-side {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.engine-side .btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13.5px;
}

@media (max-width: 640px) {
  .card-row,
  .engine {
    flex-direction: column;
  }

  .engine-side {
    justify-content: flex-start;
  }
}

.card-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.card-main strong {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-weight: 550;
}

.card-main small {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.card-main .connected,
.card-main .problem {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--brand-deep);
  font-weight: 500;
}

.card-main .problem {
  color: var(--danger);
  align-items: flex-start;
}

.card-side {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.card-side-wrap {
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.card-side .btn {
  min-height: 32px;
  padding: 0 11px;
  font-size: 13.5px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 9px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.table th {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.table td small {
  display: block;
  color: var(--muted);
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table tfoot td {
  border-bottom: 0;
  font-weight: 600;
}


/* ------------------------------------------------------- sidebar menu */

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-bottom: 6px;
}

.nav .popover-anchor {
  display: flex;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 14.5px;
  text-align: left;
  text-decoration: none;
}

.nav-item:hover {
  background: color-mix(in srgb, var(--line) 62%, transparent);
}

.nav-on {
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 550;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  font-size: 14px;
}

.menu-row > span:first-of-type {
  flex: 1;
}

.menu-choices {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: var(--sunken);
}

.menu-choices button {
  padding: 3px 9px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

.menu-choices .choice-on {
  background: var(--raised);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* ------------------------------------------------------------ pages */

.page {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100dvh;
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: calc(22px + env(safe-area-inset-top)) 28px 10px;
}

.page-title {
  flex: 1;
  min-width: 0;
}

.page-title h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-title p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.page-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 28px 32px;
}

.page-body > .cards,
.page-body > .tiles,
.page-body > .empty {
  max-width: 980px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.tile {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--raised);
  overflow: hidden;
}

.tile-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 14px 10px;
  text-align: left;
}

.tile-main:hover {
  background: var(--brand-tint);
}

.tile-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 6px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.tile-main strong {
  font-weight: 550;
  overflow-wrap: anywhere;
}

.tile-main small {
  color: var(--muted);
  font-size: 12.5px;
}

.tile-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 6px 6px;
}

.tile-actions .icon-btn {
  width: 30px;
  height: 30px;
}

.task-request {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ------------------------------------------------------- work panel */

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100dvh;
  border-left: 1px solid var(--line);
  background: var(--bg);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 50px;
  padding: calc(6px + env(safe-area-inset-top)) 8px 6px 16px;
}

.panel-head strong {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 550;
}

.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px calc(20px + env(safe-area-inset-bottom));
}

.panel-section {
  padding: 12px 4px;
  border-top: 1px solid var(--line);
}

.panel-section:first-child {
  border-top: 0;
  padding-top: 4px;
}

.panel-section > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 26px;
  margin-bottom: 4px;
}

.panel-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.panel-line {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 32px;
  padding: 4px 6px;
  border-radius: 7px;
  color: var(--ink-soft);
  font-size: 13.5px;
  text-align: left;
}

.panel-line-button:hover {
  background: var(--sunken);
}

.panel-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.panel-text small {
  color: var(--muted);
}

.panel-side {
  display: inline-flex;
  align-items: center;
  flex: none;
  max-width: 50%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 12.5px;
}

.panel-side .icon-btn {
  width: 26px;
  height: 26px;
}

.panel-empty {
  padding: 2px 6px;
  color: var(--muted);
  font-size: 13px;
}

.panel-link {
  color: var(--brand-deep);
  font-size: 12.5px;
  font-weight: 500;
}

.panel-link:disabled {
  color: var(--muted);
}

.panel-figure {
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.meter {
  height: 6px;
  margin: 2px 6px 6px;
  border-radius: 999px;
  background: var(--sunken);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.added {
  color: #1a7f4b;
  font-weight: 550;
}

.removed {
  color: var(--danger);
  font-weight: 550;
}

.tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 3px 6px;
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 13px;
  text-align: left;
}

.tree-item span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tree-item:hover {
  background: var(--sunken);
}

.tree-wait {
  padding: 4px 8px;
}

.panel-toggle-on {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.preview-title {
  min-width: 0;
  padding: 0 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font: 13px var(--mono);
}

/* ---------------------------------------- dialogs added with the menu */

.help-topic {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.help-topic h3 {
  font-size: 14.5px;
  font-weight: 600;
}

.help-topic h3 small {
  margin-left: 6px;
  color: var(--muted);
  font-weight: 400;
}

.help-topic p {
  color: var(--ink-soft);
  font-size: 14px;
}

.plan {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--brand);
  border-radius: 14px;
  background: var(--brand-tint);
}

.plan header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
}

.plan-price {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 0;
  cursor: pointer;
}

.check input {
  flex: none;
  accent-color: var(--brand);
  box-shadow: none;
}

.check span {
  display: flex;
  flex-direction: column;
}

.check small {
  color: var(--muted);
  font-size: 13px;
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.days {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.days button {
  min-width: 38px;
  padding: 5px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.days .day-on {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 550;
}

.growth {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.growth header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.growth .meter {
  height: 10px;
  margin: 0;
}

.growth small {
  color: var(--muted);
  font-size: 13px;
}

input.short {
  width: 96px;
}

label.btn {
  cursor: pointer;
}

/* ----------------------------------------------------------------- narrow */

@media (max-width: 1200px) {
  .app-preview,
  .app-panel {
    grid-template-columns: 272px minmax(0, 1fr);
  }

  .preview,
  .panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 44;
    box-shadow: var(--shadow);
  }

  .preview {
    width: min(100vw, max(52vw, 440px));
  }

  .panel {
    width: min(92vw, 340px);
  }
}

@media (max-width: 900px) {
  .app,
  .app-preview,
  .app-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .only-narrow,
  .sidebar-close {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(86vw, 320px);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
  }

  .app-drawer .sidebar {
    transform: none;
    box-shadow: var(--shadow);
  }

  .app-drawer .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 39;
    background: var(--overlay);
  }

  .conv-more {
    opacity: 1;
  }

  .preview {
    inset: 0;
    width: auto;
    z-index: 45;
    border-left: 0;
  }

  .page-head {
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  }

  .page-body {
    padding: 4px 14px calc(24px + env(safe-area-inset-bottom));
  }

  .thread-inner {
    padding: 12px 14px 24px;
  }

  .dock {
    padding: 0 10px calc(10px + env(safe-area-inset-bottom));
  }

  .bubble {
    max-width: 92%;
  }

  .modal-backdrop,
  .settings-backdrop {
    padding: 0;
    place-items: end stretch;
  }

  .modal {
    width: 100%;
    max-height: 92dvh;
    border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .settings {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }

  .settings-nav {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }

  .settings-nav h2,
  .settings-nav h3 {
    display: none;
  }

  .settings-head {
    padding: 12px 10px 4px 16px;
  }

  .settings-content {
    padding: 6px 16px calc(24px + env(safe-area-inset-bottom));
  }

  .grid-two {
    grid-template-columns: 1fr;
  }

  .card {
    flex-direction: column;
    align-items: stretch;
  }

  .card-side-wrap {
    justify-content: flex-start;
  }

  .row {
    flex-wrap: wrap;
  }

  /* iOS zooms the page when a focused field has text smaller than 16px. */
  input[type='text'],
  input[type='email'],
  input[type='password'],
  input[type='url'],
  input[type='number'],
  input[type='search'],
  textarea,
  select,
  .composer textarea {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.menu-select {
  width: auto;
  max-width: 150px;
  min-height: 30px;
  padding: 3px 8px;
  font-size: 13px;
}
