:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1b2030;
  --line: #262c3d;
  --text: #e7e9ee;
  --muted: #8b93a7;
  --accent: #6d8bff;
  --accent-2: #9b6dff;
  --rec: #ff4d6d;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); min-height: 1.4em; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login h1 { margin: 16px 0 8px; font-weight: 650; letter-spacing: -.02em; }
.login form { display: flex; gap: 8px; margin-top: 8px; }
.login input { flex: 1; min-width: 0; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 16px; }
.login button { padding: 14px 18px; border-radius: 12px; border: 0; background: var(--accent); color: #fff; font-weight: 600; }
.orb { width: 96px; height: 96px; margin: 0 auto; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #a9b8ff, var(--accent) 45%, var(--accent-2) 100%);
  box-shadow: 0 0 60px rgba(109,139,255,.45); }
.orb.small { width: 72px; height: 72px; }

/* ---------- App layout ---------- */
main { height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px; border-bottom: 1px solid var(--line); background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 19px; letter-spacing: -.01em; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); transition: background .3s; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 6px; border-radius: 10px; }

/* Running jobs */
.jobs-strip { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px; scrollbar-width: none; }
.jobs-strip:not(:empty) { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.jobs-strip::-webkit-scrollbar { display: none; }
.job-card { flex: 0 0 auto; width: min(78vw, 300px); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 12px; }
.job-card .row { display: flex; align-items: center; gap: 8px; }
.job-card .name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-card .activity { color: var(--muted); font-size: 13px; margin-top: 4px; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.job-card .stop { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 9px; font-size: 13px; color: var(--muted); }
.spinner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent;
  animation: spin 1s linear infinite; flex: 0 0 auto; }
.queued-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); flex: 0 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Feed */
.feed { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 300px; }
.empty .orb { margin-bottom: 18px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.msg.travis { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.update { align-self: stretch; max-width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--ok); }
.msg.update.failed { border-left-color: var(--bad); }
.msg .meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; opacity: .75; }
.msg .label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 3px; }
.play { background: rgba(255,255,255,.12); border: 0; border-radius: 999px; padding: 2px 10px; font-size: 12px; color: inherit; }
.msg.pending { opacity: .7; font-style: italic; }

.play-banner { padding: 0 16px 8px; }
.play-banner button { width: 100%; padding: 14px; border-radius: 14px; border: 0; background: var(--ok); color: #04210f; font-weight: 650; }

/* Dock + talk button */
.dock { padding: 8px 16px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--bg);
  display: flex; flex-direction: column; align-items: center; gap: 8px; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 14px; color: var(--text); }
.talk-wrap { position: relative; }
.talk { position: relative; width: 96px; height: 96px; border-radius: 50%; border: 0; color: #fff;
  background: radial-gradient(circle at 35% 30%, #a9b8ff, var(--accent) 45%, var(--accent-2) 100%);
  box-shadow: 0 8px 30px rgba(109,139,255,.35); touch-action: none; user-select: none; -webkit-user-select: none;
  transition: transform .15s, background .2s; display: grid; place-items: center; }
.talk:active { transform: scale(.96); }
.talk .ring { position: absolute; inset: -8px; border-radius: 50%; border: 3px solid transparent; pointer-events: none; }
.talk.recording { background: radial-gradient(circle at 35% 30%, #ffb3c0, var(--rec) 55%, #c81e4a 100%); box-shadow: 0 8px 34px rgba(255,77,109,.5); }
.talk.recording .ring { border-color: rgba(255,77,109,.55); animation: pulse 1.2s ease-out infinite; transform: scale(var(--lvl, 1)); }
.talk.busy .ring { border-color: var(--accent); border-right-color: transparent; animation: spin 1s linear infinite; }
.talk.speaking .ring { border-color: rgba(52,211,153,.7); animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { opacity: 1; } 100% { opacity: .2; } }
.hint { color: var(--muted); font-size: 13px; min-height: 1.3em; text-align: center; }

/* Settings sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; z-index: 10; }
.sheet-card { width: 100%; max-height: 85vh; overflow-y: auto; background: var(--panel); border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; }
.sheet h2 { margin: 0 0 4px; }
.sheet h3 { margin: 12px 0 0; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.row-btn { width: 100%; text-align: left; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.row-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; text-align: center; font-weight: 600; margin-top: 8px; }
.row-toggle { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.row-toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
.projects { display: flex; flex-direction: column; gap: 6px; }
.project { padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.project .p-name { font-weight: 600; }
.project .p-path { color: var(--muted); font-size: 12px; word-break: break-all; }

@media (min-width: 700px) {
  main { max-width: 720px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .sheet-card { max-width: 560px; margin: 0 auto; border-radius: 20px; margin-bottom: 24px; }
  .sheet { align-items: center; }
}
