@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@300;400;500&display=swap');

:root {
  --bg:            #0e1117;
  --surface:       #161b22;
  --surface-2:     #1c2128;
  --surface-3:     #222830;
  --border:        #2a3040;
  --border-mid:    #323c4e;
  --border-bright: #404c60;

  --accent:        #4c6ef5;
  --accent-dim:    rgba(76, 110, 245, 0.10);
  --accent-hover:  #6382f7;

  --green:         #2ea043;
  --green-dim:     rgba(46, 160, 67, 0.12);
  --orange:        #d97706;
  --red:           #e5534b;
  --red-dim:       rgba(229, 83, 75, 0.10);

  --text:          #cdd5e0;
  --text-muted:    #445060;
  --text-dim:      #768494;

  --radius:        6px;
  --radius-lg:     10px;
  --radius-xl:     16px;

  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', 'JetBrains Mono', monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; flex-direction: column; min-height: 100vh; }

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  flex-shrink: 0;
}

.tabs { display: flex; gap: 2px; }

.tab {
  padding: 5px 14px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.tab:hover { background: var(--surface-2); color: var(--text); }

.tab.active {
  background: var(--accent-dim);
  color: var(--accent-hover);
  box-shadow: inset 0 0 0 1px rgba(76, 110, 245, 0.25);
}

.main {
  flex: 1;
  padding: 28px 24px;
  max-width: 780px;
  margin: 0 auto;
  width: 100%;
}

.view-header { margin-bottom: 20px; }

.view-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.muted { color: var(--text-dim); font-size: 13px; }

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

.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 100vh;
  padding: 24px;
  text-align: center;
  animation: fade-in 0.4s ease both;
}

.loading-logo {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.loading-logo.error { color: var(--red); }

.loading-msg {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.loading-msg.error { color: var(--red); }

.loading-bar-wrap {
  width: 200px;
  height: 2px;
  background: var(--surface-3);
  border-radius: 1px;
  overflow: hidden;
}

@keyframes bar-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(500%); }
}

.loading-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 0.5s ease;
  position: relative;
  overflow: hidden;
}

.loading-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  animation: bar-shimmer 1.6s ease-in-out infinite;
}

.loading-hint {
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--mono);
  max-width: 320px;
  line-height: 1.7;
}

code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.video-wrap {
  position: relative;
  display: inline-block;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  max-width: 100%;
  border: 1px solid var(--border-mid);
}

/* Corner bracket viewfinder */
.video-wrap::before {
  content: '';
  position: absolute;
  inset: 10px;
  background:
    linear-gradient(var(--accent), var(--accent)) top    left  / 18px 2px no-repeat,
    linear-gradient(var(--accent), var(--accent)) top    left  / 2px 18px no-repeat,
    linear-gradient(var(--accent), var(--accent)) top    right / 18px 2px no-repeat,
    linear-gradient(var(--accent), var(--accent)) top    right / 2px 18px no-repeat,
    linear-gradient(var(--accent), var(--accent)) bottom left  / 18px 2px no-repeat,
    linear-gradient(var(--accent), var(--accent)) bottom left  / 2px 18px no-repeat,
    linear-gradient(var(--accent), var(--accent)) bottom right / 18px 2px no-repeat,
    linear-gradient(var(--accent), var(--accent)) bottom right / 2px 18px no-repeat;
  pointer-events: none;
  z-index: 10;
  opacity: 0.50;
}

.cam-video { display: block; max-width: 100%; height: auto; transform: scaleX(-1); }

.cam-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 8;
}

.dwell-bar-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  z-index: 15;
}

.dwell-bar {
  height: 100%;
  background: var(--green);
  width: 0%;
  transition: width 0.12s linear;
}

.controls.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-accent { background: var(--accent-dim); border-color: rgba(76,110,245,0.25); color: var(--accent-hover); }
.btn-accent:hover { background: rgba(76,110,245,0.16); }

.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-bright); }

.btn-danger { background: var(--red-dim); border-color: rgba(229,83,75,0.20); color: var(--red); }
.btn-danger:hover { background: rgba(229,83,75,0.16); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.control-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

input[type="range"] { accent-color: var(--accent); cursor: pointer; width: 90px; }

.text-input {
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  width: 240px;
}

.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.text-input::placeholder { color: var(--text-muted); }

.status-line {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  min-height: 18px;
}

.enroll-name-row { display: flex; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }

.pose-dots {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  counter-reset: pose-step;
}

.dot {
  counter-increment: pose-step;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.dot::before { content: counter(pose-step); }

.dot.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.dot.done {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

.dot.done::before { content: '\2713'; font-family: system-ui; font-size: 13px; }

.pose-instruction {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.pose-icon { font-size: 22px; line-height: 1; }

.enroll-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
}

@keyframes done-pop {
  0%   { transform: scale(0.6); opacity: 0; }
  70%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.done-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--green-dim);
  border: 2px solid var(--green);
  color: var(--green);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  animation: done-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.enroll-done h3 { font-size: 18px; font-weight: 600; }
.enroll-done p  { color: var(--text-dim); font-size: 13px; }

.gallery-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }

.identity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  transition: border-color 0.12s, background 0.12s;
}

.identity-row:hover { background: var(--surface-2); border-color: var(--border-bright); }

.identity-name { font-weight: 500; font-size: 14px; margin-right: 8px; }

.identity-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.empty-msg { padding: 24px 0; color: var(--text-muted); font-size: 13px; }

.method-choice {
  display: flex;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.method-card {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
  font-family: var(--font);
  text-align: center;
}

.method-card:hover { background: var(--surface-2); border-color: var(--accent); }

.method-icon { font-size: 28px; line-height: 1; }

.method-title { font-size: 14px; font-weight: 600; color: var(--text); }

.method-desc { font-size: 12px; color: var(--text-dim); }

.upload-area {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-input {
  font: inherit;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}

.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.file-item {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 8px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-hint { font-size: 13px; color: var(--text-muted); }

.upload-progress { margin-bottom: 12px; }

.app-footer {
  border-top: 1px solid var(--border);
  padding: 20px 28px 28px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.footer-main {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.footer-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-footer p {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.65;
}

.footer-legal {
  font-family: var(--mono);
  font-size: 10.5px;
}

.footer-clear-btn {
  flex-shrink: 0;
  margin-top: 2px;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .footer-main { flex-direction: column; }
  .footer-clear-btn { align-self: flex-start; }
}

@media (max-width: 520px) {
  .main { padding: 18px 16px; }
  .header { padding: 0 16px; gap: 12px; }
  .text-input { width: 100%; }
  .enroll-name-row { flex-direction: column; }
  .logo { font-size: 11px; }
}
