:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --text: #e8eef4;
  --muted: #8b9aab;
  --accent: #3d9cf0;
  --ok: #3ecf8e;
  --warn: #f0b429;
  --err: #f07178;
  --voice: #c792ea;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1a2a3a, var(--bg));
  color: var(--text);
  min-height: 100vh;
  padding: 1.5rem;
}
header h1 { margin: 0 0 0.25rem; font-weight: 650; letter-spacing: -0.02em; }
.sub { color: var(--muted); margin: 0 0 1.5rem; }
.badge {
  background: var(--warn);
  color: #1a1400;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}
.panel {
  background: var(--panel);
  border: 1px solid #2a3542;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.panel h2 { margin: 0 0 0.75rem; font-size: 1rem; color: var(--muted); font-weight: 600; }
.card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #243040;
  font-size: 0.92rem;
}
.card-main {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  align-items: baseline;
}
.card.active {
  background: #152018;
  border: 1px solid #2a5a3a;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #2a5a3a;
}
.card-voice { margin-top: 0.15rem; }

/* Messenger-style voice bubble */
.voice-bubble {
  --progress: 0;
  display: inline-grid;
  grid-template-columns: 2.4rem minmax(9rem, 14rem) 2.6rem;
  align-items: center;
  gap: 0.55rem;
  max-width: 100%;
  padding: 0.55rem 0.75rem 0.55rem 0.55rem;
  border-radius: 18px 18px 18px 6px;
  background: linear-gradient(145deg, #243041 0%, #1a2430 100%);
  border: 1px solid #314255;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  position: relative;
}
.kind-voice .voice-bubble,
.kind-voice_warning .voice-bubble {
  background: linear-gradient(145deg, #3a2a52 0%, #2a1f3d 100%);
  border-color: #5a4578;
}
.voice-bubble audio { display: none; }
.voice-play {
  width: 2.4rem;
  height: 2.4rem;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #041018;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.kind-voice .voice-play,
.kind-voice_warning .voice-play {
  background: var(--voice);
  color: #1a1024;
}
.voice-play svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}
.voice-play .icon-pause { display: none; }
.voice-bubble.playing .icon-play { display: none; }
.voice-bubble.playing .icon-pause { display: block; }
.voice-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 1.6rem;
  position: relative;
}
.voice-wave i {
  display: block;
  width: 3px;
  height: var(--h, 40%);
  border-radius: 2px;
  background: rgba(232, 238, 244, 0.28);
  transform-origin: center;
}
.voice-wave i.filled {
  background: #7ec8ff;
}
.kind-voice .voice-wave i.filled,
.kind-voice_warning .voice-wave i.filled {
  background: #e0b7ff;
}
.voice-bubble.playing .voice-wave i {
  animation: voicePulse 0.9s ease-in-out infinite;
  animation-delay: calc(var(--h) * 0.004s);
}
@keyframes voicePulse {
  0%, 100% { transform: scaleY(0.72); opacity: 0.7; }
  50% { transform: scaleY(1.12); opacity: 1; }
}
.voice-time {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.voice-bubble.playing .voice-time { color: var(--text); }
.kind {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--accent);
  text-transform: uppercase;
}
.kind-voice .kind { color: var(--voice); }
.kind-voice_warning .kind { color: var(--warn); }
.kind-cancel .kind { color: var(--warn); }
.kind-press .kind, .kind-latch .kind { color: var(--ok); }
.kind-voice_error .kind, .kind-cancel_miss .kind { color: var(--err); }
.ts, .meta, .muted, .hint { color: var(--muted); font-size: 0.85rem; }
.hint { margin: 0 0 0.75rem; }
.row { display: flex; gap: 0.75rem; align-items: baseline; }
.row .label { color: var(--muted); min-width: 5.5rem; font-size: 0.85rem; }
.speech { font-style: italic; }
.cat { color: var(--voice); }
.cat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.cat-item {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  background: #121820;
  border: 1px solid #2a3542;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
}
.cat-order {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.cat-name {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  padding: 0.35rem 0.25rem;
  outline: none;
}
.cat-name:focus {
  background: #0c1016;
  border-radius: 6px;
}
.cat-ops { display: flex; gap: 0.25rem; }
.cat-empty {
  padding: 0.85rem 0.5rem;
  border: 1px dashed #2a3542;
  border-radius: 10px;
  text-align: center;
}
.cat-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.cat-add input {
  background: #0f1419;
  color: var(--text);
  border: 1px solid #2a3542;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font: inherit;
}
button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid #2a3542;
  border-radius: 6px;
  min-width: 2rem;
  height: 2rem;
  cursor: pointer;
  font: inherit;
}
button.ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: #3d4f63;
}
button.ghost:disabled {
  opacity: 0.35;
  cursor: default;
}
button.ghost.danger:hover:not(:disabled) {
  color: var(--err);
  border-color: #6a3038;
}
.actions { margin-top: 0.75rem; display: flex; gap: 1rem; align-items: center; }
button.primary {
  background: var(--accent);
  color: #041018;
  border: 0;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-weight: 600;
  cursor: pointer;
}
@media (max-width: 720px) {
  .card-main { flex-direction: column; gap: 0.25rem; }
  .cat-item { grid-template-columns: 1.5rem 1fr; }
  .cat-ops { grid-column: 1 / -1; justify-content: flex-end; }
  .voice-bubble { grid-template-columns: 2.2rem minmax(7rem, 1fr) 2.4rem; width: 100%; }
}
