/* Loft's page: the same tokens as relay's page (DESIGN.md). Unlike relay's page this is an ordinary document that scrolls,
   under a bar that stays at the top. *//* ================= Design tokens =================
   System fonts (SF Pro / PingFang), and one accent color (system blue), used only for things that can be acted on;
   hierarchy comes from background shades and thin dividers, and shadows are only for the floating composer card, popups and the "island". */
:root {
  --canvas: #ffffff;
  --side: #f5f5f7;
  --group: #f5f5f7;
  --fill: #f0f0f2;
  --fill-2: #e8e8ed;
  --label: #1d1d1f;
  --label-2: #6e6e73;
  --label-3: #a1a1a6;
  --sep: rgba(60, 60, 67, .13);
  --sep-strong: rgba(60, 60, 67, .22);
  --accent: #0071e3;
  --accent-press: #0062c4;
  --accent-soft: rgba(0, 113, 227, .1);
  --red: #e5372d;
  --red-soft: rgba(229, 55, 45, .08);
  --green: #1f9e45;
  --elev: #ffffff;
  --shadow-card: 0 0 0 .5px rgba(0, 0, 0, .1), 0 10px 30px -14px rgba(0, 0, 0, .22), 0 2px 6px -2px rgba(0, 0, 0, .06);
  --shadow-pop: 0 0 0 .5px rgba(0, 0, 0, .12), 0 18px 48px -12px rgba(0, 0, 0, .28);
  /* Chinese: PingFang on Apple devices, so they never download the bundled Sarasa after it; other devices get that, which
     covers CJK only, so Latin, symbols and emoji still come from the fonts around it */
  --cjk: "PingFang SC", "Hiragino Sans GB", "Sarasa UI SC", "Microsoft YaHei UI", "Microsoft YaHei";
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", var(--cjk), sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, "JetBrains Mono", Consolas, "Liberation Mono", var(--cjk), monospace;
  --ease: cubic-bezier(.32, .72, 0, 1);
  /* Each effort level its own colour, cool to warm as it thinks more, and max a gradient through all of them. None is the accent:
     a set level never reads as the model chip beside it */
  --e-low: #15803a; --e-medium: #0a7d8c; --e-high: #5e4fd8; --e-xhigh: #c25400; --e-max: #d1336b;
  --e-all: linear-gradient(90deg, var(--e-low), var(--e-medium), var(--e-high), var(--e-xhigh), var(--e-max));
  color-scheme: light;
}
[data-level="low"] { --lv: var(--e-low); }
[data-level="medium"] { --lv: var(--e-medium); }
[data-level="high"] { --lv: var(--e-high); }
[data-level="xhigh"] { --lv: var(--e-xhigh); }
[data-level="max"] { --lv: var(--e-max); }
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #161617;
    --side: #1d1d1f;
    --group: #1f1f21;
    --fill: #2a2a2d;
    --fill-2: #333336;
    --label: #f5f5f7;
    --label-2: #a1a1a6;
    --label-3: #6e6e73;
    --sep: rgba(235, 235, 245, .1);
    --sep-strong: rgba(235, 235, 245, .18);
    --accent: #2997ff;
    --accent-press: #4aa8ff;
    --accent-soft: rgba(41, 151, 255, .16);
    --red: #ff6961;
    --red-soft: rgba(255, 105, 97, .12);
    --green: #4cd964;
    --elev: #232325;
    --shadow-card: 0 0 0 .5px rgba(255, 255, 255, .1), 0 14px 36px -14px rgba(0, 0, 0, .7);
    --shadow-pop: 0 0 0 .5px rgba(255, 255, 255, .12), 0 20px 50px -12px rgba(0, 0, 0, .75);
    --e-low: #4cd964; --e-medium: #40c8e0; --e-high: #9d8cff; --e-xhigh: #ff9f0a; --e-max: #ff6b9a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
/* What scrolls into view, by focus or by a script, stops below the bar rather than under it */
html { background: var(--canvas); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(64px + env(safe-area-inset-top)); }
body {
  margin: 0; color: var(--label); font: 15px/1.6 var(--sans); letter-spacing: .005em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
@media (pointer: coarse) { input { font-size: 16px !important; } }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; border-radius: 8px; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--fill); padding: 1px 6px; border-radius: 5px; }

