/* Chat space — ai.rur1.com/chat/ (light). */

html,
body {
  height: 100%;
}
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* header controls */
.chat-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.toggle input {
  appearance: none;
  width: 2.125rem;
  height: 1.25rem;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background 160ms var(--ease-site);
  margin: 0;
}
.toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(11, 14, 20, 0.2);
  transition: transform 160ms var(--ease-site);
}
.toggle input:checked {
  background: var(--accent-ink);
}
.toggle input:checked::after {
  transform: translateX(0.875rem);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-button);
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: color 160ms var(--ease-site), border-color 160ms var(--ease-site);
}
.icon-btn:hover {
  color: var(--fg);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}

/* ---------- messages ---------- */
.chat-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.thread {
  max-width: 50rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* empty state */
.empty-state {
  margin: 12vh auto 0;
  text-align: center;
  max-width: 34rem;
}
.empty-state img {
  width: 3.5rem;
  height: auto;
  margin: 0 auto 1rem;
}
.empty-state h1 {
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}
.empty-state p {
  color: var(--muted);
  font-size: 0.9375rem;
  margin: 0 0 1.5rem;
}
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}
.suggestion {
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font-size: 0.8425rem;
  cursor: pointer;
  transition: border-color 160ms var(--ease-site), color 160ms var(--ease-site);
}
.suggestion:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  color: var(--fg);
}

/* message rows */
.msg {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.msg .who {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}
.msg.user {
  align-items: flex-end;
}
.msg.user .bubble {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-radius: var(--radius-card);
  border-bottom-right-radius: 4px;
  max-width: 85%;
}
.msg.assistant .bubble {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  border-bottom-left-radius: 4px;
  max-width: 100%;
}
.bubble {
  padding: 0.8rem 1.05rem;
  font-size: 0.9575rem;
  overflow-wrap: break-word;
}
.bubble > *:first-child {
  margin-top: 0;
}
.bubble > *:last-child {
  margin-bottom: 0;
}
.bubble .attach-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.bubble .attach-row img {
  width: 6.5rem;
  height: 6.5rem;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* markdown-ish content */
.bubble p {
  margin: 0.6em 0;
}
.bubble h1,
.bubble h2,
.bubble h3 {
  font-size: 1.05em;
  margin: 0.9em 0 0.4em;
}
.bubble ul,
.bubble ol {
  margin: 0.5em 0;
  padding-left: 1.4em;
}
.bubble li {
  margin: 0.25em 0;
}
.bubble code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1em 0.4em;
}
.bubble pre {
  background: #0e1116;
  color: #e8ecf3;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.55;
}
.bubble pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.bubble blockquote {
  margin: 0.6em 0;
  padding: 0.1em 0 0.1em 0.9em;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.bubble table {
  border-collapse: collapse;
  margin: 0.6em 0;
  font-size: 0.875em;
  display: block;
  overflow-x: auto;
}
.bubble th,
.bubble td {
  border: 1px solid var(--border);
  padding: 0.35em 0.7em;
  text-align: left;
}
.bubble th {
  background: var(--surface);
}
.bubble a {
  word-break: break-all;
}

/* reasoning fold */
.reasoning {
  border: 1px dashed var(--border);
  border-radius: var(--radius-button);
  background: var(--surface);
  margin-bottom: 0.625rem;
  font-size: 0.845rem;
  color: var(--muted);
}
.reasoning summary {
  cursor: pointer;
  padding: 0.5rem 0.875rem;
  font-weight: 500;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.reasoning summary::-webkit-details-marker {
  display: none;
}
.reasoning summary::before {
  content: "▸";
  transition: transform 160ms var(--ease-site);
}
.reasoning[open] summary::before {
  transform: rotate(90deg);
}
.reasoning .r-body {
  padding: 0 0.875rem 0.75rem;
  white-space: pre-wrap;
  max-height: 18rem;
  overflow-y: auto;
}
.thinking-pulse {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

/* error bubble */
.msg .error {
  border-color: #e5484d55;
  background: #fff5f5;
  color: #b3261e;
}

/* ---------- composer ---------- */
.composer-wrap {
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  padding: 0.875rem 1.25rem calc(0.875rem + env(safe-area-inset-bottom));
}
.composer {
  max-width: 50rem;
  margin: 0 auto;
}
.attach-preview {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.attach-preview .thumb {
  position: relative;
}
.attach-preview img {
  width: 3.75rem;
  height: 3.75rem;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.attach-preview .rm {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
}
.composer .box {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--elevated);
  padding: 0.5rem 0.5rem 0.5rem 0.875rem;
  box-shadow: var(--shadow);
  transition: border-color 160ms var(--ease-site);
}
.composer .box:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}
.composer textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 0.9575rem;
  line-height: 1.55;
  max-height: 11rem;
  padding: 0.35rem 0;
}
.composer .send {
  flex: none;
  width: 2.375rem;
  height: 2.375rem;
  border-radius: var(--radius-button);
  border: none;
  background: var(--accent-ink);
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms var(--ease-site);
}
.composer .send:hover {
  background: #2452c8;
}
.composer .send:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}
.composer .send.stop {
  background: #b3261e;
}
.composer .attach {
  flex: none;
  width: 2.375rem;
  height: 2.375rem;
  border-radius: var(--radius-button);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.composer .attach:hover {
  color: var(--accent-ink);
  background: var(--accent-soft);
}
.composer .hint {
  margin: 0.55rem 0.25rem 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}
