@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@400;500;600;700&family=Work+Sans:wght@400;500;600&display=swap');

:root {
  --bg-main: #f3f4f6;
  --bg-panel: #ffffff;
  --bg-muted: #f8fafc;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e0e7ff;
  --border: #e2e8f0;
  --border-strong: #cbd5f5;
  --success: #22c55e;
  --warning: #f97316;
  --error: #ef4444;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.12);
  --shadow-md: 0 12px 28px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 6px 16px rgba(15, 23, 42, 0.08);
  --transition: 0.2s ease;
  --font-display: 'Bricolage Grotesque', sans-serif;
  --font-body: 'Work Sans', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--text-main);
  background: radial-gradient(circle at top left, #e7efff 0%, transparent 45%),
    radial-gradient(circle at 20% 80%, #fff2df 0%, transparent 55%), var(--bg-main);
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

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

.brand__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  box-shadow: 0 0 0 6px var(--primary-soft);
}

.brand__title {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-display);
}

.brand__subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.model-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.model-select select {
  min-width: 160px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.secondary {
  background: #f1f5f9;
  color: var(--text-main);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.icon {
  padding: 6px 10px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: none;
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  padding: 24px 28px 32px;
  flex: 1;
}

.sidebar {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: var(--shadow-md);
  animation: rise-in 0.5s ease;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 6px;
}

.chat-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--bg-muted);
  cursor: pointer;
  transition: border var(--transition), background var(--transition);
}

.chat-item:hover {
  border-color: var(--border);
  background: #eef2ff;
}

.chat-item.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.chat-title {
  font-weight: 600;
  font-size: 14px;
  font-family: var(--font-display);
}

.chat-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.file-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-form input[type='file'] {
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: #f8fafc;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.file-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: rise-in 0.6s ease;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #ffffff, #f8fafc);
}

.chat-header .chat-title {
  font-size: 16px;
}

.chat-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 600;
}

.status {
  margin: 12px 22px 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  border: 1px solid transparent;
}

.status--info {
  background: #f8fafc;
  color: var(--text-muted);
  border-color: var(--border);
}

.status--error {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.messages {
  flex: 1;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 76%;
}

.message--user {
  align-self: flex-end;
  text-align: right;
}

.message--assistant {
  align-self: flex-start;
}

.message-bubble {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--border);
  line-height: 1.5;
  white-space: pre-wrap;
}

.message--event {
  max-width: 90%;
}

.message-bubble--event {
  background: #fff7ed;
  border-color: #fed7aa;
}

.event-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.event-text {
  font-size: 13px;
  line-height: 1.4;
}

.event-text--muted {
  color: var(--text-muted);
  margin-top: 4px;
}

.event-code {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  overflow-x: auto;
}

.event-list {
  margin: 8px 0 0;
  padding-left: 18px;
}

.event-link {
  color: var(--primary);
  text-decoration: none;
}

.event-link:hover {
  text-decoration: underline;
}

.message--user .message-bubble {
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  color: #ffffff;
  border: none;
}

.message-meta {
  font-size: 11px;
  color: var(--text-soft);
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-main);
  font-family: var(--font-display);
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--border);
  background: #ffffff;
}

.composer-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.composer-row {
  display: flex;
  gap: 12px;
}

.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  resize: none;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #f8fafc;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: rise-in 0.7s ease;
}

.auth-card h1 {
  margin: 0;
  font-size: 24px;
  font-family: var(--font-display);
}

.auth-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.auth-form input {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #f8fafc;
}

.auth-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.auth-toggle button {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}

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

  .sidebar {
    order: 2;
  }

  .chat-panel {
    order: 1;
  }
}

@media (max-width: 720px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .composer {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-row {
    flex-direction: column;
  }

  .message {
    max-width: 100%;
  }
}
