﻿:root {
  --bg: linear-gradient(180deg, #f3f4f6 0%, #ffffff 100%);
  --panel: #ffffff;
  --panel-border: #e5e7eb;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --bot-bg: #f8fafc;
  --bot-border: #e2e8f0;
  --user-gradient-start: #2563eb;
  --user-gradient-end: #4f46e5;
  --divider: rgba(148, 163, 184, 0.4);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text-primary);
  font: 15px/1.6 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 40px;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.header-icon {
  color: var(--accent);
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.warn {
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid rgba(37, 99, 235, 0.2);
  color: var(--accent);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin: 16px;
}

#log {
  height: 60vh;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 24px 12px;
  overflow-y: auto;
  scroll-behavior: smooth;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.6), rgba(255, 255, 255, 0.8));
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 70%;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.msg.bot {
  align-self: flex-start;
  background: var(--bot-bg);
  border: 1px solid var(--bot-border);
  color: var(--text-primary);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.msg.you {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--user-gradient-start), var(--user-gradient-end));
  color: #fff;
  box-shadow: 0 16px 30px rgba(79, 70, 229, 0.25);
}

.msg.error {
  align-self: center;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #991b1b;
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg.you .msg-header {
  justify-content: flex-end;
}

.msg.bot .msg-header {
  justify-content: flex-start;
}

.msg .who {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

.msg.you .who { display: none; }

.msg .bot-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.msg .text {
  line-height: 1.7;
  color: inherit;
}

.msg.you .text {
  text-align: right;
}

.msg-footer {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.msg-divider {
  width: 100%;
  height: 1px;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent 0%, var(--divider) 45%, var(--divider) 55%, transparent 100%);
}

.msg-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.msg-time {
  font-size: 12px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: rgba(148, 163, 184, 0.18);
}

.msg.you .msg-time {
  background: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.85);
}

.msg-action {
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.85);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.12);
}

.msg-action svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.msg-action:hover {
  background: var(--accent);
  color: #fff;
}

.msg-action:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.5);
  outline-offset: 2px;
}

.msg-action.active,
.msg-action.copied {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.25);
}

.ask {
  display: flex;
  gap: 12px;
  padding: 16px 18px 18px;
  border-top: 1px solid var(--panel-border);
  background: #f9fafb;
}

.ask input[type="text"] {
  flex: 1;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #fff;
  color: var(--text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ask input[type="text"]::placeholder {
  color: rgba(107, 114, 128, 0.6);
}

.ask input[type="text"]:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.6);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.ask button {
  padding: 0 22px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
}

.ask button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(37, 99, 235, 0.35);
}

.ask button:active {
  transform: translateY(0);
}

.ask button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.loader {
  padding: 20px 24px;
  text-align: center;
  border-top: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: #f9fafb;
}

.loader-text {
  color: var(--text-secondary);
  font-size: 14px;
}

.progress-bar {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: rgba(226, 232, 240, 0.7);
  overflow: hidden;
}

.progress-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 35%;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.9), rgba(79, 70, 229, 0.9));
  animation: progress-indeterminate 1.3s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(229, 231, 235, 0.6);
}

::-webkit-scrollbar-thumb {
  background: rgba(37, 99, 235, 0.35);
  border-radius: 20px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(37, 99, 235, 0.55);
}


.msg .text h1,
.msg .text h2,
.msg .text h3,
.msg .text h4,
.msg .text h5,
.msg .text h6 {
  margin: 0 0 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.msg .text h1 { font-size: 1.6rem; }
.msg .text h2 { font-size: 1.45rem; }
.msg .text h3 { font-size: 1.3rem; }
.msg .text h4 { font-size: 1.15rem; }
.msg .text h5 { font-size: 1.05rem; }
.msg .text h6 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em; }

.msg .text p { margin: 0 0 12px; }

.msg .text ol,
.msg .text ul {
  margin: 0 0 12px 18px;
  padding-left: 12px;
}

.msg .text li { margin-bottom: 6px; }

.msg .text a {
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 500;
}

.msg .text a:hover {
  text-decoration: underline;
}

.msg .text code {
  background: rgba(37, 99, 235, 0.12);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.92em;
}

.msg.you .text code {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.msg .text pre {
  background: rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.92em;
  margin: 0 0 14px;
}

.msg.you .text pre {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.9);
}

.msg .text blockquote {
  margin: 0 0 12px;
  padding-left: 14px;
  border-left: 3px solid var(--accent);
  color: var(--text-secondary);
}

.msg.you .text blockquote {
  border-left-color: rgba(255, 255, 255, 0.6);
  color: rgba(255, 255, 255, 0.85);
}
