:root {
  --brand: #5b5bd6;
  --brand-dark: #4444b3;
  --bg: #fafafa;
  --card: #ffffff;
  --border: #e5e5ee;
  --text: #1a1a2e;
  --muted: #6b6b80;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.nav .logo { font-weight: 700; font-size: 18px; }
.nav .logo span { color: var(--brand); }

.nav-links { display: flex; gap: 20px; align-items: center; }

.btn {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn.secondary:hover { background: #f0f0fb; }
.btn.danger { background: #d64545; }
.btn.danger:hover { background: #b33636; }
.btn:disabled { opacity: .6; cursor: default; }

.hero {
  max-width: 780px;
  margin: 80px auto;
  text-align: center;
  padding: 0 20px;
}
.hero h1 { font-size: 44px; line-height: 1.15; margin-bottom: 16px; }
.hero p { font-size: 18px; color: var(--muted); margin-bottom: 32px; }

.features {
  max-width: 960px;
  margin: 0 auto 80px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding: 0 20px;
}
.feature { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.feature h3 { margin: 0 0 8px; font-size: 16px; }
.feature p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.auth-wrap {
  max-width: 380px;
  margin: 80px auto;
  padding: 32px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.auth-wrap h1 { font-size: 22px; margin-bottom: 4px; }
.auth-wrap p.sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--brand); }

.error-box { background: #fdeaea; color: #b33636; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; display: none; }
.error-box.show { display: block; }

.container { max-width: 1080px; margin: 0 auto; padding: 32px 24px; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h1 { font-size: 24px; margin: 0; }

.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.bot-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px;
  cursor: pointer; transition: box-shadow .1s ease, border-color .1s ease;
}
.bot-card:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.bot-card h3 { margin: 0 0 6px; font-size: 16px; }
.bot-card .swatch { width: 20px; height: 20px; border-radius: 6px; display: inline-block; margin-bottom: 10px; }
.bot-card .meta { color: var(--muted); font-size: 12px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab, .subtab { padding: 10px 16px; cursor: pointer; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.active, .subtab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 24px; margin-bottom: 20px; }
.card h2 { font-size: 16px; margin: 0 0 16px; }

.doc-list { display: flex; flex-direction: column; gap: 10px; }
.doc-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; }
.doc-item .title { font-weight: 600; font-size: 14px; }
.doc-item .meta { color: var(--muted); font-size: 12px; }

.snippet {
  background: #1a1a2e; color: #d8d8ff; padding: 16px; border-radius: 8px; font-size: 13px;
  overflow-x: auto; white-space: pre; font-family: 'Courier New', monospace;
}

.usage-bar-track { width: 100%; height: 10px; border-radius: 6px; background: #eee; overflow: hidden; }
.usage-bar-fill { height: 100%; background: var(--brand); border-radius: 6px; transition: width .2s ease; }
.usage-bar-fill.over { background: #d64545; }

.conv-list { display: flex; flex-direction: column; gap: 8px; }
.conv-item { padding: 14px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.conv-item:hover { border-color: var(--brand); }
.conv-item .meta { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.conv-item .preview { font-size: 14px; }

.msg-thread { display: flex; flex-direction: column; gap: 10px; max-height: 500px; overflow-y: auto; }
.msg-bubble { max-width: 75%; padding: 10px 14px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; }
.msg-bubble.user { align-self: flex-end; background: var(--brand); color: #fff; }
.msg-bubble.assistant { align-self: flex-start; background: #f0f0f5; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }

.color-row { display: flex; gap: 10px; align-items: center; }
.color-row input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; }

.muted { color: var(--muted); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
