:root {
  --bg: #050506;
  --panel: #0c0d10;
  --line: #1c1e24;
  --text: #efeff2;
  --dim: #8a8d96;
  --faint: #55585f;
  --accent: #6f8bff;
  --accent-soft: rgba(111, 139, 255, 0.5);
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 46px 60px 26px;
  overflow-y: auto;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(111,139,255,0.06), transparent 60%),
    var(--bg);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.clock {
  font-weight: 200;
  font-size: 118px;
  line-height: 0.8;
  letter-spacing: -4px;
  font-variant-numeric: tabular-nums;
}
.clock .colon { color: var(--faint); font-weight: 100; }
.clock .ss {
  font-size: 34px;
  color: var(--dim);
  letter-spacing: 0;
  margin-left: 8px;
  vertical-align: baseline;
}

.topright { text-align: right; padding-top: 10px; }
.date { font-size: 20px; font-weight: 300; letter-spacing: 0.3px; }
.topright-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.integrations-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 14px 5px 12px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: lowercase;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.integrations-btn:hover { border-color: var(--accent-soft); color: var(--text); }
.integrations-btn.active { border-color: #57d68d; color: var(--text); }
.integrations-btn.active .ibtn-dot { background: #57d68d; box-shadow: 0 0 8px rgba(87,214,141,0.5); }
.ibtn-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-soft);
}

.model-select {
  background: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 10px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
}
.model-select:hover { border-color: var(--accent-soft); color: var(--text); }
.model-select option { background: #111; color: var(--text); }

.status-line {
  margin-top: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: lowercase;
  color: var(--dim);
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.status-line .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--faint);
  transition: background 0.3s, box-shadow 0.3s;
}
#status-word { color: var(--dim); }

/* status states drive the dot + word colour */
#status-orb.asleep    .dot { background: var(--faint); }
#status-orb.listening .dot,
#status-orb.thinking  .dot,
#status-orb.speaking  .dot {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-soft);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- info grid ---------- */
.grid {
  margin-top: 64px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
  padding-top: 26px;
}
.cell {
  padding: 0 30px;
  border-right: 1px solid var(--line);
  min-height: 132px;
}
.cell:first-child { padding-left: 0; }
.cell:last-child { border-right: none; padding-right: 0; }

.cell-title {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 20px;
}

/* weather */
.temp { font-size: 40px; font-weight: 200; line-height: 1; }
.cond { font-size: 14px; color: var(--dim); margin-top: 8px; }
.sub { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-top: 8px; letter-spacing: 0.5px; }

/* agenda */
.row { display: flex; gap: 16px; font-size: 13.5px; margin-bottom: 13px; }
.row .t { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.row .t.accent { color: var(--accent); }
.row .d { color: var(--text); }
.dim { color: var(--faint); font-size: 13px; }

/* tasks */
.task {
  display: flex; align-items: center; gap: 11px;
  font-size: 13.5px; color: var(--dim); margin-bottom: 13px;
}
.task .box {
  width: 11px; height: 11px; border: 1px solid var(--faint);
  border-radius: 2px; flex: none;
}
.task.done { color: var(--text); }
.task.done .box { background: var(--accent); border-color: var(--accent); }

/* nearby mini radar */
.nearby { display: flex; flex-direction: column; align-items: flex-start; }
.mini-radar {
  position: relative; width: 78px; height: 78px; margin: 2px 0 12px;
}
.mini-radar .ring, .mini-radar .r2 {
  position: absolute; border: 1px solid var(--line); border-radius: 50%;
  inset: 0;
}
.mini-radar .r2 { inset: 22px; }
.mini-radar .blip {
  position: absolute; width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 6px var(--accent-soft);
}
.mini-radar .b1 { top: 12px; right: 16px; }
.mini-radar .b2 { bottom: 22px; left: 20px; background: var(--dim); box-shadow: none; }
.mini-radar .sweep {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(111,139,255,0.18) 40deg, transparent 60deg);
  animation: spin 4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- centre / waveform / chat ---------- */
.center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  min-height: 220px;
  position: relative;
}

#hero-radar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 44px;
}
#hero-radar .wb {
  width: 2px;
  height: 4px;
  border-radius: 1px;
  background: #2b2f3d;
  animation: wave 1.3s ease-in-out infinite;
  animation-play-state: paused;
}
#hero-radar.listening .wb,
#hero-radar.speaking .wb,
#hero-radar.thinking .wb {
  background: var(--accent);
  animation-play-state: running;
}
#hero-radar.speaking .wb { background: #8aa0ff; }
@keyframes wave { 0%, 100% { height: 4px; } 50% { height: 26px; } }

.quote {
  max-width: 720px;
  text-align: center;
  font-size: 16px;
  font-weight: 300;
  color: var(--dim);
  line-height: 1.5;
}

#messages {
  width: 100%;
  max-width: 720px;
  max-height: 40vh;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px;
}
#chat-area.has-messages #messages { display: flex; }
#chat-area.has-messages .quote { display: none; }