/* ---------- The bar: name, tabs, who is signed in ---------- */
.bar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--canvas) 86%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--sep); padding-top: env(safe-area-inset-top);
}
.bar-in {
  display: flex; align-items: center; gap: 22px; height: 52px; max-width: 1120px; margin: 0 auto;
  padding: 0 max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left));
}
.brand { font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.tabs { display: flex; gap: 2px; margin-right: auto; }
.tab {
  padding: 5px 12px; border-radius: 8px; color: var(--label-2); font-size: 14px; font-weight: 500; text-decoration: none;
  transition: background-color .15s, color .15s;
}
.tab.on { background: var(--fill); color: var(--label); }
.me { display: flex; align-items: center; gap: 10px; color: var(--label-2); font-size: 14px; }

/* ---------- A page ---------- */
.page { max-width: 768px; margin: 0 auto; padding: 24px max(24px, env(safe-area-inset-right)) 96px max(24px, env(safe-area-inset-left)); }
.head { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; }
.head h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; margin: 0 auto 0 0; }
.section-title { font-size: 13px; font-weight: 600; color: var(--label-2); margin: 26px 0 8px 14px; letter-spacing: .02em; }
.section-title.first { margin-top: 4px; }
.note { font-size: 13px; color: var(--label-3); }
/* A sentence under a page's title, saying where what it lists comes from */
.lead { margin: -8px 0 18px; font-size: 14px; color: var(--label-2); }
.lead a { color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }
.error { color: var(--red); margin: 12px 14px 0; }
.toast {
  position: fixed; z-index: 40; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 10px 16px; border-radius: 12px;
  background: var(--elev); color: var(--label); box-shadow: var(--shadow-pop); font-size: 14px; animation: toast .22s var(--ease);
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: none; }
@keyframes toast { from { transform: translateX(-50%) translateY(8px); opacity: 0; } }

/* ---------- Controls ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 18px; border: 0; border-radius: 18px;
  background: var(--accent); color: #fff; font-weight: 500; font-size: 14px; text-decoration: none; white-space: nowrap;
  transition: background-color .15s;
}
.button.big { height: 40px; padding: 0 22px; border-radius: 20px; font-size: 15px; }
.button:disabled { opacity: .4; cursor: default; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-size: 14px; white-space: nowrap; }
.link.danger { color: var(--red); }
.link.muted { color: var(--label-2); }
.actions { margin-left: auto; display: flex; gap: 16px; }
/* Hover only where there is a pointer that hovers: on touch it would stay on whatever was last tapped */
@media (hover: hover) {
  .tab:hover { color: var(--label); }
  .button:hover:not(:disabled) { background: var(--accent-press); }
  .link:hover, .lead a:hover { text-decoration: underline; text-underline-offset: 2px; }
}
/* On touch the text buttons keep their look but take a finger-sized area around it */
@media (pointer: coarse) {
  .link { padding: 10px 8px; margin: -10px -8px; }
  .actions { gap: 20px; }
}

