/* The look of the Vector app on the PC: one dark surface, panels a shade lighter, light grey text. */
:root {
  --paper: #1a1a1a;      /* the window */
  --card: #212121;       /* panels: the prompt box, your own messages, search */
  --chosen: #2c2c2c;     /* the chat that is open, code chips */
  --line: #2e2e2e;
  --edge: #383838;       /* the outline of a panel */
  --ink: #f5f5f5;
  --dim: #bbbbbb;        /* chat names, updates */
  --soft: #6b6b6b;       /* times, placeholders */
  --link: #b59df1;
  --orange: #ff7a52;
  --green: #6fd18a;
  --amber: #ffc15a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC", "Microsoft JhengHei", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; }

.hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

[hidden] { display: none !important; }

.main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.device-controls { flex: none; margin: 0 0 14px; padding: 4px 4px 12px; border-bottom: 1px solid var(--line); }
.device-controls label, #deviceDialog label { display: block; margin-bottom: 5px; color: var(--dim); font-size: 13px; }
.device-controls select, #deviceDialog input { width: 100%; padding: 10px; border: 1px solid var(--edge); border-radius: 9px; background: var(--card); color: var(--ink); font: inherit; }
.device-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.device-actions button, #firstDevice { min-height: 42px; padding: 4px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--link); cursor: pointer; }
.send-target { min-width: 0; overflow: hidden; margin: 0 9px; color: var(--dim); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
#deviceDialog { width: min(90vw, 380px); max-height: 88dvh; overflow-y: auto; padding: 20px; border: 1px solid var(--edge); border-radius: 14px; background: var(--card); color: var(--ink); }
#deviceDialog::backdrop { background: rgba(0, 0, 0, .65); }
#deviceDialog h2 { margin: 0 0 14px; font-size: 19px; }
#deviceDialog label { margin-top: 12px; }
#deviceDialog p { color: var(--dim); font-size: 14px; }
#deviceDialog .device-actions { margin-top: 10px; }
#deviceDialog #deviceError { color: var(--orange); }

/* ---- the chat list */
.side {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  width: min(84vw, 330px);
  padding: calc(12px + env(safe-area-inset-top)) 8px calc(10px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  border-right: 1px solid var(--line);
  background: var(--paper);
  transform: translateX(-102%);
  visibility: hidden;
  transition: transform 0.2s ease, visibility 0s linear 0.2s;
}

body.side-open .side {
  transform: none;
  visibility: visible;
  transition: transform 0.2s ease;
}

.shade {
  position: fixed;
  z-index: 20;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.search {
  flex: none;
  display: flex;
  gap: 9px;
  align-items: center;
  min-height: 42px;
  margin: 0 0 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--soft);
}

.search input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}

.search input::placeholder { color: var(--soft); opacity: 1; }
.search input::-webkit-search-cancel-button { display: none; }
.search:focus-within { border-color: var(--edge); }

.chats {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.chip {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  margin: 0 0 2px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
  text-align: left;
}

.chip .name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.chosen { background: var(--chosen); color: var(--ink); }
.chip.away .name { color: var(--soft); }
.chip .when { flex: none; margin-left: auto; padding-left: 8px; color: var(--soft); font-size: 14px; font-variant-numeric: tabular-nums; }
.chip .new { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--link); }

.spin {
  flex: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--soft);
  border-top-color: transparent;
  border-radius: 50%;
  animation: turn 0.9s linear infinite;
}

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

.side-empty { margin: 6px 12px; color: var(--soft); font-size: 14px; }

/* ---- the bar */
.bar {
  flex: none;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 8px calc(6px + env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.menu {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
}

.menu:active { background: var(--chosen); }
.menu .new { position: absolute; top: 9px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--link); }

.titles { flex: 1 1 auto; min-width: 0; }

.brand {
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 1px 0 0;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.35;
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--soft);
  transform: translateY(-1px);
}

.dot.ok { background: var(--green); }
.dot.busy { background: var(--amber); animation: pulse 1.4s ease-in-out infinite; }
.dot.bad { background: var(--orange); }

@keyframes pulse { 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
  .dot.busy { animation: none; }
  .spin { animation-duration: 2.4s; }
  .side, body.side-open .side { transition: none; }
}

/* ---- the feed */
.feed {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px calc(16px + env(safe-area-inset-right)) 18px calc(16px + env(safe-area-inset-left));
}

.day {
  margin: 14px 0 10px;
  color: var(--soft);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
}

.item {
  max-width: 46rem;
  margin: 0 auto 14px;
}

.item .text { overflow-wrap: anywhere; }

.item .meta {
  margin-top: 4px;
  color: var(--soft);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* what you typed: a panel, as in the app */
.item.prompt .text {
  padding: 11px 14px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: var(--card);
  white-space: pre-wrap;
}

.item.prompt .meta { text-align: right; }
.item.prompt.failed .text { border-style: dashed; border-color: var(--orange); background: transparent; }
.item.prompt.failed .meta { color: var(--orange); }

/* what the chat says while it works */
.item.update { display: flex; gap: 10px; align-items: baseline; color: var(--dim); font-size: 15px; }
.item.update::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--soft); transform: translateY(-2px); }
.item.update .meta { flex: none; margin: 0 0 0 auto; padding-left: 8px; }
.item.update .text { min-width: 0; }

