@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,600;0,9..40,700;1,9..40,400&display=swap");

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --elevated: #1a1a26;
  --border: #2a2a3a;
  --text: #e8e8ed;
  --muted: #9898a8;
  --accent: #00d4aa;
  --accent-dim: #00a884;
  --danger: #ff5c5c;
  --radius: 12px;
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

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

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.logo span {
  color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover {
  border-color: var(--accent);
  background: rgba(0, 212, 170, 0.08);
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-color: transparent;
  color: #0a0a0f;
}
.btn-primary:hover {
  filter: brightness(1.08);
}
.btn-ghost {
  background: transparent;
}
.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

input,
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}
textarea {
  min-height: 120px;
  resize: vertical;
}
label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.field {
  margin-bottom: 1rem;
}

.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}
.hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin: 0 0 0.75rem;
  letter-spacing: -0.03em;
}
.hero p {
  color: var(--muted);
  max-width: 520px;
  margin: 0 auto 1.5rem;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
}

.layout-app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 57px);
}
@media (max-width: 900px) {
  .layout-app {
    grid-template-columns: 1fr;
  }
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem;
}
.sidebar h3 {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.chat-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.chat-list li.chat-row {
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 8px;
  padding: 0.15rem 0.35rem 0.15rem 0;
}
.chat-list li.chat-row:hover {
  background: rgba(255, 255, 255, 0.03);
}
.chat-list .chat-link {
  flex: 1;
  min-width: 0;
  display: block;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-list .chat-link:hover,
.chat-list .chat-link.active {
  background: var(--elevated);
  color: var(--accent);
}
.chat-actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.15rem;
}
.chat-actions .btn-icon {
  padding: 0.25rem 0.45rem;
  font-size: 0.85rem;
  line-height: 1;
  min-width: auto;
}
.chat-header-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.chat-header-bar label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.chat-main {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 57px);
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.bubble {
  max-width: min(92%, 640px);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.92rem;
}
.bubble.user {
  align-self: flex-end;
  background: var(--elevated);
  border: 1px solid var(--border);
}
.bubble.assistant {
  align-self: flex-start;
  background: rgba(0, 212, 170, 0.08);
  border: 1px solid rgba(0, 212, 170, 0.25);
}

.composer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  background: var(--bg);
}
.composer textarea {
  flex: 1;
  min-height: 48px;
  max-height: 160px;
}

.usage-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.35rem;
}
.usage-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dim));
  border-radius: 99px;
  transition: width 0.3s ease;
}

.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
th,
td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
