/* Botley — "industrial Facebook": 2008-era Facebook blue/grey chrome,
   riveted panels and hazard-stripe accents for an industrial edge. */

:root {
  --fb-blue: #3b5998;
  --fb-blue-dark: #2d4373;
  --fb-blue-light: #8b9dc3;
  --steel-100: #f4f5f6;
  --steel-200: #e9ebee;
  --steel-300: #d8dfea;
  --steel-500: #8a97a0;
  --steel-700: #5c6770;
  --steel-900: #2b3136;
  --hazard-yellow: #f0b429;
  --ink: #1c2733;
  --white: #ffffff;
  --danger: #a4302a;
}

* { box-sizing: border-box; }

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

body {
  background: var(--steel-200)
    linear-gradient(135deg, rgba(0,0,0,0.02) 25%, transparent 25%) 0 0 / 24px 24px;
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
}

a { color: var(--fb-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- top bar --- */

.topbar {
  background: linear-gradient(180deg, var(--fb-blue) 0%, var(--fb-blue-dark) 100%);
  border-bottom: 3px solid var(--steel-900);
  box-shadow: 0 2px 0 var(--hazard-yellow) inset;
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-family: "Arial Narrow", Arial, sans-serif;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--white) !important;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-rivet {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hazard-yellow);
  box-shadow: 0 0 0 2px var(--fb-blue-dark);
  display: inline-block;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.whoami {
  color: var(--steel-200);
  font-size: 12px;
  letter-spacing: 0.5px;
}
.whoami strong { color: var(--white); }

/* --- buttons --- */

.btn {
  font-family: "Arial Narrow", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 1px;
  border: 1px solid var(--steel-900);
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 2px;
  transition: filter 0.1s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { filter: brightness(0.95); }

.btn-primary {
  background: linear-gradient(180deg, var(--fb-blue-light) 0%, var(--fb-blue) 100%);
  color: var(--white);
  border-color: var(--fb-blue-dark);
}

.btn-steel {
  background: linear-gradient(180deg, #fbfbfc 0%, var(--steel-300) 100%);
  color: var(--steel-900);
  border-color: var(--steel-500);
}

.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-block { width: 100%; }

.btn-x {
  border: none;
  background: transparent;
  color: var(--steel-500);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.btn-x:hover { color: var(--danger); }

.inline-form { display: inline; margin: 0; }

/* --- page shell --- */

.page {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
}

/* --- auth pages --- */

.auth-wrap {
  display: flex;
  justify-content: center;
  padding-top: 40px;
}

.auth-panel {
  width: 360px;
  background: var(--white);
  border: 1px solid var(--steel-500);
  border-top: 4px solid var(--hazard-yellow);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.auth-panel-header {
  background: var(--steel-900);
  color: var(--white);
  font-family: "Arial Narrow", Arial, sans-serif;
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 13px;
  padding: 10px 16px;
}

.auth-panel-body { padding: 20px; }

.auth-tagline {
  margin: 0 0 16px;
  color: var(--steel-700);
  font-size: 13px;
}

.stack-form { display: flex; flex-direction: column; gap: 4px; }

.stack-form label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--steel-700);
  margin-top: 10px;
}

.stack-form input {
  padding: 9px 10px;
  border: 1px solid var(--steel-500);
  border-radius: 2px;
  font-size: 14px;
  background: var(--steel-100);
}
.stack-form input:focus {
  outline: none;
  border-color: var(--fb-blue);
  background: var(--white);
  box-shadow: 0 0 0 2px var(--fb-blue-light);
}

.stack-form .btn { margin-top: 16px; }

.hint { font-size: 11px; color: var(--steel-500); margin: 6px 0 0; }

.auth-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--steel-300);
  font-size: 12px;
  text-align: center;
}

.alert {
  padding: 8px 12px;
  border-radius: 2px;
  font-size: 12px;
  margin-bottom: 12px;
}
.alert-error {
  background: #fbeceb;
  border: 1px solid var(--danger);
  color: var(--danger);
}

/* --- dashboard --- */

.dash {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  align-items: start;
}

.sidebar {
  background: var(--white);
  border: 1px solid var(--steel-500);
  border-top: 4px solid var(--steel-700);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--steel-200);
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--steel-700);
  border-bottom: 1px solid var(--steel-300);
}

.convo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 60vh;
  overflow-y: auto;
}

.convo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--steel-200);
  font-size: 13px;
}
.convo-item a {
  color: var(--ink);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.convo-item.active {
  background: var(--steel-200);
  border-left: 3px solid var(--fb-blue);
}
.convo-item.active a { color: var(--fb-blue-dark); font-weight: 700; }
.convo-empty { padding: 12px 10px; color: var(--steel-500); font-size: 12px; }

.chat-panel {
  background: var(--white);
  border: 1px solid var(--steel-500);
  border-top: 4px solid var(--fb-blue);
  display: flex;
  flex-direction: column;
  min-height: 65vh;
}

.chat-panel-header {
  background: var(--steel-200);
  padding: 10px 14px;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid var(--steel-300);
  background-image: repeating-linear-gradient(
    -45deg, transparent, transparent 8px, rgba(240,180,41,0.15) 8px, rgba(240,180,41,0.15) 16px
  );
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--steel-100);
}

.messages-empty {
  color: var(--steel-500);
  font-size: 13px;
  text-align: center;
  margin-top: 24px;
}

.bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid var(--steel-300);
}

.bubble-role {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 3px;
  opacity: 0.65;
}

.bubble-text { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; }

.bubble-user {
  align-self: flex-end;
  background: var(--fb-blue-light);
  color: var(--white);
  border-color: var(--fb-blue-dark);
}
.bubble-user .bubble-role { color: var(--steel-900); }

.bubble-assistant {
  align-self: flex-start;
  background: var(--white);
  border-left: 3px solid var(--steel-700);
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--steel-300);
  background: var(--steel-200);
}

.chat-form input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--steel-500);
  border-radius: 2px;
  font-size: 14px;
}
.chat-form input:focus {
  outline: none;
  border-color: var(--fb-blue);
  box-shadow: 0 0 0 2px var(--fb-blue-light);
}

@media (max-width: 720px) {
  .dash { grid-template-columns: 1fr; }
}

/* --- api tokens --- */

.settings-wrap {
  display: flex;
  justify-content: center;
  padding-top: 24px;
}

.token-panel { width: 640px; max-width: 100%; }

.token-reveal {
  background: #fff8e6;
  border: 1px solid var(--hazard-yellow);
  border-radius: 2px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.token-reveal-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--steel-700);
  margin-bottom: 6px;
}

.token-reveal-value {
  display: block;
  font-family: "Courier New", monospace;
  font-size: 13px;
  word-break: break-all;
  color: var(--ink);
}

.token-form { margin-bottom: 20px; }

.token-list {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.token-list th {
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--steel-700);
  background: var(--steel-200);
  padding: 8px 10px;
  border-bottom: 1px solid var(--steel-300);
}

.token-list td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--steel-200);
}

.token-list code {
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.token-empty {
  text-align: center;
  color: var(--steel-500);
  padding: 16px 10px !important;
}
