:root {
  --bg: #05070f;
  --panel: #0c1222;
  --panel-2: #111a30;
  --line: #1c2a4a;
  --text: #e6ecff;
  --muted: #8a97b8;
  --accent: #3b8bff;
  --accent-glow: rgba(59, 139, 255, 0.45);
  --danger: #ff5c7a;
  --ok: #3ddc97;
  --warn: #ffc857;
  --radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Devanagari", sans-serif;
}
:root[data-accent="cyan"]   { --accent: #22d3ee; --accent-glow: rgba(34, 211, 238, 0.45); }
:root[data-accent="violet"] { --accent: #8b5cf6; --accent-glow: rgba(139, 92, 246, 0.45); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  background:
    radial-gradient(600px 300px at 80% -10%, var(--accent-glow), transparent 70%),
    radial-gradient(500px 300px at -10% 110%, rgba(59, 139, 255, 0.12), transparent 70%),
    var(--bg);
}
button, input, textarea, select { font: inherit; color: inherit; }

.app { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 1.15rem; letter-spacing: 0.3em; }
.status { margin: 2px 0 0; font-size: 0.75rem; color: var(--muted); }
.status.ok { color: var(--ok); } .status.warn { color: var(--warn); } .status.err { color: var(--danger); }
.orb {
  width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--accent) 45%, #0b1a3a 100%);
  box-shadow: 0 0 18px var(--accent-glow), 0 0 40px var(--accent-glow);
  animation: pulse 3.5s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.08); box-shadow: 0 0 26px var(--accent-glow), 0 0 60px var(--accent-glow); } }

main { flex: 1; overflow: hidden; position: relative; }
.view { display: none; height: 100%; overflow-y: auto; padding: 16px; }
.view.active { display: flex; flex-direction: column; }
#view-chat { padding: 0; }
h2 { margin: 4px 0 14px; font-size: 1.2rem; }

/* Chat */
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg {
  max-width: 85%; padding: 10px 14px; border-radius: var(--radius);
  line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; font-size: 0.95rem;
}
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.maya {
  align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.msg.error { align-self: flex-start; background: rgba(255, 92, 122, 0.1); border: 1px solid var(--danger); color: #ffd3dc; }
.msg.system { align-self: center; color: var(--muted); font-size: 0.8rem; background: none; }
.msg .meta { display: block; margin-top: 4px; font-size: 0.7rem; opacity: 0.6; }

.visualizer { display: flex; justify-content: center; align-items: center; gap: 5px; height: 0; overflow: hidden; transition: height .25s; }
.visualizer.on { height: 44px; }
.visualizer span {
  width: 5px; height: 10px; border-radius: 3px; background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  animation: wave 0.9s ease-in-out infinite;
}
.visualizer span:nth-child(2) { animation-delay: .1s } .visualizer span:nth-child(3) { animation-delay: .2s }
.visualizer span:nth-child(4) { animation-delay: .3s } .visualizer span:nth-child(5) { animation-delay: .2s }
.visualizer span:nth-child(6) { animation-delay: .1s }
@keyframes wave { 50% { height: 34px; } }

.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--line); background: rgba(12, 18, 34, 0.85);
}
.composer textarea {
  flex: 1; resize: none; max-height: 120px; padding: 11px 14px; border-radius: 22px;
  background: var(--panel); border: 1px solid var(--line); outline: none;
}
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.send { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 16px var(--accent-glow); color: #fff; }
.icon-btn.mic.listening { background: var(--danger); border-color: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
.icon-btn:disabled { opacity: .4; }

/* Lists */
.row-form { display: flex; gap: 8px; margin-bottom: 14px; }
.row-form input, .note-form input, .note-form textarea, .field select {
  width: 100%; padding: 11px 13px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--line); outline: none;
}
.note-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
}
.list li .grow { flex: 1; min-width: 0; }
.list li.done .grow { text-decoration: line-through; color: var(--muted); }
.list li h4 { margin: 0 0 4px; } .list li p { margin: 0; color: var(--muted); white-space: pre-wrap; }
.list input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); margin-top: 2px; }
.del { background: none; border: 0; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 0 4px; }
.empty { color: var(--muted); text-align: center; }

.pill {
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer; white-space: nowrap;
}
.pill.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.pill.danger { background: transparent; color: var(--danger); border-color: var(--danger); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; color: var(--muted); font-size: .85rem; }
.field.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: .95rem; }
.field small { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 6px 0 18px; }
.card h3 { margin: 0 0 8px; font-size: 1rem; }
.status-list { list-style: none; padding: 0; margin: 0; font-size: .85rem; display: grid; gap: 6px; }
.status-list b { font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err { background: var(--danger); }

.tabbar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line); background: var(--panel);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button { padding: 14px 0; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .85rem; }
.tabbar button.active { color: var(--accent); text-shadow: 0 0 12px var(--accent-glow); }

.dialog { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; z-index: 10; }
.dialog[hidden] { display: none; }
.dialog-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; max-width: 340px; width: 100%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
