/* AI Object Vision — custom CSS, dark only */

:root {
  --bg: #0b0e16;
  --elev: #131826;
  --elev2: #1a2033;
  --border: #262c40;
  --border2: #333a52;
  --text: #e8eaf0;
  --muted: #9aa1b5;
  --dim: #6b7188;
  --accent: #9b8cff;
  --accent2: #7c5cff;
  --accent-h: #b3a6ff;
  --accent-soft: rgba(124, 92, 255, 0.14);
  --ok: #2fd38a;
  --danger: #ff6b6b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
  --cam: 640px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 1.25rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); text-decoration: underline; }
h1,h2,h3,h4 { font-weight: 650; line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; margin-top: 1.1rem; }
p { margin: 0 0 .75rem; }
code { background: var(--elev2); border-radius: 4px; padding: .1rem .35rem; font-size: .88em; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: .9rem 0;
  background: rgba(11,14,22,.88);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; }
.brand { font-weight: 700; font-size: 1.05rem; }
.brand .tag {
  font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); border: 1px solid var(--border2); border-radius: 999px;
  padding: .12rem .5rem; margin-left: .45rem; vertical-align: middle;
}
.header-links { display: flex; gap: 1.1rem; }
.header-links a { color: var(--muted); font-size: .9rem; }
.header-links a:hover { color: var(--text); }
.site-footer { border-top: 1px solid var(--border); margin-top: 2.5rem; padding: 1.1rem 0; color: var(--dim); }
main.wrap { padding: 1.75rem 0 2.5rem; }
.intro { margin-bottom: 1.35rem; }

