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

:root {
  color-scheme: dark;
  --bg: #090d18;
  --panel: #101827;
  --line: #243147;
  --text: #edf3ff;
  --muted: #8b9ab1;
  --accent: #8b7cff;
  --accent2: #54d8c5;
  --shadow: 0 18px 55px #0004;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 70% -20%, #20264b 0, transparent 42%), var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
}
button, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  min-height: 100vh; padding: 27px 18px 20px; display: flex; flex-direction: column;
  background: #0c1220b8; border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; margin: 2px 4px 54px; color: var(--text); text-decoration: none; font: 700 18px 'Space Grotesk'; letter-spacing: .5px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(140deg, #a38cff, #55d9c8); color: #0b1020; font-size: 24px; box-shadow: 0 7px 25px #8b7cff44; }
.brand-accent { color: #a99cff; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font: 500 8px 'DM Sans'; letter-spacing: 2px; }
.side-label, .eyebrow { color: #8c9bb2; font-size: 10px; font-weight: 700; letter-spacing: 1.8px; }
.side-label { padding: 0 12px 13px; }
.nav-list { display: grid; gap: 7px; }
.nav-btn { display: flex; align-items: center; gap: 13px; padding: 13px 14px; border: 0; border-radius: 12px; background: transparent; color: #aab6c9; text-align: left; font-weight: 600; }
.nav-btn span { width: 20px; font-size: 19px; text-align: center; }
.nav-btn:hover, .nav-btn.active { background: linear-gradient(100deg, #8b7cff24, #54d8c50c); color: #fff; }
.nav-btn.active { box-shadow: inset 3px 0 #9c8dff; }
.sidebar-bottom { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid var(--line); }
.api-indicator { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 600; }
.api-indicator i, .status-pill i, .camera-live i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #e5b45d; box-shadow: 0 0 10px currentColor; }
.api-indicator i.online, .status-pill i.online { background: #55d8a4; }
.sidebar-bottom p, .version { color: var(--muted); font-size: 11px; }
.version { font-size: 9px; letter-spacing: 1.5px; }

.main-area { display: flex; flex-direction: column; width: 100%; max-width: 1500px; min-height: 100vh; margin: 0 auto; padding: 29px clamp(20px, 5vw, 72px) 20px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 6px 0 0; font: 600 27px 'Space Grotesk'; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.status-pill { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 30px; color: var(--muted); font-size: 11px; }
.icon-btn, .round-btn { width: 39px; height: 39px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); font-size: 18px; }

.view { display: none; flex: 1; min-height: 0; }
.view.active { display: flex; flex-direction: column; }
.welcome { max-width: 690px; margin: auto; padding: 38px 0 20px; text-align: center; }
.orb { display: grid; width: 86px; height: 86px; place-items: center; margin: 0 auto 25px; border-radius: 28px; background: radial-gradient(circle at 30% 20%, #b7a9ff, #5c55b7 52%, #1a9e9c); box-shadow: 0 0 70px #8276ff44; transform: rotate(-7deg); }
.orb span { color: white; font: 700 24px 'Space Grotesk'; transform: rotate(7deg); }
.welcome h2 { margin: 12px 0; font: 600 clamp(28px, 4vw, 43px) 'Space Grotesk'; }
.welcome h2 em { color: #a99cff; font-style: normal; }
.muted { color: var(--muted); line-height: 1.65; }
.welcome > .muted { max-width: 560px; margin: 0 auto; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 32px; }
.suggestion { padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: #131d2d; color: #c7d2e4; font-size: 12px; }
.suggestion span { padding-left: 9px; color: var(--accent2); }

.chat-messages { display: flex; flex: 1; flex-direction: column; gap: 16px; width: 100%; max-width: 850px; margin: 12px auto 0; padding: 8px 4px 20px; overflow: auto; }
.message { display: flex; align-items: flex-start; gap: 12px; max-width: 92%; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.avatar { display: grid; flex: 0 0 32px; width: 32px; height: 32px; place-items: center; border-radius: 11px; background: linear-gradient(140deg, #9182ff, #4dcbbd); color: #101528; font: 700 12px 'Space Grotesk'; }
.user .avatar { background: #25334a; color: #e2eaff; }
.bubble { padding: 13px 15px; border: 1px solid var(--line); border-radius: 5px 15px 15px 15px; background: var(--panel); font-size: 14px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.user .bubble { border-color: #4b477b; border-radius: 15px 5px 15px 15px; background: #252348; }
.message-tools { display: flex; gap: 12px; margin-top: 7px; }
.speak-btn { padding: 4px 0; border: 0; background: transparent; color: var(--accent2); font-size: 11px; }
.speak-btn.is-speaking { color: #ff8792; }
.composer-wrap { width: 100%; max-width: 850px; margin: 10px auto 20px; }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 12px 13px 12px 18px; border: 1px solid #36435c; border-radius: 18px; background: #121b2b; box-shadow: var(--shadow); }
.composer textarea { flex: 1; min-height: 27px; max-height: 130px; padding: 5px 0; resize: none; outline: 0; border: 0; background: transparent; color: var(--text); }
.composer textarea::placeholder { color: #71819b; }
.composer-actions { display: flex; gap: 8px; }
.send-btn { width: 42px; height: 39px; border: 0; border-radius: 12px; background: linear-gradient(135deg, #9c8cff, #57d9c6); color: #101526; font-size: 20px; }
.composer-foot { display: flex; justify-content: space-between; gap: 12px; padding: 10px 5px; color: #71819b; font-size: 10px; }
.wake-btn { padding: 0; border: 0; background: transparent; color: #a99cff; font-size: 11px; }
.pulse-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #a99cff; }
.wake-btn.listening .pulse-dot { background: #5ce0ad; box-shadow: 0 0 0 5px #5ce0ad22; }

.section-intro { display: flex; align-items: center; gap: 15px; margin: 28px 0 22px; }
.section-intro h2 { margin: 0 0 4px; font: 600 22px 'Space Grotesk'; }
.section-intro p { margin: 0; font-size: 13px; }
.section-icon { display: grid; width: 47px; height: 47px; place-items: center; border-radius: 15px; background: #8b7cff22; color: #b4aaff; font-size: 24px; }
.vision-grid, .settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; width: 100%; max-width: 1050px; margin: 0 auto; }
.panel { padding: 21px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, #121d2d, #0f1725); box-shadow: var(--shadow); }
.upload-zone { display: flex; min-height: 225px; flex-direction: column; align-items: center; justify-content: center; gap: 9px; border: 1px dashed #485779; border-radius: 14px; background: #171f332e; color: var(--text); cursor: pointer; }
.upload-zone:hover { border-color: var(--accent); background: #8b7cff0c; }
.upload-icon { color: #a99cff; font-size: 30px; }
.upload-zone strong { font: 600 16px 'Space Grotesk'; }
.upload-zone span { color: var(--muted); font-size: 11px; }
.upload-zone .browse-link { color: var(--accent2); font-weight: 700; }
.preview-wrap { position: relative; margin-bottom: 18px; text-align: center; }
.preview-wrap img { max-width: 100%; max-height: 260px; border-radius: 12px; object-fit: contain; }
.remove-btn { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: #0a0f1ddd; color: white; font-size: 20px; }
.field-label { display: block; margin: 20px 0 8px; font-size: 12px; font-weight: 700; }
.field-label span { float: right; color: var(--muted); font-size: 9px; letter-spacing: 1px; }
.vision-prompt, .select-field { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 11px; outline: 0; background: #0c1422; color: var(--text); font-size: 13px; }
.vision-prompt { resize: vertical; }
.primary-btn, .secondary-btn { padding: 12px 17px; border: 0; border-radius: 11px; font-size: 12px; font-weight: 700; transition: .2s; }
.primary-btn { background: linear-gradient(120deg, #9b8cff, #5ad9c7); color: #0b1321; }
.primary-btn:hover:not(:disabled), .send-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.primary-btn.full { width: 100%; margin-top: 15px; }
.primary-btn span { float: right; font-size: 17px; line-height: 12px; }
.secondary-btn { border: 1px solid #35445d; background: #202b3e; color: #d8e2f2; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; }
.panel-heading h3, .setting-card h3, .camera-result h3 { margin: 7px 0; font: 600 18px 'Space Grotesk'; }
.result-tag { padding: 6px 8px; border: 1px solid #7669cf66; border-radius: 7px; color: #a99cff; font-size: 9px; letter-spacing: 1.4px; }
.result-content { display: flex; min-height: 225px; flex-direction: column; align-items: center; justify-content: center; padding: 15px 5px; color: #dce5f3; text-align: center; white-space: pre-wrap; line-height: 1.65; font-size: 13px; overflow-wrap: anywhere; }
.result-content p { margin: 10px 0 4px; }
.result-content small { color: var(--muted); font-size: 11px; }
.empty-visual { color: #9a8cff; font-size: 36px; opacity: .8; }
.speak-result { width: 100%; padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px; background: #172337; color: #aeece3; font-size: 11px; }
.speak-result.is-speaking { color: #ff8792; }
.camera-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, .7fr); gap: 18px; width: 100%; max-width: 1100px; margin: 0 auto; }
.camera-stage { position: relative; display: grid; height: 340px; place-items: center; overflow: hidden; border: 1px solid #28364e; border-radius: 13px; background: #070b13; }
.camera-stage video { display: block; width: 100%; height: 100%; object-fit: contain; transform: scaleX(-1); }
.camera-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; background: radial-gradient(circle, #1c2940, #090d18); color: var(--muted); }
.camera-placeholder[hidden], .camera-live[hidden] { display: none; }
.camera-placeholder span { color: #9d8eff; font-size: 40px; }
.camera-placeholder b { color: #e5ebf7; }
.camera-placeholder small { font-size: 11px; }
.camera-live { position: absolute; top: 12px; left: 12px; padding: 7px 9px; border-radius: 8px; background: #0b1422d9; font-size: 9px; letter-spacing: 1px; }
.camera-live i { background: #ff667b; }
.camera-controls { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
.camera-error { min-height: 16px; margin: 10px 0 0; color: #ff8792; font-size: 11px; }
.camera-result { display: flex; flex-direction: column; }
.camera-result .result-content { flex: 1; }

.setting-card h3 { margin-bottom: 20px; }
.setting-row { display: flex; justify-content: space-between; gap: 15px; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.setting-row b { color: #dce7f8; font-size: 11px; }
.setting-note { margin: 16px 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.setting-note code { color: #b7aaff; }
.select-field { max-width: 260px; }
.main-footer { margin-top: auto; padding: 20px 0 4px; color: #607089; text-align: center; font-size: 10px; }
.main-footer span { padding: 0 5px; color: var(--accent2); }
.toast { position: fixed; z-index: 10; bottom: 25px; left: 50%; padding: 11px 16px; border: 1px solid #53647e; border-radius: 11px; background: #25334a; color: white; font-size: 12px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 20px); transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

body.light { color-scheme: light; --bg: #f3f5fb; --panel: #fff; --line: #dce2ee; --text: #182238; --muted: #66738b; --shadow: 0 15px 45px #24375b12; background: radial-gradient(ellipse at 70% -20%, #dfe0ff, transparent 45%), var(--bg); }
body.light .sidebar { background: #ffffffb8; }
body.light .nav-btn { color: #526079; }
body.light .nav-btn.active { color: #2b3150; }
body.light .panel { background: linear-gradient(145deg, #fff, #f8faff); }
body.light .composer { border-color: #dce2ee; background: #fff; }
body.light .composer textarea, body.light .vision-prompt, body.light .select-field { background: #fff; color: #182238; }
body.light .bubble { color: #182238; }
body.light .user .bubble { background: #eeecff; }
body.light .suggestion { background: #fff; color: #3c4962; }
body.light .secondary-btn, body.light .speak-result { background: #edf1fa; color: #33415c; }
body.light .setting-row b { color: #24304a; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 205px 1fr; }
  .sidebar { padding-inline: 13px; }
  .vision-grid, .settings-grid, .camera-layout { grid-template-columns: 1fr; }
  .camera-stage { height: 300px; }
}
@media (max-width: 650px) {
  .app-shell { display: block; }
  .sidebar { height: auto; min-height: auto; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0; font-size: 15px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand small, .side-label, .sidebar-bottom { display: none; }
  .nav-list { display: flex; gap: 3px; }
  .nav-btn { gap: 0; padding: 9px; border-radius: 10px; font-size: 0; }
  .nav-btn span { font-size: 18px; }
  .main-area { min-height: calc(100vh - 62px); padding: 18px 14px 12px; }
  .topbar { padding-bottom: 16px; }
  .topbar h1 { font-size: 22px; }
  .status-pill { padding: 10px; font-size: 0; }
  .status-pill i { margin: 0; }
  .icon-btn { width: 36px; height: 36px; }
  .welcome { padding: 30px 0 15px; }
  .welcome h2 { font-size: 30px; }
  .suggestions { gap: 7px; }
  .suggestion { padding: 9px; font-size: 10px; }
  .composer-foot { font-size: 9px; }
  .composer-foot > span { text-align: right; }
  .section-intro { margin: 20px 0; }
  .panel { padding: 15px; }
  .camera-stage { height: 250px; }
  .camera-controls button { flex: 1; }
  .message { max-width: 98%; }
  .chat-messages { padding-bottom: 12px; }
  .vision-grid, .camera-layout, .settings-grid { gap: 12px; }
}
