* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  color: #2c2c2c;
  background: #f3f4f6;
  -webkit-font-smoothing: antialiased;
}

a { color: #06c755; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Login ---------- */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-box {
  background: white; padding: 36px;
  border-radius: 10px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.06);
  width: 320px;
}
.login-box h1 { margin-bottom: 20px; font-size: 18px; font-weight: 600; color: #2c2c2c; }
.login-box input {
  width: 100%; padding: 11px 12px;
  border: 1px solid #e0e0e0; border-radius: 6px;
  font-size: 14px; margin-bottom: 14px;
}
.login-box input:focus { outline: none; border-color: #06c755; }
.login-box button {
  width: 100%; padding: 11px;
  background: #06c755; color: white; border: 0; border-radius: 6px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.login-box button:hover { background: #05b04c; }
.login-box .error {
  color: #c53030; font-size: 13px; margin-bottom: 12px; text-align: center;
}

/* ---------- App shell ---------- */
.app {
  display: flex; flex-direction: column;
  height: 100vh;
  max-width: 760px; margin: 0 auto;
  background: white;
  border-left: 1px solid #ececec; border-right: 1px solid #ececec;
}

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #ececec;
  background: white;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 15px; font-weight: 700; color: #2c2c2c; }
.topbar .status {
  font-size: 11px; color: #777;
  background: #f3f4f6; padding: 4px 9px; border-radius: 12px;
  white-space: nowrap;
}
.topbar .status.ok { background: #e6f9ed; color: #04a847; }
.topbar .status.error { background: #fde8e8; color: #c53030; }
.topbar .spacer { flex: 1; }
.topbar input[type=search] {
  flex: 1; min-width: 120px;
  padding: 7px 12px;
  border: 1px solid #e0e0e0; border-radius: 16px;
  font-size: 13px; background: #f8f8f8;
}
.topbar input[type=search]:focus { outline: none; border-color: #06c755; background: white; }
.topbar button, .topbar .link {
  padding: 6px 11px;
  border: 1px solid #e0e0e0; background: white; border-radius: 5px;
  font-size: 12px; cursor: pointer; color: #555;
  font-family: inherit;
}
.topbar button:hover, .topbar .link:hover { background: #f5f5f5; }
.topbar button:disabled { opacity: 0.5; cursor: not-allowed; }
.topbar form { display: inline; }

/* ---------- Chat list ---------- */
.chat-list { flex: 1; overflow-y: auto; background: white; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #f3f3f3;
  cursor: pointer;
}
.row:hover { background: #fafafa; }
.row:hover .copy-btn { opacity: 1; }

.avatar {
  flex: 0 0 48px; height: 48px;
  border-radius: 50%; overflow: hidden;
  background: #e8e8e8;
  display: flex; align-items: center; justify-content: center;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #06c755 0%, #00adf1 100%);
  color: white; font-weight: 600; font-size: 18px;
}

.meta { flex: 1; min-width: 0; }
.line1 {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 2px;
}
.name {
  font-weight: 600; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #2c2c2c;
  flex: 1;
}
.time { font-size: 11px; color: #999; flex: 0 0 auto; }
.line2 {
  font-size: 13px; color: #777;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.copy-btn {
  flex: 0 0 auto;
  padding: 5px 11px;
  border: 1px solid #e0e0e0; background: white; border-radius: 4px;
  font-size: 12px; cursor: pointer; color: #555;
  opacity: 0.4;
  transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.copy-btn:hover { background: #06c755; color: white; border-color: #06c755; }

.empty {
  padding: 60px 24px; text-align: center; color: #999;
  font-size: 14px; line-height: 1.6;
}
.empty a { display: inline-block; margin-top: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #2c2c2c; color: white;
  padding: 10px 18px; border-radius: 6px;
  font-size: 13px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  max-width: 90vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toast.show { opacity: 1; }

/* ---------- Setup page ---------- */
.setup-page {
  max-width: 720px; margin: 0 auto;
  padding: 24px;
  background: white; min-height: 100vh;
}
.setup-page header {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 14px; margin-bottom: 22px;
  border-bottom: 1px solid #ececec;
}
.setup-page header h1 { font-size: 18px; font-weight: 600; }
.setup-page .instructions {
  background: #f8f9fa; border-radius: 6px; padding: 16px 16px 16px 36px;
  margin-bottom: 22px; font-size: 13px; line-height: 1.7;
}
.setup-page .instructions li { margin-bottom: 4px; }
.setup-page code {
  background: #ececec; padding: 1px 5px; border-radius: 3px;
  font-size: 12px; font-family: 'SF Mono', Menlo, Monaco, monospace;
}
.setup-page label {
  display: block; margin-bottom: 14px;
  font-size: 13px; color: #555; font-weight: 500;
}
.setup-page label small {
  font-weight: normal; color: #888; margin-left: 6px;
}
.setup-page input, .setup-page textarea {
  display: block; width: 100%; margin-top: 5px;
  padding: 9px 11px;
  border: 1px solid #e0e0e0; border-radius: 5px;
  font-size: 12px;
  font-family: 'SF Mono', Menlo, Monaco, monospace;
}
.setup-page input:focus, .setup-page textarea:focus { outline: none; border-color: #06c755; }
.setup-page textarea { resize: vertical; }
.setup-page .btn-row { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.setup-page button {
  padding: 10px 20px;
  background: #06c755; color: white; border: 0; border-radius: 5px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  font-family: inherit;
}
.setup-page button:hover { background: #05b04c; }
.setup-page button.secondary { background: white; color: #555; border: 1px solid #e0e0e0; }
.setup-page button.secondary:hover { background: #f5f5f5; }
.setup-page #result {
  margin-top: 14px; padding: 11px 14px;
  border-radius: 5px; font-size: 13px; line-height: 1.5;
  display: none;
}
.setup-page #result.show { display: block; }
.setup-page #result.success { background: #e6f9ed; color: #04a847; }
.setup-page #result.error { background: #fde8e8; color: #c53030; }
.setup-page .extracted {
  background: #fffbe6; border: 1px solid #ffe58f;
  padding: 10px 12px; border-radius: 5px;
  font-size: 12px; margin-bottom: 14px;
  font-family: 'SF Mono', Menlo, monospace;
  display: none;
}
.setup-page .extracted.show { display: block; }
.setup-page .extracted strong { font-family: inherit; }
