:root {
  color-scheme: dark;
  --background: #141414;
  --surface: #1f1f1f;
  --surface-muted: #262626;
  --border: #464646;
  --border-subtle: #343434;
  --text: #f2f2f2;
  --text-muted: #b5b5b5;
  --button: #8a8a8a;
  --button-hover: #b8b8b8;
  --on-button: #111111;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--background);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 0;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
  background: var(--surface);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 4px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.bar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status.ok {
  color: var(--text);
}

.status.warn {
  color: var(--text-muted);
}

.gate {
  margin: 16px 4px 0;
  padding: 14px 16px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.gate-text {
  margin: 0;
  font-size: 14px;
}

.gate-action {
  margin: 10px 0 0;
}

.gate-link {
  display: inline-block;
  padding: 9px 14px;
  background: var(--button);
  border-radius: 8px;
  color: var(--on-button);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.gate-link:hover {
  background: var(--button-hover);
}

.gate-link[hidden] {
  display: none;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 4px;
  scrollbar-color: var(--border) transparent;
  scrollbar-width: thin;
}

.line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  margin: 0 0 10px;
  padding: 12px 14px;
  background: var(--surface-muted);
  border-radius: 12px;
  overflow-wrap: anywhere;
}

.line .meta {
  grid-column: 2;
  grid-row: 1;
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.line .body {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
}

.line.chat strong {
  grid-column: 1;
  grid-row: 1;
  font-weight: 600;
}

.line.system {
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

.line.system .body {
  grid-column: 1;
  grid-row: 1;
}

.notice {
  margin: 0 4px 10px;
  padding: 10px 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}

.composer {
  flex: 0 0 auto;
  padding: 12px 0 max(16px, env(safe-area-inset-bottom));
  background: var(--surface);
}

.composer-field {
  display: flex;
  height: 52px;
  align-items: center;
  padding: 4px;
  background: var(--surface-muted);
  border-radius: 26px;
}

.composer .text {
  flex: 1;
  width: auto;
  min-width: 0;
  height: 44px;
  padding: 10px 14px;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 24px;
}

.composer .text::placeholder {
  color: var(--text-muted);
}

.composer .text:focus {
  outline: none;
}

.composer .send {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--on-button);
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 120ms ease;
}

.composer .send::before {
  position: absolute;
  inset: 4px;
  background: var(--text);
  border-radius: 50%;
  content: "";
}

.composer .send:hover {
  opacity: 0.82;
}

.composer .send:active {
  opacity: 0.65;
}

.composer .send svg {
  position: relative;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.composer .send:focus-visible,
.gate-link:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  #app {
    padding: 0 12px;
  }

  .bar {
    padding-top: 14px;
  }

  .messages {
    padding-top: 14px;
  }
}
