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

html, body {
  width: 240px;
  height: 282px;
  background: #000;
  color: #f5f5f5;
  font-family: ui-rounded, -apple-system, system-ui, sans-serif;
  font-size: 12px;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  --accent: #ff6b00;
  --accent-soft: rgba(255, 107, 0, 0.2);
  width: 240px;
  height: 282px;
  display: flex;
  flex-direction: column;
  border: 5px solid var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-soft);
}

#app[data-mode="ask"] { --accent: #ffd166; --accent-soft: rgba(255, 209, 102, 0.22); }
#app[data-mode="mac"] { --accent: #ff6b00; --accent-soft: rgba(255, 107, 0, 0.22); }
#app[data-mode="capture"] { --accent: #a574ff; --accent-soft: rgba(165, 116, 255, 0.22); }
#app[data-mode="watch"] { --accent: #23d18b; --accent-soft: rgba(35, 209, 139, 0.22); }

#bar {
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#bar button {
  background: #000;
  color: var(--accent);
  border: 0;
  padding: 2px 5px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 2px;
}

#barBtns {
  display: flex;
  gap: 4px;
  align-items: center;
}

#screenPanel {
  height: 142px;
  background: #050505;
  border-bottom: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#screenPanel[hidden] { display: none; }

#screenFeed {
  max-width: 230px;
  max-height: 140px;
  object-fit: contain;
  background: #000;
}

#stateRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: #090909;
  border-bottom: 1px solid #181818;
  font-size: 9px;
  text-transform: uppercase;
}

#modeLabel {
  color: #000;
  background: var(--accent);
  border-radius: 2px;
  padding: 2px 5px;
  font-weight: 800;
}

#voiceLabel {
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#modes { display: none; }

.modeBtn {
  min-width: 0;
  background: #151515;
  color: #aaa;
  border: 1px solid #333;
  border-radius: 2px;
  padding: 5px 2px;
  font-size: 8px;
  font-weight: 800;
  cursor: pointer;
}

.modeBtn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

#modeHelp { display: none; }

#modeHint {
  display: block;
  color: #cfcfcf;
  font-size: 8px;
  line-height: 1.2;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#log {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

#log::-webkit-scrollbar { width: 3px; }
#log::-webkit-scrollbar-thumb { background: var(--accent); }

.msg {
  padding: 4px 6px;
  border-radius: 4px;
  word-wrap: break-word;
  line-height: 1.3;
  max-width: 100%;
}

.msg.user { background: #1a1a1a; align-self: flex-end; border-right: 2px solid var(--accent); }
.msg.bot  { background: #111;    align-self: flex-start; border-left: 2px solid #fff; }
.msg.err  { background: #2a0000; color: #ff8080; align-self: stretch; }
.msg.sys  { color: #888; font-style: italic; align-self: center; font-size: 10px; }

.msg.user.corrected {
  position: relative;
  overflow: visible;
  display: inline-block;
}

.msg.user.corrected .ghost {
  display: inline-block;
  opacity: 0.4;
  font-style: italic;
  color: #d8d8d8;
  filter: blur(0.3px);
  letter-spacing: 0;
  transition: opacity 320ms ease, filter 320ms ease, letter-spacing 320ms ease, transform 320ms ease;
}

.msg.user.corrected .ghost.dissolve {
  opacity: 0;
  filter: blur(2.5px);
  letter-spacing: 0.18em;
  transform: translateY(-1px);
}

.msg.user.corrected .sparkle {
  position: absolute;
  inset: -2px;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 18% 50%, rgba(255,200,120,0.95) 0 1.4px, transparent 2px),
    radial-gradient(circle at 42% 28%, rgba(255,255,255,0.9) 0 1.2px, transparent 2px),
    radial-gradient(circle at 64% 72%, rgba(255,107,0,0.95) 0 1.4px, transparent 2px),
    radial-gradient(circle at 82% 38%, rgba(255,240,180,0.9) 0 1px, transparent 1.6px),
    radial-gradient(circle at 30% 80%, rgba(255,255,255,0.85) 0 1px, transparent 1.6px);
  animation: sparkleFlicker 480ms ease-out forwards;
  mix-blend-mode: screen;
}

@keyframes sparkleFlicker {
  0%   { opacity: 0; transform: scale(0.85); }
  35%  { opacity: 1; }
  70%  { opacity: 0.7; transform: scale(1.08); }
  100% { opacity: 0; transform: scale(1.18); }
}

.msg.user.corrected .final {
  display: inline-block;
  animation: finalIn 320ms ease-out;
}

@keyframes finalIn {
  from { opacity: 0; transform: translateY(2px); filter: blur(1px); }
  to   { opacity: 1; transform: translateY(0);   filter: blur(0); }
}

.correctionNote {
  display: block;
  margin-top: 2px;
  color: #555;
  font-size: 8px;
  font-style: italic;
  letter-spacing: 0.2px;
  text-align: right;
  opacity: 0;
  animation: noteIn 360ms ease-out forwards;
  animation-delay: 80ms;
}

@keyframes noteIn {
  from { opacity: 0; }
  to   { opacity: 0.75; }
}

@media (prefers-reduced-motion: reduce) {
  .msg.user.corrected .ghost,
  .msg.user.corrected .ghost.dissolve,
  .msg.user.corrected .sparkle,
  .msg.user.corrected .final,
  .correctionNote {
    animation: none;
    transition: none;
    filter: none;
  }
}

#status {
  padding: 2px 6px;
  background: #222;
  color: var(--accent);
  font-size: 10px;
  text-align: center;
}

#hint {
  padding: 2px 6px;
  background: #050505;
  color: #999;
  font-size: 9px;
  text-align: center;
  border-top: 1px solid #181818;
}

#composer {
  display: flex;
  gap: 4px;
  padding: 4px 6px;
  background: #0a0a0a;
  border-top: 1px solid #222;
}

#input {
  flex: 1;
  background: #1a1a1a;
  color: #fff;
  border: 1px solid #333;
  padding: 4px 6px;
  font-size: 12px;
  border-radius: 2px;
  min-width: 0;
}

#input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }

#send, #mic {
  background: var(--accent);
  color: #000;
  border: 0;
  padding: 4px 5px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 2px;
  font-size: 9px;
}

#mic {
  background: #222;
  color: var(--accent);
  border: 1px solid var(--accent);
}

#send:disabled, #mic:disabled { opacity: 0.5; cursor: wait; }

dialog {
  width: 200px;
  background: #111;
  color: #fff;
  border: 2px solid var(--accent);
  padding: 8px;
  border-radius: 4px;
}

dialog::backdrop { background: rgba(0,0,0,0.7); }

dialog label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  margin-bottom: 6px;
  color: var(--accent);
}

dialog input[type="url"], dialog input[type="password"] {
  background: #000;
  color: #fff;
  border: 1px solid #333;
  padding: 3px 4px;
  font-size: 11px;
}

dialog menu {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  list-style: none;
  margin-top: 6px;
}

dialog menu button {
  background: var(--accent);
  color: #000;
  border: 0;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 2px;
}

dialog menu button[value="cancel"] {
  background: #333;
  color: #fff;
}