.add { display: flex; gap: 10px; margin-top: 14px; }
.add input {
  flex: 1; min-width: 0; height: 36px; padding: 0 14px; border: .5px solid var(--sep-strong); border-radius: 10px;
  background: var(--canvas); outline: none;
}
.add input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.avatar {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: var(--fill-2); color: var(--label-2); font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.avatar.big { width: 30px; height: 30px; font-size: 13px; }
.tag { font-size: 12px; line-height: 20px; padding: 0 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.online { background: var(--green); }
.dot.offline { background: var(--label-3); }

.chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px 0 4px; border-radius: 14px;
  background: var(--canvas); color: var(--label); font-size: 13px; white-space: nowrap;
}
.chip .x { border: 0; background: none; padding: 0; margin-right: -4px; color: var(--label-2); display: inline-grid; }
.chip .x svg { width: 14px; height: 14px; }
.chip.asking { padding: 0 12px; gap: 12px; color: var(--label-2); }
.chip.asking .link { font-size: 13px; }
@media (hover: hover) { .chip .x:hover { color: var(--label); } }
@media (pointer: coarse) { .chip .x { padding: 11px; margin: -11px -15px -11px -9px; } }

/* A grouped list, as in the iOS settings */
.list { list-style: none; margin: 0; padding: 0; background: var(--group); border-radius: 12px; overflow: hidden; }
.list li { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 9px 14px; flex-wrap: wrap; }
.list li + li { border-top: .5px solid var(--sep); }
.list .main { flex: 1; min-width: 0; display: grid; }
.list .sub { font-size: 12.5px; color: var(--label-2); }
.list .empty { color: var(--label-3); font-size: 13.5px; }
.name { font-weight: 500; }
.real { color: var(--label-2); margin-left: 8px; }

/* ---------- 我的 ---------- */
.machs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.mach {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 12px; border: 0;
  background: var(--group); text-align: left; color: var(--label-3); transition: background-color .15s;
}
.mach .main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.mach .t { color: var(--label); font-weight: 500; }
.mach .sub { font-size: 12.5px; color: var(--label-2); }
.mach:disabled { cursor: default; }
/* Assigned but not registered: an outline where its card will be, with the line that registers it */
.mach.pending { background: none; outline: 1px dashed var(--sep-strong); outline-offset: -1px; grid-column: 1 / -1; }
.mach .cmd { justify-self: start; margin-top: 6px; color: var(--label); max-width: 100%; overflow-x: auto; white-space: nowrap; user-select: all; -webkit-user-select: all; }
@media (hover: hover) { button.mach:hover:not(:disabled) { background: var(--fill); color: var(--accent); } }

/* ---------- 机器 ---------- */
.machine { background: var(--group); border-radius: 14px; padding: 16px 18px 18px; margin-bottom: 14px; }
.machine-head { display: flex; align-items: center; gap: 12px; }
.machine h3 { margin: 0; font-size: 17px; font-weight: 650; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.machine .k { font-size: 12.5px; font-weight: 600; color: var(--label-2); margin: 14px 0 8px; }
.machine .list { background: var(--canvas); }
.add-chip { height: 28px; padding: 0 10px; border-radius: 14px; border: 0; background: none; color: var(--accent); font-size: 13px; transition: background-color .15s; }
.add-chip.on { background: var(--accent-soft); }
@media (hover: hover) { .add-chip:hover { background: var(--accent-soft); } }

/* The menu that opens below a button: frosted, floating, the choice under the pointer in blue */
.menu-box { position: relative; display: inline-flex; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 160px; max-height: 280px; overflow-y: auto;
  padding: 5px; border-radius: 12px; display: grid;
  background: color-mix(in srgb, var(--elev) 82%, transparent); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--shadow-pop); animation: pop .18s var(--ease); transform-origin: top left;
  /* Scrolled into view while it still opens at 94%, so a margin for the rest */
  scroll-margin-bottom: 16px;
}
.menu button { border: 0; background: none; text-align: left; padding: 6px 10px; border-radius: 7px; font-size: 14px; white-space: nowrap; }
@media (hover: hover) { .menu button:hover { background: var(--accent); color: #fff; } }
@media (pointer: coarse) {
  .menu button { padding: 10px 12px; }
  .add-chip { height: 36px; border-radius: 18px; }
  .tab { padding: 9px 14px; }
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } }

/* ---------- Sign-in ---------- */
.center { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 24px; text-align: center; }
.center .title { font-size: 40px; font-weight: 650; letter-spacing: -.02em; margin: 0; }
.center .sub { color: var(--label-2); margin: 0 0 22px; }

/* ---------- Narrow screens: the tabs go under the name, the cards two to a row ---------- */
@media (max-width: 760px) {
  .bar-in { flex-wrap: wrap; height: auto; gap: 0 10px; padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); }
  .brand { display: flex; align-items: center; height: 48px; }
  .me { margin-left: auto; }
  .tabs { order: 3; width: 100%; margin: 0 -4px 8px; }
  html { scroll-padding-top: calc(108px + env(safe-area-inset-top)); }
  .wide { display: none; }
  .page { padding: 16px max(14px, env(safe-area-inset-right)) 64px max(14px, env(safe-area-inset-left)); }
  .machs { grid-template-columns: 1fr 1fr; gap: 8px; }
  .mach { padding: 10px 12px; gap: 10px; }
  .mach > svg { display: none; }
  .machine { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
