/* Homeport: one stylesheet for the portal and the admin panel. Harbour colours: deep water ink, a signal-buoy accent. */
:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --ink: #12202f;
  --muted: #5b6878;
  --line: #d9dfe6;
  --soft: #eef2f6;
  --accent: #d9541a;
  --accent-ink: #ffffff;
  --link: #1f5fa8;
  --ok: #1d7d46;
  --warn: #a35d00;
  --bad: #b3261e;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Ubuntu, Cantarell, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Ubuntu Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1520; --panel: #142030; --ink: #e6edf5; --muted: #9aa8b8; --line: #24344a; --soft: #1a283a;
    --accent: #ff7a3d; --accent-ink: #1a0d05; --link: #7fb3ff; --ok: #4cc27c; --warn: #f0b04a; --bad: #ff7b72;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--link); }
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 18px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code, .mono { font-family: var(--mono); font-size: 13px; }

input, select, textarea, button, .button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
input:focus-visible, select:focus-visible, button:focus-visible, .button:focus-visible, a:focus-visible {
  outline: 2px solid var(--link); outline-offset: 2px;
}
label { display: grid; gap: 5px; font-weight: 500; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .button:hover { background: var(--soft); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.05); background: var(--accent); }
button.danger { color: var(--bad); }
button:disabled { opacity: .55; cursor: default; }

