:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: #0d1d31;
  --panel-2: #12243a;
  --panel-3: #172b44;
  --line: #26465f;
  --line-soft: rgba(111, 216, 255, 0.16);
  --text: #f6fbff;
  --muted: #93a9bb;
  --accent: #6fd8ff;
  --gold: #ffd76a;
  --green: #7ee7ad;
  --red: #ff8b8b;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 20% 0%, rgba(111, 216, 255, 0.12), transparent 28%),
    linear-gradient(180deg, #07111f 0%, #081827 100%);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  padding: 26px 28px 28px;
}

.topbar {
  position: relative;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}

.topbar h1 {
  margin: 0;
  width: 100%;
  text-align: center;
  font-size: clamp(34px, 4vw, 54px);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.status {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 132px;
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(13, 29, 49, 0.72);
  font-weight: 900;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.78fr) minmax(440px, 1.22fr);
  gap: 22px;
  min-height: 0;
}

.camera-card,
.records-card,
.debug {
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(18, 36, 58, 0.94), rgba(9, 22, 38, 0.96));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.camera-card {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 16px;
  padding: 18px;
  align-content: start;
}

.camera {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: #050b14;
}

.camera video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 22px;
  background: #050b14;
}

.placeholder.hidden {
  display: none;
}

.face-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px 14px;
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--panel-2), var(--panel-3));
}

.face-result span,
.voice-panel span {
  color: var(--muted);
  font-size: 14px;
}

.face-result strong {
  grid-column: 1;
  font-size: 30px;
  line-height: 1;
}

.face-result small {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--gold);
  font-size: 15px;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.actions button {
  min-height: 54px;
  border-radius: 12px;
  color: #04101a;
  background: linear-gradient(180deg, #79ddff, #55c9f5);
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(87, 205, 246, 0.18);
}

.actions button:nth-child(2) {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
}

.actions button:nth-child(3),
.actions button:nth-child(4) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid var(--line-soft);
  box-shadow: none;
}

.actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.records-card {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  padding: 18px;
  overflow: hidden;
}

.voice-panel {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
}

.voice-wave {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.voice-wave i {
  width: 9px;
  height: 20px;
  border-radius: 999px;
  background: rgba(111, 216, 255, 0.42);
}

.voice-wave.active i {
  animation: wave 0.8s ease-in-out infinite;
  background: var(--accent);
}

.voice-wave.active i:nth-child(2) { animation-delay: 0.08s; }
.voice-wave.active i:nth-child(3) { animation-delay: 0.16s; }
.voice-wave.active i:nth-child(4) { animation-delay: 0.24s; }
.voice-wave.active i:nth-child(5) { animation-delay: 0.32s; }

.voice-panel strong {
  display: block;
  min-height: 34px;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.35;
  word-break: break-word;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(8, 18, 31, 0.52);
}

.records-table th,
.records-table td {
  padding: 16px 14px;
  border-bottom: 1px solid rgba(38, 70, 95, 0.75);
  text-align: left;
  vertical-align: top;
}

.records-table th {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.075);
  font-size: 14px;
  font-weight: 900;
}

.records-table td {
  color: var(--text);
  background: rgba(8, 18, 31, 0.22);
  line-height: 1.5;
}

.records-table tbody tr:hover td {
  background: rgba(111, 216, 255, 0.055);
}

.records-table tr:last-child td {
  border-bottom: 0;
}

.records-table th:nth-child(1),
.records-table td:nth-child(1) {
  width: 72px;
  text-align: center;
}

.records-table th:nth-child(2),
.records-table td:nth-child(2) {
  width: 120px;
}

.empty-row td {
  height: 180px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.plus {
  color: var(--green) !important;
  font-weight: 1000;
}

.minus {
  color: var(--red) !important;
  font-weight: 1000;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 8, 15, 0.68);
}

.modal[hidden] {
  display: none;
}

.modal-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #0d1d31;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.modal-head strong {
  font-size: 22px;
}

.modal-head button {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.modal label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 900;
}

.modal input,
.modal textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(5, 11, 20, 0.72);
  font: inherit;
  outline: none;
}

.modal textarea {
  resize: vertical;
  min-height: 112px;
}

.modal input:focus,
.modal textarea:focus {
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

.modal-actions button {
  min-width: 120px;
  min-height: 46px;
  border-radius: 12px;
  color: #04101a;
  background: var(--accent);
  font-weight: 1000;
}

.debug {
  max-height: 150px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  color: #b9c8d6;
  padding: 14px;
}

.debug:empty {
  display: none;
}

@keyframes wave {
  0%, 100% { height: 20px; }
  50% { height: 54px; }
}

@media (max-width: 980px) {
  .app {
    padding: 16px;
  }

  .topbar,
  .workspace,
  .voice-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .topbar h1 {
    text-align: left;
  }

  .status {
    position: static;
    transform: none;
    justify-self: start;
    margin-top: 12px;
  }
}
