@font-face {
  font-family: "Syne";
  src: url("/fonts/syne.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: "Manrope";
  src: url("/fonts/manrope.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

* { box-sizing: border-box; }

:root {
  --accent: #00e5c8;
  --accent-dim: rgba(0, 229, 200, 0.35);
  --ink: #dde2f8;
  --muted: #8a96a8;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(ellipse at 50% 35%, #0d1322 0%, #0a0f1e 55%, #060912 100%);
  color: var(--ink);
}

#aurora {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1160px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  gap: 1rem;
}

#hud {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 220px minmax(0, 640px) 220px;
  justify-content: center;
  gap: 1.25rem;
}

#center {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

.hud-col {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  overflow-y: auto;
  scrollbar-width: none;
}

@media (max-width: 979px) {
  #hud { grid-template-columns: minmax(0, 1fr); }
  .hud-col { display: none; }
}

.hud-card {
  position: relative;
  padding: 0.85rem 1rem 0.95rem;
  border-radius: 12px;
  border: 1px solid rgba(0, 229, 200, 0.14);
  background: rgba(10, 15, 30, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.hud-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 12px;
  width: 34px;
  height: 2px;
  background: var(--accent);
  opacity: 0.7;
  border-radius: 2px;
}

.hud-card h2 {
  margin: 0 0 0.6rem;
  font-family: "Syne", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(0, 229, 200, 0.85);
}

.hud-big {
  margin: 0 0 0.6rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1.9rem;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.hud-unit {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: "Manrope", sans-serif;
}

.hud-kv { margin: 0; display: flex; flex-direction: column; gap: 0.45rem; }

.hud-kv div { display: flex; justify-content: space-between; align-items: baseline; }

.hud-kv dt { color: var(--muted); font-size: 0.8rem; }

.hud-kv dd {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85rem;
  color: var(--ink);
}

#mem-bars { display: flex; flex-direction: column; gap: 0.4rem; }

.mem-row { display: flex; align-items: center; gap: 0.5rem; }

.mem-row span {
  width: 74px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.mem-row .bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.mem-row .bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, rgba(0, 229, 200, 0.9), rgba(0, 229, 200, 0.4));
  border-radius: 3px;
  transition: width 0.8s ease;
}

.mem-row b {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  font-weight: 400;
  width: 18px;
  text-align: right;
}

#tool-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#tool-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--ink);
}

#tool-list .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

#tool-list .dot.green { background: #3fd68f; box-shadow: 0 0 6px rgba(63, 214, 143, 0.7); }
#tool-list .dot.yellow { background: #e8c34a; box-shadow: 0 0 6px rgba(232, 195, 74, 0.7); }
#tool-list .dot.red { background: #e05a6d; box-shadow: 0 0 6px rgba(224, 90, 109, 0.7); }

#feed {
  min-height: 2.6rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

@keyframes feed-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.feed-line {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.72rem;
  color: rgba(0, 229, 200, 0.75);
  animation: feed-in 0.25s ease;
  transition: opacity 0.8s;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-line::before { content: "\203A "; opacity: 0.6; }

.feed-line.fading { opacity: 0; }

#mem-recent {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

#mem-recent li {
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--ink);
  cursor: pointer;
}

#mem-recent li .mem-desc { color: var(--muted); transition: color 0.2s; }

#mem-recent li:hover .mem-desc { color: var(--ink); }

#mem-recent li .mem-date {
  font-family: ui-monospace, monospace;
  font-size: 0.65rem;
  color: rgba(0, 229, 200, 0.6);
  margin-right: 0.35rem;
}

#mem-recent .mem-body {
  display: none;
  margin-top: 0.3rem;
  padding: 0.45rem 0.6rem;
  border-left: 2px solid var(--accent-dim);
  background: rgba(0, 229, 200, 0.05);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: pre-wrap;
  cursor: default;
}

#mem-recent li.open .mem-body { display: block; }

header { text-align: center; position: relative; }

header h1 {
  font-family: "Syne", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 0 22px var(--accent-dim), 0 0 60px rgba(0, 229, 200, 0.2);
}

#status {
  color: var(--muted);
  margin: 0;
  min-height: 1.2em;
  font-size: 0.9rem;
}

#handsfree {
  position: absolute;
  top: 0;
  right: 0;
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  font-family: "Manrope", sans-serif;
  border-radius: 999px;
  border: 1px solid rgba(138, 150, 168, 0.35);
  background: rgba(16, 24, 38, 0.6);
  color: var(--muted);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.2s, border-color 0.2s, box-shadow 0.3s;
}