.page { min-height: 100vh; }
.narrow { max-width: 400px; margin: 0 auto; padding: 72px 16px 40px; display: grid; gap: 18px; }
.wide { max-width: 1040px; margin: 0 auto; padding: 28px 16px 60px; display: grid; gap: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.stack { display: grid; gap: 14px; }
.error { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); padding: 8px 12px; border-radius: 8px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.mark { width: 22px; height: 22px; border-radius: 50% 50% 50% 4px; background: var(--accent); box-shadow: inset 0 -6px 0 color-mix(in srgb, var(--ink) 25%, transparent); }
.bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.who form { margin: 0; }

.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.tile {
  display: grid; gap: 4px; padding: 18px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line);
  text-decoration: none; color: var(--ink); min-width: 0;
}
.tile:hover { border-color: var(--accent); }
.glyph {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 20px;
  background: color-mix(in srgb, var(--accent) 14%, var(--panel)); color: var(--accent); margin-bottom: 6px;
}
.tname { font-weight: 600; }
.tdomain { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

/* Admin panel */
.admin { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; display: grid; align-content: start; gap: 18px; }
.side nav { display: grid; gap: 2px; }
.side nav a { padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.side nav a[aria-current="page"] { background: var(--soft); font-weight: 600; }
.side .foot { color: var(--muted); font-size: 12px; }
.content { padding: 26px 24px 60px; display: grid; gap: 20px; align-content: start; max-width: 1080px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
td.actions button { margin-left: 6px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); }
.pill.running, .pill.done { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.pill.stopped, .pill.failed { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.pill.partly, .pill.unknown { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.entry { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 8px; align-content: start; }
.entry .top { display: flex; align-items: center; gap: 10px; }
.entry .glyph { margin: 0; width: 36px; height: 36px; font-size: 16px; border-radius: 10px; }
.entry p { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 180px; min-width: 0; }
.row > button { flex: 0 0 auto; }
.suffixed { display: flex; gap: 6px; align-items: center; }
.suffixed > input { flex: 1; min-width: 0; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog form, dialog .body { padding: 22px; display: grid; gap: 14px; }
dialog .buttons { display: flex; justify-content: end; gap: 8px; flex-wrap: wrap; }
pre.log { margin: 0; max-height: 320px; overflow: auto; background: var(--soft); border-radius: 8px; padding: 12px; font: 12px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.toast { position: fixed; right: 16px; bottom: 16px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; max-width: min(420px, calc(100vw - 32px)); }
@media (max-width: 760px) {
  .admin { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); gap: 10px; }
  .side .foot { display: none; }
  .side nav { grid-auto-flow: column; overflow-x: auto; }
  .content { padding: 20px 16px 48px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Assistant chat */
.chat { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; align-items: start; }
.convs { display: grid; gap: 2px; position: sticky; top: 16px; max-height: calc(100vh - 120px); overflow-y: auto; }
.convs button { justify-content: start; border: 0; background: none; overflow: hidden; text-overflow: ellipsis; text-align: left; display: block; }
.convs button.current { background: var(--soft); font-weight: 600; }
.thread, .live { display: grid; gap: 12px; }
.msg { display: grid; gap: 8px; max-width: 100%; overflow-wrap: anywhere; }
.msg p { white-space: pre-wrap; }
.msg p.heading { font-size: 16px; margin-top: 4px; }
.msg.user { justify-self: end; max-width: min(620px, 88%); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); border: 1px solid var(--line); border-radius: 14px 14px 4px 14px; padding: 10px 14px; }
.msg.bot { background: var(--panel); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 12px 16px; }
.msg.note { color: var(--muted); font-size: 13px; text-align: center; }
.msg.tools { gap: 4px; }
.msg.tools summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.msg.tools pre.log { margin-top: 6px; max-height: 240px; }
.msg .call { color: var(--muted); }
.msg .by { color: var(--muted); font-size: 12px; }
.msg .by:empty { display: none; }
.status::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.approval { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-color: var(--warn); padding: 14px 16px; }
.approval .row > * { flex: 0 0 auto; }
.consent { border-color: var(--accent); }
.composer { display: grid; gap: 8px; position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 4px; }
.composer textarea { resize: vertical; min-height: 64px; }
.composer .row > select { flex: 0 1 220px; }
@media (max-width: 760px) {
  .chat { grid-template-columns: 1fr; }
  .convs { position: static; grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; max-height: none; }
}

/* Services */
.svc .head { align-items: baseline; }
.svc td.actions, .svc + .list td.actions { white-space: normal; }
.svc td.actions button { margin: 3px 0 3px 6px; }
.svc td:first-child { min-width: 150px; }
pre.log.tall { max-height: min(62vh, 640px); }
dialog:has(.wide-body) { width: min(980px, calc(100vw - 32px)); }

/* Backups */
.apps-pick { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.apps-pick legend { padding: 0 6px; font-weight: 500; }
.row.pw { align-items: center; }
.row.pw .secret { flex: 1 1 auto; }

/* An app's notes */
.notes { padding: 14px 16px; display: grid; gap: 8px; }
.notes p { white-space: pre-wrap; }
.secret { letter-spacing: .02em; word-break: break-all; }
h3 { font-size: 15px; margin: 0; }

/* Installing from GitHub */
dialog:has(form.wide) { width: min(780px, calc(100vw - 32px)); }
textarea.code { font: 12px/1.45 var(--mono); white-space: pre; overflow: auto; }
.problems { border-color: var(--bad); }
.problems b { color: var(--bad); }
.warnings b { color: var(--warn); }
.problems ul, .warnings ul { margin: 6px 0 0; padding-left: 20px; }
.warn-box { padding: 10px 12px; border-radius: 8px; color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }

.ai-glyph { background: linear-gradient(135deg, var(--link), var(--accent)); color: #fff; }

/* The AI page (ai.<main domain>): the model's name large above the message box, like a search page; the conversation
   takes over once it starts. */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body.ai { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.ai-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 2; }
.ai-bar .brand { color: inherit; text-decoration: none; }
.ai-bar .who { margin-left: auto; }
.ai-menu { padding: 6px 10px; }
.ai-small-name { font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: none; }
body.talking .ai-small-name { display: block; }
.ai-body { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 0; }
.ai-convs { display: flex; flex-direction: column; gap: 2px; padding: 14px 10px; border-right: 1px solid var(--line); overflow-y: auto; max-height: calc(100vh - 57px); position: sticky; top: 57px; }
.ai-convs p { padding: 10px 10px 4px; }
.ai-convs button { justify-content: start; border: 0; background: none; text-align: left; display: block; overflow: hidden; text-overflow: ellipsis; }
.ai-convs button.current { background: var(--soft); font-weight: 600; }
.ai-convs .ai-new { border: 1px solid var(--line); font-weight: 600; margin-bottom: 6px; text-align: center; }
.ai-main { display: flex; flex-direction: column; align-items: center; padding: 0 16px; min-width: 0; }

.ai-hero { text-align: center; max-width: 680px; display: grid; gap: 12px; justify-items: center; margin-top: max(10vh, 32px); }
.ai-name {
  font-size: clamp(34px, 6.5vw, 58px); font-weight: 650; letter-spacing: -0.025em; line-height: 1.05;
  background: linear-gradient(100deg, var(--link), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ai-desc { color: var(--muted); font-size: 16px; max-width: 560px; text-wrap: pretty; }
.ai-status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; background: var(--panel); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ready { background: var(--ok); }
.dot.loading { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot.loading { animation: none; } }

.ai-thread { width: 100%; max-width: 780px; display: grid; gap: 12px; }
body:not(.talking) .ai-thread { display: none; }
body.talking .ai-hero { display: none; }
body.talking .ai-thread { padding: 20px 0 8px; flex: 1; align-content: start; }

.ai-composer { width: 100%; max-width: 780px; margin-top: 28px; display: grid; gap: 8px; }
body.talking .ai-composer { position: sticky; bottom: 0; margin-top: 0; padding: 8px 0 14px; background: var(--bg); }
.ai-box { display: flex; align-items: end; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 26px; padding: 8px 8px 8px 18px; box-shadow: 0 2px 14px color-mix(in srgb, var(--ink) 8%, transparent); }
.ai-box:focus-within { border-color: color-mix(in srgb, var(--link) 60%, var(--line)); }
.ai-box textarea { border: 0; background: none; padding: 9px 0; resize: none; min-height: 40px; max-height: 240px; line-height: 1.45; font-size: 16px; }
.ai-box textarea:focus-visible { outline: none; }
.ai-send { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 18px; flex: 0 0 auto; }
.ai-stop { flex: 0 0 auto; border-radius: 999px; }
.ai-under { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 0 6px; }
.ai-pick select { width: auto; max-width: 100%; border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 500; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 780px; margin: 18px 0 32px; }
.ai-chips button { border-radius: 999px; font-size: 14px; white-space: normal; text-align: left; }
.ai-menu { display: none; }

@media (max-width: 760px) {
  .ai-body { grid-template-columns: 1fr; }
  .ai-menu { display: inline-flex; }
  .ai-convs { display: none; position: fixed; inset: 57px 0 auto 0; max-height: 60vh; background: var(--panel); border-right: 0; border-bottom: 1px solid var(--line); z-index: 3; }
  body.menu-open .ai-convs { display: flex; }
  .ai-bar .who > span { display: none; }
  #hint { display: none; }
}
