/* ─── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }

/* ─── Login page ────────────────────────────────────────────────── */
.login-bg {
  background: #008080;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-window { width: 340px; }

.login-body { padding: 10px 14px 14px; }

.login-icon-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #808080;
}

.login-form { display: flex; flex-direction: column; gap: 0; }

.login-form .field-row-stacked label { font-size: 11px; margin-bottom: 2px; }

.login-form .field-row-stacked input { width: 100%; }

.login-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.error-banner {
  background: #fff;
  border: 2px inset #d4d0c8;
  color: #c00;
  font-size: 11px;
  padding: 4px 8px;
  margin-bottom: 10px;
}

/* ─── Chat page shell ───────────────────────────────────────────── */
.chat-bg {
  background: #008080;
  padding: 6px;
  min-height: 100vh;
}

.app-window {
  height: calc(100vh - 12px);
  display: flex;
  flex-direction: column;
  min-width: 600px;
}

/* 98.css sets window-body padding — override to control layout */
.app-window > .window-body.app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 4px;
  overflow: hidden;
  margin: 0;
}

/* ─── Toolbar ───────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px;
  border-bottom: 1px solid #808080;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.online-pill {
  font-size: 11px;
  padding: 2px 8px;
  border: 2px inset #d4d0c8;
  background: #d4d0c8;
  white-space: nowrap;
}

/* ─── Two-panel layout ──────────────────────────────────────────── */
.panels {
  flex: 1;
  display: flex;
  gap: 0;
  overflow: hidden;
  min-height: 0;
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0;
  min-width: 0;
  overflow: hidden;
}

/* Fieldset legend padding fix for 98.css */
.panel legend { padding: 0 4px; font-size: 11px; }

.panel-splitter {
  width: 6px;
  flex-shrink: 0;
  border-left: 2px solid #808080;
  border-right: 2px solid #fff;
  background: #d4d0c8;
}

/* ─── Message area ──────────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  background: #fff;
  border: 2px inset #d4d0c8;
  padding: 6px;
  margin-bottom: 6px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
  min-height: 0;
}

/* ─── Input rows ────────────────────────────────────────────────── */
.send-row {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.send-row input { flex: 1; min-width: 0; }

.model-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.model-row select { flex: 1; min-width: 0; }

/* ─── Message bubbles ───────────────────────────────────────────── */
.msg { margin-bottom: 5px; }

.msg .who  { font-weight: bold; }
.msg .body { }

/* Friend chat colours */
.msg-friend .who { color: #000080; }
.msg-own    .who { color: #800000; }
.msg-system     { color: #808080; font-style: italic; }

/* AI chat colours */
.msg-ai-user .who  { color: #000080; }
.msg-ai-self .who  { color: #800000; }
.msg-ai-resp .who  { color: #006400; }

/* Streaming cursor */
.msg-ai-resp.streaming .body::after {
  content: '▋';
  animation: blink 0.7s step-end infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.msg-error .who  { color: #c00; }
.msg-error .body { color: #c00; }

/* ─── Status bar ────────────────────────────────────────────────── */
.status-bar { flex-shrink: 0; }
.status-bar .status-bar-field { font-size: 11px; }

/* ─── API Keys modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.keys-modal { width: 380px; }

.key-input-row {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.key-input-row input { flex: 1; min-width: 0; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
