@font-face {
  font-family: "Geist";
  src: url("/fonts/geist-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/geist-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #000;
  --s1: #0d0d0d;
  --s2: #161616;
  --s3: #222;
  --line: #262626;
  --tx: #ededed;
  --mu: #8a8a8a;
  --mu2: #5c5c5c;
  --remo: #6ea8fe;
  --nero: #f0b45a;
  --planer: #5cc8a0;
  --claude: #e08a62;
  --system: #8a8a8a;
  --danger: #f06a6a;
  --r: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tx); }
body {
  font: 15px/1.5 "Geist", -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--mu); }
:focus-visible { outline: 2px solid var(--remo); outline-offset: 2px; }

/* ---------- Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-icon { width: 72px; height: 72px; border-radius: 18px; image-rendering: pixelated; }
.login-card h1 { margin: 6px 0 0; font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.login-card p { margin: 0; }
.field { position: relative; display: block; margin-top: 10px; }
.field input {
  width: 100%; padding: 13px 46px 13px 14px; font: 16px "Geist Mono", monospace;
  background: var(--s1); color: var(--tx); border: 1px solid var(--line); border-radius: var(--r);
}
.field input:focus { outline: none; border-color: #444; }
.eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; color: var(--mu);
}
.eye:hover { color: var(--tx); background: var(--s2); }
.eye svg { transition: transform .18s ease, opacity .18s ease; }
.eye.flip svg { transform: scale(.6); opacity: 0; }
.primary {
  padding: 13px; border-radius: var(--r); background: var(--tx); color: #000; font-weight: 600;
}
.primary:disabled { opacity: .5; }
.err { color: var(--danger); min-height: 1.5em; font-size: 14px; }

/* ---------- App */
.app { height: 100dvh; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px; border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.title { display: flex; flex-direction: column; min-width: 0; }
.title strong { font-size: 16px; font-weight: 600; }
.status { display: flex; align-items: center; gap: 7px; color: var(--mu); font-size: 13px; min-width: 0; }
.status span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mu2); flex: none; }
.status.ok .dot { background: var(--planer); }
.status.busy .dot { background: var(--claude); animation: puls 1.4s ease-in-out infinite; }
.status.paused .dot { background: var(--danger); }
.status.off .dot { background: var(--mu2); }
@keyframes puls { 50% { opacity: .3; } }
.actions { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: var(--mu); }
.icon-btn:hover { color: var(--tx); background: var(--s2); }
.icon-btn.on { color: var(--tx); }
.pill-btn {
  display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 13px; font-weight: 500;
}
.pill-btn svg.i { width: 14px; height: 14px; }
.pill-btn:hover { background: var(--s2); }
.pill-btn.paused { border-color: #5a2a2a; color: #ffb4b4; }

.list { flex: 1; overflow-y: auto; padding: 8px 0 16px; overscroll-behavior: contain; }
.day { text-align: center; color: var(--mu2); font-size: 12px; margin: 18px 0 6px; }
.msg { padding: 8px 16px; max-width: 860px; margin: 0 auto; }
.msg + .msg.same { padding-top: 0; }
.msg .head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg .who { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.msg .who::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.msg .to, .msg .time { color: var(--mu2); font-size: 12px; }
.msg .body { overflow-wrap: anywhere; }
.msg .body p { margin: 0 0 8px; }
.msg .body p:last-child { margin-bottom: 0; }
.msg .body ul, .msg .body ol { margin: 0 0 8px; padding-left: 22px; }
.msg .body code { font: 13px "Geist Mono", monospace; background: var(--s2); padding: 1px 5px; border-radius: 5px; }
.msg .body pre { font: 12.5px/1.5 "Geist Mono", monospace; background: var(--s1); border: 1px solid var(--line); padding: 10px 12px; border-radius: 10px; overflow-x: auto; margin: 0 0 8px; }
.msg .body pre code { background: none; padding: 0; }
.msg .body a { color: var(--remo); }
.msg .body h4 { margin: 10px 0 4px; font-size: 14px; }
.msg.bot .body { color: #d6d6d6; }
.msg.long .body { max-height: 340px; overflow: hidden; position: relative; }
.msg.long.open .body { max-height: none; }
.more { color: var(--mu); font-size: 13px; padding: 4px 0; }
.more:hover { color: var(--tx); }
.msg.system { text-align: center; color: var(--mu); font-size: 13px; padding: 6px 16px; }
.msg.system .body { display: inline; }
.msg.system.card { text-align: left; font-size: 14px; }
.msg.system.card .body { display: block; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; color: var(--mu); }
.msg.system.card .body strong { color: var(--tx); }
.msg.pending { opacity: .5; }

.imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.imgs img {
  height: 150px; max-width: 100%; border-radius: 8px; border: 1px solid var(--line);
  cursor: zoom-in; background: var(--s1); object-fit: contain;
}

.jump {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px;
  background: var(--s3); font-size: 13px; z-index: 5;
}
.jump svg.i { width: 14px; height: 14px; }

.composer { border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); }
.hint { color: var(--mu); font-size: 13px; padding: 0 4px 8px; max-width: 860px; margin: 0 auto; }
.hint.to-claude { color: var(--claude); }
.previews { display: flex; gap: 8px; flex-wrap: wrap; max-width: 860px; margin: 0 auto; }
.previews:not(:empty) { padding-bottom: 8px; }
.prev { position: relative; width: 64px; height: 64px; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); }
.prev img { width: 100%; height: 100%; object-fit: cover; }
.prev.busy img { opacity: .4; }
.prev button { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: #000c; display: grid; place-items: center; }
.prev button svg.i { width: 13px; height: 13px; }
.send-row { display: flex; align-items: flex-end; gap: 6px; max-width: 860px; margin: 0 auto; }
.send-row textarea {
  flex: 1; resize: none; max-height: 180px; padding: 9px 13px; font: 16px/1.4 "Geist", sans-serif;
  color: var(--tx); background: var(--s1); border: 1px solid var(--line); border-radius: 20px;
}
.send-row textarea:focus { outline: none; border-color: #3a3a3a; }
.send { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--tx); color: #000; flex: none; }
.send:disabled { background: var(--s3); color: var(--mu2); cursor: default; }
.send svg.i { width: 17px; height: 17px; }

.lightbox { position: fixed; inset: 0; background: #000e; display: grid; place-items: center; z-index: 20; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; }
.lightbox img.px { image-rendering: pixelated; }

@media (min-width: 700px) {
  .imgs img { height: 200px; }
}