#handsfree.on {
  color: var(--accent);
  border-color: var(--accent-dim);
  box-shadow: 0 0 14px rgba(0, 229, 200, 0.25);
}

#log {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.6rem;
  overflow-y: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 15%);
  mask-image: linear-gradient(to bottom, transparent, black 15%);
}

#log::-webkit-scrollbar { display: none; }

.msg {
  padding: 0.6rem 0.95rem;
  border-radius: 14px;
  line-height: 1.45;
  max-width: 85%;
  white-space: pre-wrap;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.msg.user {
  align-self: flex-end;
  background: rgba(42, 67, 101, 0.55);
}

.msg.jarvis {
  align-self: flex-start;
  background: rgba(13, 19, 34, 0.65);
  border-color: rgba(0, 229, 200, 0.22);
}

.msg.error {
  align-self: center;
  background: rgba(74, 31, 36, 0.6);
  color: #f0b8bd;
  font-size: 0.9rem;
}

#confirm-bar {
  background: rgba(43, 36, 19, 0.7);
  border: 1px solid rgba(179, 143, 30, 0.45);
  border-radius: 14px;
  padding: 0.8rem 1rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#confirm-bar.hidden { display: none; }

#confirm-prompt { margin: 0 0 0.6rem; }

.confirm-buttons { display: flex; gap: 0.6rem; }

.confirm-buttons button {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  background: #33404f;
  color: #e8ecf1;
}

#confirm-yes { background: #2f6b3a; }

@keyframes ptt-pulse {
  0%, 100% { box-shadow: 0 0 26px rgba(0, 229, 200, 0.3), inset 0 0 18px rgba(0, 229, 200, 0.14); }
  50% { box-shadow: 0 0 52px rgba(0, 229, 200, 0.55), inset 0 0 26px rgba(0, 229, 200, 0.22); }
}

#ptt-wrap {
  position: relative;
  align-self: center;
  width: 240px;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#viz {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#ptt {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 1px solid rgba(0, 229, 200, 0.45);
  background: radial-gradient(circle at 50% 40%, rgba(14, 80, 69, 0.5), rgba(8, 13, 28, 0.95));
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: border-color 0.3s, transform 0.15s;
  animation: ptt-pulse 3.2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  #ptt { animation: none; box-shadow: 0 0 26px rgba(0, 229, 200, 0.3); }
}

#ptt:hover { border-color: var(--accent); }

#ptt.recording {
  border-color: rgba(230, 110, 130, 0.6);
  transform: scale(1.1);
  box-shadow: 0 0 46px rgba(200, 60, 90, 0.55), inset 0 0 24px rgba(200, 60, 90, 0.3);
}

#ptt:disabled { opacity: 0.4; cursor: default; }

main.voices { max-width: 460px; }

#voice-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.voice-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(13, 19, 34, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.voice-row.active { border-color: var(--accent-dim); box-shadow: 0 0 16px rgba(0, 229, 200, 0.15); }

.voice-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.voice-info span { color: var(--muted); font-size: 0.82rem; }

.voice-row button {
  padding: 0.45rem 0.8rem;
  border: 1px solid rgba(138, 150, 168, 0.35);
  border-radius: 999px;
  background: rgba(16, 24, 38, 0.6);
  color: var(--ink);
  font-size: 0.85rem;
  cursor: pointer;
}

.voice-row button.use { border-color: var(--accent-dim); color: var(--accent); }

.voice-row button:disabled { opacity: 0.55; cursor: default; }

#voicelink {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  border-radius: 999px;
  border: 1px solid rgba(138, 150, 168, 0.35);
  background: rgba(16, 24, 38, 0.6);
  color: var(--muted);
  text-decoration: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

main.auth {
  max-width: 380px;
  justify-content: center;
  text-align: center;
}

main.auth h1 { font-size: 1.5rem; margin: 0; letter-spacing: 0.35em; text-transform: uppercase; }

.auth-hint { color: #8a94a3; line-height: 1.5; }

.auth-hint a { color: #7fb2e5; }

main.auth form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

main.auth input {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid #33404f;
  background: rgba(28, 37, 48, 0.8);
  color: #e8ecf1;
  font-size: 1rem;
}

main.auth button {
  padding: 0.75rem;
  border: none;
  border-radius: 10px;
  background: #2a4365;
  color: #e8ecf1;
  font-size: 1rem;
  cursor: pointer;
}
