:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #0f766e;
  --border: #d1d5db;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, #ecfeff, #f8fafc 45%, #eef2ff);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  min-height: 100vh;
}

.container {
  max-width: 760px;
  margin: 40px auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 15px 45px rgba(2, 6, 23, 0.08);
}

header h1 {
  margin: 0;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: #f8fafc;
}

.lang-switch a {
  padding: 6px 10px;
  text-decoration: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.lang-switch a + a {
  border-left: 1px solid var(--border);
}

.lang-switch a.active {
  background: var(--primary);
  color: #ffffff;
}

header p {
  margin-top: 8px;
  color: var(--muted);
}

.chat-log {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  min-height: 380px;
  max-height: 52vh;
  overflow-y: auto;
  background: #fafafa;
}

.message {
  margin: 10px 0;
  display: flex;
}

.message .bubble {
  padding: 10px 12px;
  border-radius: 12px;
  max-width: 80%;
  line-height: 1.4;
}

.message.user {
  justify-content: flex-end;
}

.message.user .bubble {
  background: #ccfbf1;
}

.message.bot .bubble {
  background: #f3f4f6;
}

.message .bubble code {
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 6px;
  padding: 2px 6px;
}

.message .bubble pre {
  overflow-x: auto;
  margin: 8px 0;
  padding: 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.08);
}

.message .bubble pre code {
  padding: 0;
  background: transparent;
}

.message .bubble a {
  color: #0f766e;
}

.message .bubble p {
  margin: 0 0 10px;
}

.message .bubble p:last-child {
  margin-bottom: 0;
}

.message .bubble h1,
.message .bubble h2,
.message .bubble h3,
.message .bubble h4,
.message .bubble h5,
.message .bubble h6 {
  margin: 10px 0 8px;
  line-height: 1.25;
}

.message .bubble ul,
.message .bubble ol {
  margin: 8px 0 10px;
  padding-left: 22px;
}

.message .bubble li + li {
  margin-top: 4px;
}

.message .bubble blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid #0f766e;
  background: rgba(15, 118, 110, 0.08);
  border-radius: 6px;
}

.message .bubble hr {
  border: 0;
  border-top: 1px solid rgba(15, 23, 42, 0.2);
  margin: 12px 0;
}

.message .bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  display: block;
  overflow-x: auto;
}

.message .bubble th,
.message .bubble td {
  border: 1px solid rgba(15, 23, 42, 0.15);
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
}

.message .bubble th {
  background: rgba(15, 23, 42, 0.08);
}

.chat-form {
  margin-top: 14px;
  display: flex;
  gap: 10px;
}

.chat-form input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
}

.chat-form button {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  color: white;
  background: var(--primary);
  cursor: pointer;
}

@media (max-width: 700px) {
  .header-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .container {
    margin: 14px;
    padding: 16px;
  }

  .chat-log {
    min-height: 58vh;
  }
}
