:root {
  color-scheme: dark;
  --bg: #0b0c0e;
  --surface: #17191d;
  --surface-2: #22252b;
  --line: #2e3238;
  --text: #eceef1;
  --muted: #9aa1ab;
  --accent: #4c8dff;
  --danger: #ff6b5e;
  --bar-h: 44px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
}

body { display: flex; flex-direction: column; }

[hidden] { display: none !important; }

.bar {
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: none;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
}
.pill-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.pill-scope { color: var(--muted); font-size: 13px; }

.spacer { flex: 1; }

.tool {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  position: relative;
}
.tool:hover:not(:disabled) { border-color: var(--muted); }
.tool:disabled { opacity: 0.45; cursor: default; }
.tool[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tool.leave { color: var(--danger); }

.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#picture {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#picture.controlling { cursor: default; }
#picture:not(.shown) { visibility: hidden; }

.keys {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
  resize: none;
  pointer-events: none;
}

.card {
  position: absolute;
  max-width: min(440px, calc(100% - 32px));
  padding: 20px 22px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: center;
}
.card-title { margin: 0 0 8px; font-weight: 600; }
.card-text { margin: 0; line-height: 1.45; }
.card-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

.chat {
  position: fixed;
  top: calc(var(--bar-h) + env(safe-area-inset-top));
  right: 0;
  bottom: 0;
  width: min(340px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; font-weight: 600; }
.chat-note { margin: 0 12px 8px; color: var(--muted); font-size: 12px; }
.chat-lines { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 0 12px; }
.chat-lines li { margin: 0 0 10px; line-height: 1.4; overflow-wrap: anywhere; }
.chat-lines .from { display: block; color: var(--muted); font-size: 12px; }
.chat-form { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