.item.note { color: var(--soft); font-size: 13px; text-align: center; }
.item.note .meta { display: none; }

/* the answer: plain text on the window, no bubble */
.item.result .text,
.item.error .text { line-height: 1.6; }

.item.error .text { padding: 2px 0 2px 12px; border-left: 3px solid var(--orange); }

.text p { margin: 0 0 11px; }
.text p:last-child, .text ul:last-child, .text ol:last-child, .text pre:last-child, .text .scroll:last-child { margin-bottom: 0; }
.text h3 { margin: 16px 0 6px; font-size: 16px; font-weight: 600; }
.text h3:first-child { margin-top: 0; }
.text ul, .text ol { margin: 0 0 11px; padding-left: 24px; }
.text li { margin: 4px 0; }
.text li::marker { color: var(--dim); }
.text strong { font-weight: 600; }
.text a { color: var(--link); }

.text code {
  padding: 1.5px 6px;
  border-radius: 5px;
  background: var(--chosen);
  font: 13.5px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.text pre {
  margin: 0 0 11px;
  padding: 11px 13px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

.text pre code { padding: 0; background: none; white-space: pre; }

.text .scroll { margin: 0 0 11px; overflow-x: auto; }
.text table { border-collapse: collapse; font-size: 14px; }
.text th, .text td { padding: 6px 10px; border: 1px solid var(--edge); text-align: left; vertical-align: top; }
.text th { background: var(--card); font-weight: 600; }

.more {
  margin-top: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: transparent;
  color: var(--dim);
  font-size: 14px;
}

.retry, .drop {
  padding: 0;
  border: 0;
  background: none;
  color: var(--orange);
  font-size: 12.5px;
  text-decoration: underline;
}

.drop { margin-left: 10px; color: var(--soft); }

.empty { margin: 22vh auto 0; max-width: 20rem; color: var(--soft); text-align: center; }

/* ---- sheets and hints */
.sheet { flex: 1 1 auto; max-width: 34rem; margin: 0 auto; padding: 24px 20px; overflow-y: auto; }
.sheet h2 { margin: 0 0 10px; font-size: 22px; font-weight: 600; }
.sheet ol { padding-left: 22px; }
.sheet li { margin: 6px 0; }
.soft { color: var(--soft); font-size: 14px; }

.hint {
  flex: none;
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0 12px 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--dim);
  font-size: 14px;
}

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

.hint button, .preview button {
  flex: none;
  min-width: 44px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

/* ---- the prompt box */
.composer {
  flex: none;
  padding: 4px calc(12px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
}

.compose {
  max-width: 46rem;
  margin: 0 auto;
  padding: 4px 8px 8px;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: var(--card);
}

.compose:focus-within { border-color: #4a4a4a; }

.composer textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  max-height: 38vh;
  padding: 10px 8px 6px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  resize: none;
}

.composer textarea::placeholder { color: var(--soft); opacity: 1; }

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

.composer .attach, .composer .send {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
}

.composer .attach { background: var(--chosen); color: var(--dim); }
.composer .send { background: var(--ink); color: var(--paper); }
.composer button:disabled { opacity: 0.3; }

.menu:focus-visible,
.chip:focus-visible,
.composer button:focus-visible,
.more:focus-visible,
.preview button:focus-visible,
.hint button:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* ---- the photo about to be sent */
.preview {
  flex: none;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px calc(16px + env(safe-area-inset-right)) 6px calc(16px + env(safe-area-inset-left));
}

.preview img { width: 56px; height: 56px; border: 1px solid var(--edge); border-radius: 10px; object-fit: cover; }

/* ---- pictures in the feed */
.pic { margin: 0 0 8px; }
.pic:last-child { margin-bottom: 0; }
.pic img { display: block; max-width: 100%; height: auto; border-radius: 10px; background: var(--card); }

.pic .wait {
  display: grid;
  place-items: center;
  max-width: 100%;
  border-radius: 10px;
  background: var(--card);
  color: var(--soft);
  font-size: 13px;
}

.pic button.wait { border: 1px dashed var(--orange); color: var(--orange); font-size: 13px; }
.item.prompt .pic { max-width: 70%; margin-bottom: 8px; }
.item.prompt .pic:last-child { margin-bottom: 0; }
.item.update .pic { margin-top: 6px; }

/* ---- a wide screen: the chat list stays open on the left, as in the app */
@media (min-width: 820px) {
  .side {
    position: static;
    flex: none;
    width: 300px;
    transform: none;
    visibility: visible;
    transition: none;
  }

  .shade { display: none !important; }
  .menu { display: none; }
  .bar { padding-left: 20px; }
}
