/* Weel's web page, in the window's direction « Calme » (app/style.css): warm paper and ink, the brand's gradient only on
   its mark. Light and dark follow the system. */
:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --border: #e4ded3;
  --border-strong: #d2cabd;
  --text: #23252d;
  --muted: #5f6371;
  --faint: #9a9ca6;
  --ink: #1b1d26;
  --on-ink: #ffffff;
  --soft: #ebe5da;
  --ok: #12996a;
  --working: #6c47dc;
  --attention: #d26a35;
  --danger: #b0413a;
  --code: #f1ece4;
  --shadow: 0 1px 2px rgba(30, 25, 15, 0.05), 0 6px 22px rgba(30, 25, 15, 0.07);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171c;
    --card: #22242b;
    --border: #2d2f38;
    --border-strong: #3c3f4a;
    --text: #e7e5df;
    --muted: #a7a9b3;
    --faint: #6f727d;
    --ink: #f2efe8;
    --on-ink: #16171c;
    --soft: #2a2c34;
    --ok: #3ecf8e;
    --working: #a084ff;
    --attention: #f0915a;
    --danger: #e0766d;
    --code: #2a2c34;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }

.mark { width: 26px; height: 26px; border-radius: 7px; display: block; }
.mark.big { width: 52px; height: 52px; border-radius: 13px; }
.muted { color: var(--muted); }
.hint { color: var(--faint); font-size: 13px; margin: 0; }
.error { color: var(--danger); margin: 0; font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

.primary { background: var(--ink); color: var(--on-ink); border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 600; }
.primary:disabled { opacity: 0.5; }
.ghost { background: transparent; border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; }
.ghost:hover { background: var(--soft); }
.danger { background: var(--danger); color: #fff; border: 0; border-radius: 10px; padding: 6px 12px; font-weight: 600; }
.link { background: none; border: 0; padding: 0; color: var(--working); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* Sign-in and invitation */
.center { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.door { width: min(380px, 100%); padding: 32px 28px 28px; display: flex; flex-direction: column; gap: 16px; }
.door h1 { font-size: 22px; }
.door .lead { margin: -8px 0 0; color: var(--muted); }
.door label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.door input, .add input, .link-row input { border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px 12px; background: var(--bg); font-size: 15px; font-weight: 400; }
.door input:focus, .add input:focus, textarea:focus { outline: 2px solid var(--working); outline-offset: -1px; }
#join-fields { display: flex; flex-direction: column; gap: 16px; }

/* The account's page */
#app { height: 100%; display: flex; flex-direction: column; }
.bar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; padding-top: max(12px, env(safe-area-inset-top)); border-bottom: 1px solid var(--border); background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; margin-right: auto; }
.chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 13px; max-width: 46vw; }
.chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.chip[data-state="ready"] .dot, .hands li.ready .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.chip[data-state="none"] .dot { background: var(--attention); }
.account { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); padding: 12px; min-width: 220px; z-index: 5; display: flex; flex-direction: column; gap: 10px; }
.menu p { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.offline { margin: 0; padding: 6px 20px; background: var(--soft); color: var(--muted); font-size: 13px; text-align: center; }

.column { width: min(760px, 100%); margin: 0 auto; padding: 0 20px; }
.conversation { flex: 1; overflow-y: auto; padding: 24px 0 8px; }
#messages { display: flex; flex-direction: column; gap: 14px; }
.message { display: flex; flex-direction: column; gap: 4px; }
.message.user { align-items: flex-end; }
.message.weel { align-items: flex-start; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 18px; overflow-wrap: anywhere; }
.message.user .bubble { background: var(--ink); color: var(--on-ink); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.message.weel .bubble { background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.answer > :first-child { margin-top: 0; }
.answer > :last-child { margin-bottom: 0; }
.answer p, .answer ul, .answer ol, .answer pre { margin: 0 0 10px; }
.answer ul, .answer ol { padding-left: 22px; }
.answer h3 { font-size: 15px; margin: 4px 0 8px; }
.answer code { font: 13px/1.4 var(--mono); background: var(--code); border-radius: 5px; padding: 1px 5px; }
.answer pre { background: var(--code); border-radius: 10px; padding: 10px 12px; overflow-x: auto; }
.answer pre code { padding: 0; background: none; }
.answer a { color: var(--working); }
.answer:empty::before { content: "…"; color: var(--faint); }
.meta { font-size: 12.5px; color: var(--faint); padding: 0 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.message.weel .meta { justify-content: flex-start; }
.meta.waiting { color: var(--attention); }
.meta.failed { color: var(--danger); }
.meta.writing { color: var(--working); }
.detail { margin: 0; max-width: 85%; font: 12px/1.4 var(--mono); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--soft); border-radius: 8px; padding: 6px 10px; }
.dots { width: 22px; height: 6px; background: radial-gradient(circle, currentColor 2.5px, transparent 3px) 0 50% / 8px 6px repeat-x; animation: dots 1.2s linear infinite; }
@keyframes dots { 50% { opacity: 0.35; } }

.empty { margin: 9vh auto 0; max-width: 440px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty h2 { font-size: 24px; }
.empty p { margin: 0; }

.composer { padding: 10px 0 max(14px, env(safe-area-inset-bottom)); }
.field { display: flex; align-items: flex-end; gap: 8px; background: var(--card); border: 1px solid var(--border-strong); border-radius: 20px; padding: 8px 8px 8px 16px; box-shadow: var(--shadow); }
.field textarea { flex: 1; border: 0; background: transparent; resize: none; padding: 6px 0; max-height: 220px; line-height: 1.45; outline: none; }
.field:focus-within { border-color: var(--working); }
.send { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; flex: none; }
.send svg { width: 18px; height: 18px; }
.send:disabled { opacity: 0.4; }
.stop { border: 1px solid var(--border-strong); background: var(--bg); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; flex: none; }
.composer .hint { text-align: center; margin-top: 8px; }

/* The machines */
dialog { width: min(520px, calc(100% - 32px)); padding: 22px; color: var(--text); }
dialog::backdrop { background: rgba(20, 18, 14, 0.35); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dialog-head h2 { font-size: 19px; }
.close { border: 0; font-size: 16px; padding: 4px 8px; }
dialog > .muted { margin: 0 0 14px; font-size: 14px; }
.hands { list-style: none; margin: 0 0 18px; padding: 0; border: 1px solid var(--border); border-radius: 12px; }
.hands li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; }
.hands li + li { border-top: 1px solid var(--border); }
.hands li.none { justify-content: flex-start; }
.about { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; min-width: 0; }
.about b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.about .muted { grid-column: 2; font-size: 13px; }
.add { display: flex; align-items: flex-end; gap: 10px; }
.add label { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.add .primary { padding: 10px 16px; }
.pairing { margin-top: 16px; padding: 14px; border-radius: 12px; background: var(--soft); display: flex; flex-direction: column; gap: 10px; }
.pairing p { margin: 0; font-size: 14px; }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; min-width: 0; font: 12px var(--mono); }

@media (max-width: 560px) {
  .bar { padding-left: 14px; padding-right: 14px; }
  .column { padding: 0 12px; }
  .brand span { display: none; }
  .bubble { max-width: 92%; }
}