/* Panel */
.panel {
  background: var(--elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.35rem 1.4rem;
}
.panel-title { margin-bottom: .2rem; }
.panel-title-spaced { margin-top: 1.35rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-weight: 600; font-size: .92rem;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  padding: .55rem 1rem; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, transform .08s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent2); color: #fff; }
.btn-primary:hover { background: var(--accent-h); color: #14101f; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border2); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-sm { padding: .32rem .7rem; font-size: .8rem; }

/* Mode pick cards */
.mode-pick {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .7rem; margin: 1rem 0 1.1rem;
}
.mode-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: .3rem;
  text-align: left; background: var(--elev2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: .95rem; cursor: pointer; font: inherit; color: var(--text);
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.mode-card:hover { border-color: var(--accent); background: #202741; }
.mode-card[aria-pressed="true"] {
  border-color: var(--accent); background: #23193f;
  box-shadow: 0 0 0 1px var(--accent);
}
.mode-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode-card-icon { color: var(--accent); display: flex; margin-bottom: .1rem; }
.mode-card-title { font-weight: 650; }
.mode-card-sub { font-size: .8rem; color: var(--muted); }

/* Source cards */
.source-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .65rem; margin: .9rem 0 0;
}
.source-card {
  display: flex; flex-direction: column; gap: .2rem; text-align: left;
  background: var(--elev2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: .85rem .9rem; cursor: pointer;
  font: inherit; color: var(--text);
  transition: border-color .12s, background .12s;
}
.source-card:hover { border-color: var(--accent); background: #202741; }
.source-card[aria-pressed="true"] { border-color: var(--accent); background: #23193f; }
.source-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.source-card-title { font-weight: 650; font-size: .92rem; }
.source-card-sub { font-size: .78rem; color: var(--muted); }

.field-row { margin: .85rem 0; max-width: 280px; }
.field-row label { display: block; margin-bottom: .3rem; font-size: .88rem; color: var(--muted); }
.select, .text-input, .file-input {
  width: 100%; font: inherit; color: var(--text); background: var(--elev2);
  border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: .5rem .7rem;
}
.select:focus, .text-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Load status */
.load-status { margin-top: 1.1rem; }
.progress-track {
  height: 7px; border-radius: 999px; background: var(--elev2);
  overflow: hidden; margin-bottom: .45rem;
}
.progress-fill {
  height: 100%; background: var(--accent2); border-radius: 999px;
  transition: width .25s ease;
}
.progress-fill.indeterminate {
  width: 38% !important;
  background: linear-gradient(90deg, transparent, var(--accent2), transparent);
  animation: slide 1.15s ease-in-out infinite;
}
@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(260%); }
}
.load-row { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
#load-text { color: var(--muted); font-size: .88rem; }
.load-hint {
  margin: .45rem 0 0; padding: .5rem .7rem;
  background: var(--accent-soft); border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent); color: var(--muted); font-size: .85rem; line-height: 1.45;
}
.load-error {
  margin-top: .7rem; padding: .7rem .9rem; background: #2a1620;
  border: 1px solid #4a2333; border-radius: var(--radius-sm);
  color: #ffb4c2; font-size: .88rem; line-height: 1.5;
}
.load-error strong { color: #ff8fa3; }

/* Demo toolbar / tabs */
.demo-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; margin-bottom: .55rem;
}
.tabs { display: flex; gap: .45rem; flex-wrap: wrap; }
.tabs button {
  font: inherit; font-weight: 600; font-size: .9rem;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border2); border-radius: var(--radius-sm);
  padding: .45rem .9rem; cursor: pointer; transition: all .12s;
}
.tabs button:hover { color: var(--text); border-color: var(--muted); }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tabs button.active { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.tabs-secondary { margin-bottom: 1.1rem; }
.tabs-secondary button { font-size: .82rem; padding: .35rem .75rem; border-color: var(--border); }
.tabs-secondary button.active {
  background: var(--elev2); color: var(--text); border-color: var(--accent);
}

/* Camera + results */
.demo-grid {
  display: grid;
  grid-template-columns: minmax(0, var(--cam)) minmax(260px, 1fr);
  gap: 1.35rem; align-items: start;
}
.camera-frame {
  position: relative; width: 100%; max-width: var(--cam);
  aspect-ratio: 4/3; background: #000; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
}
.camera-frame video, .camera-frame canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.camera-frame video { object-fit: cover; }
.camera-frame canvas { object-fit: contain; }
#overlay { pointer-events: none; }

.frame-prompt {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(11,14,22,.78); z-index: 5;
}
.frame-prompt-inner {
  display: flex; flex-direction: column; align-items: center; gap: .55rem;
  text-align: center; padding: 1.1rem;
}
.frame-prompt-inner p { margin: 0; max-width: 200px; }
.empty-icon { color: var(--dim); opacity: .85; }

.capture-bar { margin-top: .7rem; display: flex; gap: .5rem; }
.privacy-note { margin-top: .55rem; }
.demo-foot { margin-top: 1.25rem; }

.results-pane {
  background: var(--elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; min-height: 260px;
}
.results-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; margin-bottom: .7rem;
}
.results-header h3 { margin: 0; }
.results-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.results-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 1.6rem 1rem; gap: .65rem;
}
.results-empty p { margin: 0; max-width: 220px; }
.empty-state { color: var(--dim); opacity: .7; }

.results-list { list-style: none; margin: 0; padding: 0; }
.results-list li {
  display: flex; align-items: center; flex-wrap: wrap; gap: .55rem;
  padding: .5rem 0; border-bottom: 1px solid var(--border);
}
.results-list li:last-child { border-bottom: none; }
.result-label { flex: 1; font-weight: 550; }
.result-score { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .88rem; }
.result-bar-track {
  flex: 0 0 100%; height: 5px; border-radius: 999px; background: var(--elev2); overflow: hidden;
}
.result-bar { display: block; height: 100%; background: var(--accent2); border-radius: 999px; }
.style-result { flex-direction: column; align-items: flex-start !important; gap: .55rem !important; }

.meta-panel {
  margin-top: .65rem; padding: .65rem .85rem; background: var(--elev2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .76rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  max-height: 240px; overflow-y: auto; color: var(--muted);
}

/* Modals */
.modal {
  background: var(--elev); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0; max-width: 520px; width: 92vw; box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(4,5,9,.72); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); font-size: 1rem;
}
.modal-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 1rem; cursor: pointer; line-height: 1; padding: .2rem;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.1rem; max-height: 70vh; overflow-y: auto; }
.modal-body ul { padding-left: 1.2rem; }
.modal-body li { margin-bottom: .35rem; }
.link-list { padding-left: 1.1rem; margin: .6rem 0 1rem; }
.info-table { width: 100%; border-collapse: collapse; }
.info-table th, .info-table td {
  text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); font-size: .9rem;
}
.info-table th { color: var(--muted); font-weight: 550; width: 34%; }
pre.flow {
  background: var(--elev2); border-radius: var(--radius-sm);
  padding: .65rem .9rem; line-height: 1.5; overflow-x: auto; font-size: .86rem;
}

@media (max-width: 900px) {
  .demo-grid { grid-template-columns: 1fr; }
  .results-pane { min-height: 180px; }
}
@media (max-width: 520px) {
  h1 { font-size: 1.5rem; }
  .mode-pick, .source-grid { grid-template-columns: 1fr 1fr; }
  .header-links { gap: .75rem; }
  .header-links a { font-size: .82rem; }
}
