:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --bg-3: #334155;
  --accent: #10b981;     /* emerald 500 */
  --accent-2: #34d399;
  --warn: #f59e0b;
  --err: #ef4444;
  --txt: #f1f5f9;
  --txt-2: #94a3b8;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; font-family: -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; background: var(--bg); color: var(--txt); }
body { padding-bottom: 90px; min-height: 100vh; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
  border-bottom: 1px solid #1f2937;
}
.top h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.4px; }
.top h1 span { color: var(--accent); }
.status { font-size: 18px; color: var(--txt-2); }
.status.ok { color: var(--accent); }
.status.err { color: var(--err); }

main { padding: 16px; max-width: 720px; margin: 0 auto; }

.card {
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1px solid #1f2937;
}

h2 { margin: 0 0 10px; font-size: 17px; font-weight: 700; color: var(--accent-2); }
.sub { color: var(--txt-2); font-size: 13.5px; line-height: 1.5; }

label { display: block; margin: 12px 0 4px; color: var(--txt-2); font-size: 13px; font-weight: 500; }
input, textarea, select {
  width: 100%; padding: 13px 14px;
  background: #0b1220; border: 1px solid #1f2937; border-radius: 10px;
  color: var(--txt); font-size: 16px;
  transition: border .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 18px; border: none; border-radius: 10px;
  background: var(--accent); color: #052e1a; font-size: 15.5px; font-weight: 700;
  cursor: pointer; margin-top: 14px; width: 100%;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.alt { background: #1e293b; color: var(--txt); }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #0b1220; border-top: 1px solid #1f2937;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tab {
  background: transparent; border: none; color: var(--txt-2);
  padding: 9px 4px; font-size: 11.5px; font-weight: 600;
  cursor: pointer;
}
.tab.active { color: var(--accent); }
.tab.active::before {
  content: ""; display: block; height: 3px; width: 28px;
  background: var(--accent); margin: -9px auto 4px; border-radius: 2px;
}

.bubble { border-radius: 14px; padding: 12px 14px; margin: 8px 0; line-height: 1.5; font-size: 15px; word-wrap: break-word; }
.bubble.user { background: #134e4a; color: #ecfdf5; }
.bubble.assistant { background: var(--bg-3); border: 1px solid #1f2937; }
.bubble.thinking { opacity: .6; font-style: italic; }
.bubble strong { color: var(--accent-2); }
.bubble code { background: #0b1220; padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4, .bubble h5 {
  margin: 16px 0 8px; color: var(--accent); line-height: 1.3; font-weight: 700;
}
.bubble h1 { font-size: 19px; }
.bubble h2 { font-size: 17px; }
.bubble h3 { font-size: 15.5px; }
.bubble h4, .bubble h5 { font-size: 14.5px; color: var(--accent-2); }
.bubble ul, .bubble ol { margin: 6px 0 10px; padding-left: 22px; }
.bubble li { margin: 3px 0; }
.bubble hr { border: none; border-top: 1px solid #475569; margin: 14px 0; }
.bubble blockquote {
  margin: 10px 0; padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: #0b122066; border-radius: 0 8px 8px 0;
  color: var(--txt-2);
}
.bubble table {
  width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13.5px;
  display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.bubble th, .bubble td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid #475569;
  white-space: nowrap;
}
.bubble th { background: #0b1220; color: var(--accent-2); font-weight: 700; font-size: 12.5px; }
.bubble tbody tr:last-child td { border-bottom: none; }
.bubble tbody tr:nth-child(even) { background: #0b122033; }

.sources { margin-top: 8px; font-size: 12.5px; color: var(--txt-2); }
.sources a { color: var(--accent-2); text-decoration: none; margin-right: 8px; }
.sources a:hover { text-decoration: underline; }

.quote-card { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; }
.quote-card .price { font-size: 28px; font-weight: 800; }
.up { color: var(--accent); }
.down { color: var(--err); }
.qmeta { color: var(--txt-2); font-size: 12.5px; margin-top: 6px; line-height: 1.5; }

.disclaimer { background: #422006; border: 1px solid #f59e0b40; color: #fde68a; font-size: 12.5px; border-radius: 10px; padding: 10px 12px; margin-top: 14px; }

.history-item {
  padding: 11px 13px; border-left: 3px solid var(--accent); margin-bottom: 8px;
  background: #0b1220; border-radius: 8px;
  font-size: 13.5px;
}
.history-item .kind { color: var(--accent-2); font-size: 11px; font-weight: 700; text-transform: uppercase; }

.empty { text-align: center; color: var(--txt-2); padding: 30px 12px; }

.typing { display: inline-flex; gap: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: t 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes t { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

@media (min-width: 720px) {
  .top h1 { font-size: 22px; }
  main { padding: 22px; }
}