.msg {
  font-size: 14.5px;
  line-height: 1.5;
  max-width: 82%;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user { align-self: flex-end; color: var(--text); }
.msg.assistant { align-self: flex-start; color: var(--dim); }
.msg.user::before { content: "you  "; font-family: var(--mono); font-size: 10px; color: var(--faint); letter-spacing: 1px; }
.msg.assistant::before { content: "jarvis  "; font-family: var(--mono); font-size: 10px; color: var(--accent); letter-spacing: 1px; }

.msg a { color: var(--accent); word-break: break-all; }

/* generated media inlined in the chat */
.msg img.inline-media, .msg video.inline-media {
  display: block;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  margin-top: 8px;
}

/* ---------- ask input ---------- */
.ask {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto 22px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.ask input[type="text"] {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 300;
}
.ask input[type="text"]::placeholder { color: var(--faint); }
.ask button {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.2s;
}
.ask button:hover { color: var(--accent); }
#attach-btn { font-size: 15px; }

.attachments-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.attachments-strip:empty { display: none; }
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--dim);
  max-width: 220px;
}
.attachment-chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip .chip-remove {
  background: none;
  border: none;
  color: var(--faint);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.attachment-chip .chip-remove:hover { color: var(--text); }

#chat-area.drag-over {
  outline: 1px dashed var(--accent-soft);
  outline-offset: 8px;
}

/* ---------- footer ---------- */
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--faint);
}
#reset-btn {
  background: none;
  border: none;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s;
}
#reset-btn:hover { color: var(--dim); }

/* ---------- integrations / plugins panel ---------- */
#integrations-overlay, #mcp-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
}
#integrations-overlay.hidden, #mcp-overlay.hidden { display: none; }
#integrations-box, #mcp-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 92%;
  max-width: 520px;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ibox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}
.ibox-head h2 { font-size: 16px; font-weight: 400; }
#integrations-close, #mcp-close {
  background: none; border: none; color: var(--dim);
  font-size: 15px; cursor: pointer; transition: color 0.2s;
}
#integrations-close:hover, #mcp-close:hover { color: var(--text); }

.ibox-list { overflow-y: auto; padding: 6px 10px; }
.iplugin {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
}
.iplugin:last-child { border-bottom: none; }
.istatus {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--faint);
}
.istatus.on { background: #57d68d; box-shadow: 0 0 8px rgba(87,214,141,0.5); }
.istatus.off { background: #55585f; }
.imeta { flex: 1; min-width: 0; }
.iname { font-size: 14px; color: var(--text); }
.idesc { font-size: 12px; color: var(--faint); margin-top: 2px; }
.idetail {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--dim);
  text-align: right;
  max-width: 160px;
  flex: none;
}

/* ---------- mcp connectors panel ---------- */
.mcp-server {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
}
.mcp-server:last-child { border-bottom: none; }
.mcp-toggle {
  width: 30px; height: 17px; border-radius: 10px; flex: none;
  background: var(--line); border: none; cursor: pointer; position: relative;
  transition: background 0.2s;
}
.mcp-toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 13px; height: 13px; border-radius: 50%; background: var(--dim);
  transition: transform 0.2s, background 0.2s;
}
.mcp-toggle.on { background: rgba(87,214,141,0.25); }
.mcp-toggle.on::after { transform: translateX(13px); background: #57d68d; }
.mcp-remove {
  background: none; border: none; color: var(--faint);
  font-size: 14px; cursor: pointer; flex: none;
}
.mcp-remove:hover { color: #e0616b; }
.mcp-note { font-size: 11px; color: var(--faint); margin-top: 2px; }

.mcp-advanced-toggle {
  background: none; border: none; color: var(--faint);
  font-size: 11px; text-decoration: underline; cursor: pointer;
  text-align: left; padding: 0; align-self: flex-start;
}
.mcp-advanced-toggle:hover { color: var(--dim); }
.mcp-advanced { display: flex; flex-direction: column; gap: 8px; }
.mcp-advanced.hidden { display: none; }

.mcp-add-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px 18px;
  border-top: 1px solid var(--line);
}
.mcp-add-title { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); margin-bottom: 2px; }
.mcp-add-form input, .mcp-add-form select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
}
.mcp-add-form button {
  background: none;
  border: 1px solid var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
}
.mcp-add-form button:hover { background: rgba(111,139,255,0.08); }

/* scrollbar */
#messages::-webkit-scrollbar { width: 6px; }
#messages::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

@media (max-width: 900px) {
  #app { padding: 28px 26px 18px; }
  .clock { font-size: 74px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 20px 0; }
  .cell:nth-child(2n) { border-right: none; }
}

/* Small window: prioritize the chat over the info grid so replies stay
   visible instead of getting squeezed to zero height and clipped. */
@media (max-width: 620px), (max-height: 560px) {
  #app { padding: 16px 16px 12px; }
  .clock { font-size: 40px; letter-spacing: -1px; }
  .clock .ss { font-size: 16px; }
  .date { font-size: 13px; }
  .topright { padding-top: 2px; }
  .grid { display: none; }
  .center { margin-top: 12px; min-height: 120px; }
  #hero-radar { height: 28px; }
  #messages { max-height: 50vh; }
  .quote { font-size: 13px; }
}
