:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --border: #e3e3de;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --user-bg: #2f5bea;
  --user-text: #ffffff;
  --bot-bg: #efefea;
  --danger: #c0392b;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131312;
    --surface: #1c1c1a;
    --text: #ecece8;
    --muted: #9a9a93;
    --border: #2d2d2a;
    --accent: #6b8cff;
    --accent-text: #0e0e0d;
    --user-bg: #3d5fd9;
    --user-text: #ffffff;
    --bot-bg: #262624;
    --danger: #ff7b6b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
nav { display: flex; gap: 4px; overflow-x: auto; }
nav a {
  text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px;
  font-size: 14px; white-space: nowrap;
}
nav a:hover { color: var(--text); background: var(--bot-bg); }
nav a.active { color: var(--text); background: var(--bot-bg); font-weight: 600; }

/* generic */
main { padding: 28px 0 56px; }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 24px; max-width: 60ch; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tile { text-decoration: none; color: inherit; display: block; transition: transform .12s, border-color .12s; }
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile .emoji { font-size: 26px; }
.tile h3 { margin: 8px 0 4px; font-size: 16px; }
.tile p { margin: 0; color: var(--muted); font-size: 14px; }
.badge {
  display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--bot-bg); color: var(--muted); margin-top: 10px;
}
.hero { padding: 28px 0 8px; }
.hero h1 { font-size: 36px; }
.privacy { margin-top: 28px; color: var(--muted); font-size: 14px; }

button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 10px; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.primary:hover { opacity: .92; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.danger { color: var(--danger); }
input[type=text], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > button, .row > .btn { flex: 0 0 auto; }
.stack > * + * { margin-top: 14px; }
.muted { color: var(--muted); font-size: 14px; }
.notice {
  border: 1px solid var(--border); background: var(--bot-bg);
  padding: 12px 14px; border-radius: 10px; font-size: 14px;
}
.notice.warn { border-color: var(--danger); }

.drop {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px;
  text-align: center; color: var(--muted); cursor: pointer;
}
.drop.over { border-color: var(--accent); color: var(--text); }
.drop input { display: none; }

progress { width: 100%; height: 10px; accent-color: var(--accent); }
.filelist { list-style: none; margin: 0; padding: 0; }
.filelist li {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.filelist li + li { margin-top: 8px; }
.filelist .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist button { padding: 4px 10px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.preview img { max-width: 100%; border-radius: 10px; border: 1px solid var(--border); }

/* chat */
.chat-shell { display: flex; flex-direction: column; height: calc(100vh - 56px); height: calc(100dvh - 56px); }
.chat-top { padding: 12px 0; border-bottom: 1px solid var(--border); }
.chat-top .row > * { flex: 1 1 200px; }
.messages { flex: 1; overflow-y: auto; padding: 18px 0; }
.msg { display: flex; margin-bottom: 14px; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: min(720px, 88%); padding: 10px 14px; border-radius: 16px;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.user .bubble { background: var(--user-bg); color: var(--user-text); border-bottom-right-radius: 4px; }
.msg.bot .bubble { background: var(--bot-bg); border-bottom-left-radius: 4px; }
.bubble pre {
  background: #0f0f0e; color: #e8e8e2; padding: 10px 12px; border-radius: 10px;
  overflow-x: auto; margin: 8px 0; white-space: pre; font-size: 13px;
}
.bubble code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.bubble :not(pre) > code { background: rgba(127,127,127,.2); padding: 1px 5px; border-radius: 5px; }
.composer { padding: 12px 0 18px; border-top: 1px solid var(--border); }
.composer form { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { flex: 1; max-height: 160px; min-height: 44px; }
.empty { text-align: center; color: var(--muted); margin-top: 8vh; }
.empty h2 { color: var(--text); font-size: 22px; }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.chips button { font-size: 14px; }
.status { font-size: 13px; color: var(--muted); min-height: 20px; }
footer { border-top: 1px solid var(--border); padding: 20px 0; color: var(--muted); font-size: 13px; }
