:root {
  color-scheme: light;
  --bg: #f6f8fa;
  --panel: #fff;
  --line: #e7ebee;
  --muted: #697586;
  --text: #202c3a;
  --accent: #12816a;
  --accent-soft: #edf7f3;
  --danger: #c44444;
  --warning: #ac7017;
}

* { box-sizing: border-box; }
[hidden], .icon-sprite { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .42; }
a { color: inherit; text-decoration: none; }
button, a, summary, input, select, textarea { outline-offset: 4px; }
:focus-visible { outline: 2px solid var(--accent); }
.icon { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.app-header { position: sticky; z-index: 10; top: 0; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.header-inner { max-width: 1600px; min-height: 76px; margin: auto; padding: 12px 32px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand, .header-actions { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 39px; height: 42px; border-radius: 12px; background: var(--accent); color: #fff; }
.brand-mark .icon { width: 25px; height: 25px; }
.brand strong { display: block; font-size: 16px; font-weight: 650; letter-spacing: .01em; }
.brand small { display: block; margin-top: 1px; color: #8a95a3; font-size: 9px; letter-spacing: .15em; }
.header-actions { gap: 10px; }
.connection-state { display: inline-flex; align-items: center; gap: 8px; margin-right: 10px; color: var(--muted); font-size: 12px; }
.state-dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: #a6b0ba; box-shadow: 0 0 0 4px #f1f3f5; }
.connection-state[data-state="online"] { color: var(--accent); }
.connection-state[data-state="online"] .state-dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.connection-state[data-state="connecting"] .state-dot { background: var(--warning); animation: pulse 1.1s infinite; }
.connection-state[data-state="error"] { color: var(--danger); }
.connection-state[data-state="error"] .state-dot { background: var(--danger); box-shadow: 0 0 0 4px #fff1f0; }

.primary-button, .secondary-button, .ghost-button, .camera-command { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 36px; padding: 8px 13px; border: 1px solid transparent; border-radius: 8px; font-size: 12px; font-weight: 550; line-height: 1.4; transition: background .15s, border-color .15s; }
.primary-button { background: var(--accent); color: #fff; box-shadow: 0 2px 3px #102a1710; }
.primary-button:hover:not(:disabled) { background: #096a56; }
.secondary-button { color: #405062; border-color: #dce2e7; background: var(--panel); }
.secondary-button:hover:not(:disabled) { background: #f5f8f9; border-color: #a5bdb5; }
.ghost-button { color: var(--muted); background: transparent; }
.ghost-button:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }

.app-shell { max-width: 1600px; margin: auto; padding: 28px 32px 32px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 10px; font-weight: 650; letter-spacing: .16em; }
h1 { margin: 0; font-size: 25px; line-height: 1.4; letter-spacing: -.035em; font-weight: 650; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.workspace-tag { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; color: #7b8795; font-size: 11px; background: #fff8; }
.mobile-shortcuts { display: none; }
.workbench { display: grid; grid-template-columns: 324px minmax(0, 1fr); align-items: start; gap: 22px; }
.settings-rail { display: grid; gap: 12px; min-width: 0; }
.main-workspace { display: grid; gap: 18px; min-width: 0; }
#workspace, #deviceSettings, #interaction { scroll-margin-top: 100px; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 2px 5px #20354003; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
h2 { display: flex; align-items: center; gap: 9px; margin: 0; font-size: 14px; font-weight: 650; letter-spacing: .01em; }
h2 .icon { width: 18px; height: 18px; color: #6c7f8d; }
.muted-label { color: #8a95a3; font-size: 10px; }
.field { display: grid; min-width: 0; gap: 7px; }
.field > span { color: #526174; font-size: 11px; font-weight: 550; }
.field small, .field-hint { margin: 0; color: #7a8796; font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; }
.stack { display: grid; gap: 12px; }
input, select, textarea { width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid #e0e5e9; border-radius: 7px; color: var(--text); background: #fff; font-size: 13px; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: #9aa4b0; }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: #b8c6c0; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: #70b6a4; box-shadow: 0 0 0 3px #12816a0b; }
input:disabled, select:disabled, textarea:disabled { color: #8d98a4; background: #f7f9fa; cursor: not-allowed; }
textarea { resize: vertical; font: 11px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; }
.toggle-field { display: flex; align-items: center; gap: 9px; color: #526174; font-size: 12px; cursor: pointer; }
.toggle-field input { flex-shrink: 0; width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }

.device-panel { padding: 18px; }
.device-dock { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 16px; }
.device-card:disabled { opacity: 1; }
.device-empty { grid-column: 1 / -1; margin: 0; padding: 16px 12px; border: 1px dashed #dce4e9; border-radius: 8px; background: #fbfcfd; color: #8a95a3; text-align: center; font-size: 11px; }
.device-slot { position: relative; min-width: 0; }
.device-card { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 61px; padding: 10px 22px 10px 10px; border: 1px solid #e4e9ec; border-radius: 8px; color: #637283; background: #fff; text-align: left; transition: border-color .15s, background .15s; }
.device-card:hover:not(:disabled) { border-color: #8ebfb0; background: #fafdfb; }
.device-card.active { color: var(--accent); border-color: #92c9b9; background: var(--accent-soft); }
.device-screen { display: grid; gap: 3px; min-width: 0; }
.device-screen strong { overflow: hidden; color: inherit; font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.device-screen small { font: 9px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; opacity: .7; }
.device-keyline { flex-shrink: 0; width: 14px; height: 21px; order: -1; border: 1.5px solid currentColor; border-radius: 4px; opacity: .75; }
.device-keyline::after { content: ""; display: block; width: 4px; height: 1px; margin: 14px auto 0; background: currentColor; }
.device-remove { position: absolute; top: 5px; right: 4px; display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 4px; color: #98a4ae; background: transparent; font-size: 16px; }
.device-remove:hover:not(:disabled) { color: var(--danger); background: #fff1f0; }

summary { list-style: none; cursor: pointer; user-select: none; }
summary::-webkit-details-marker { display: none; }
.module-summary { display: flex; align-items: center; gap: 11px; min-height: 75px; padding: 16px 18px; border-radius: 12px; }
.module-summary:hover { background: #fbfcfd; }
.module-icon { display: grid; flex-shrink: 0; place-items: center; width: 32px; height: 34px; border: 1px solid #edf0f2; border-radius: 8px; color: #6c7f8d; background: #fafbfc; }
.module-icon .icon { width: 17px; height: 17px; }
.summary-copy { display: grid; gap: 4px; min-width: 0; flex: 1; }
.summary-copy strong { font-size: 13px; font-weight: 600; }
.summary-copy small { color: #8a95a3; font-size: 10px; }
.summary-badge { padding: 3px 6px; border-radius: 4px; color: #8a95a3; background: #f2f5f7; font-size: 9px; white-space: nowrap; }
.summary-badge[data-active="true"] { color: var(--accent); background: var(--accent-soft); }
.summary-chevron { display: inline-block; flex-shrink: 0; width: 6px; height: 6px; margin: 0 2px 3px 4px; border: solid #9aa4b0; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); transition: transform .15s; }
details[open] > summary .summary-chevron { margin-bottom: -2px; transform: rotate(225deg); }
.module-body { display: grid; gap: 14px; padding: 0 18px 18px; }
.device-settings { margin-top: 14px; border-top: 1px solid #edf0f2; }
.device-settings > .module-summary { min-height: 68px; padding-inline: 0; border-radius: 0; }
.device-settings > .module-body { padding-inline: 0; }
.subdetails { margin-top: 14px; padding-top: 12px; border-top: 1px solid #edf0f2; }
.module-body > .subdetails { margin-top: 0; }
.subdetails > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #7b8795; font-size: 11px; }
.subdetails > .stack { margin-top: 14px; }
.transport-box { padding: 11px 12px; border: 1px solid #edf1f2; border-radius: 7px; background: #f8fafb; }
.transport-status { margin: 0 0 5px; color: #56736b; font-size: 11px; font-weight: 550; overflow-wrap: anywhere; }
.transport-status[data-transport="fallback"] { color: var(--warning); }
.resolved-url { margin: 7px 0 0; color: #8a95a3; font: 9px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.language-controls { display: grid; gap: 12px; }
.role-controls { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.role-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.role-button[aria-pressed="true"] { border-color: #92c9b9; color: var(--accent); background: var(--accent-soft); }
.role-button[aria-busy="true"] { border-color: var(--warning); }
#agentSwitchControls > .field-hint { margin-top: 10px; }

.location-card { display: flex; align-items: center; gap: 12px; min-height: 94px; padding: 17px 20px; }
.location-icon { display: grid; flex-shrink: 0; place-items: center; width: 39px; height: 42px; border-radius: 10px; color: var(--accent); background: var(--accent-soft); }
.location-content { flex: 1; min-width: 0; }
.location-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.location-heading strong { color: #7a8796; font-size: 10px; font-weight: 500; }
.location-heading span { padding: 1px 5px; border-radius: 4px; color: #8a95a3; background: #f3f5f7; font-size: 9px; }
.location-heading span[data-state="located"] { color: var(--accent); background: var(--accent-soft); }
.location-name { margin: 5px 0 0; font-size: 14px; font-weight: 600; }
.location-card p { overflow-wrap: anywhere; }
.location-card p:empty { display: none; }
#currentLocationDescription { margin: 3px 0 0; color: #6f7e8e; font-size: 12px; }
#currentLocationBeacon { margin-top: 4px; font-size: 10px; }
.location-caption { align-self: flex-start; color: #9aa4b0; font-size: 10px; }

.interaction-grid { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); align-items: stretch; gap: 18px; }
.media-column, .voice-column { display: grid; align-content: start; gap: 16px; min-width: 0; }
.media-panel, .voice-panel { padding: 18px; }
.pill { padding: 3px 8px; border: 1px solid #e9edf0; border-radius: 5px; color: #8a95a3; background: #fafbfc; font-size: 10px; }
.pill.active { color: var(--accent); border-color: #cfe7dc; background: var(--accent-soft); }
.camera-stage { position: relative; width: 100%; aspect-ratio: 16 / 10; overflow: hidden; border: 1px solid #e5ebef; border-radius: 9px; background: #f7f9fb; }
.camera-stage video { display: block; width: 100%; height: 100%; object-fit: cover; }
.camera-placeholder { position: absolute; inset: 0; display: grid; justify-items: center; align-content: center; text-align: center; color: #8a95a3; }
.camera-placeholder.hidden { display: none; }
.camera-placeholder-icon { display: grid; place-items: center; width: 49px; height: 49px; margin-bottom: 14px; border: 1px solid #e1e7ec; border-radius: 14px; color: #9aa9b6; background: #fff; box-shadow: 0 3px 8px #23334304; }
.camera-placeholder-icon .icon { width: 23px; height: 23px; }
.camera-placeholder strong { font-size: 12px; font-weight: 500; color: #7a8796; }
.camera-placeholder p { margin: 5px 0 0; font-size: 10px; }
.frame-corners { position: absolute; inset: 13px; pointer-events: none; }
.frame-corners::before, .frame-corners::after { position: absolute; content: ""; width: 16px; height: 16px; border: solid #c5d2da; }
.frame-corners::before { top: 0; left: 0; border-width: 1px 0 0 1px; border-radius: 3px 0 0; }
.frame-corners::after { right: 0; bottom: 0; border-width: 0 1px 1px 0; border-radius: 0 0 3px; }
.camera-toolbar { display: flex; flex-wrap: wrap; gap: 3px; margin: 12px 0 8px; }
.camera-toolbar .secondary-button, .camera-toolbar .ghost-button { min-height: 32px; padding: 6px 9px; font-size: 11px; }
.camera-command-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 13px; }
.camera-command { color: #587363; border-color: #dce8e1; background: #f5faf7; padding: 9px 6px; font-size: 11px; }
.camera-command.manual { color: var(--accent); border-color: #cde3da; background: var(--accent-soft); }
.camera-command:hover:not(:disabled) { border-color: #8ebfb0; background: #e8f3ee; }
.voice-orb-wrap { display: flex; align-items: center; gap: 16px; }
.voice-orb { display: grid; place-content: center; justify-items: center; gap: 3px; flex-shrink: 0; width: 105px; min-height: 110px; border: 1px solid #cce3d9; border-radius: 12px; color: var(--accent); background: #f1f8f5; text-align: center; user-select: none; touch-action: none; }
.voice-orb .icon { width: 22px; height: 22px; margin-bottom: 7px; }
.voice-orb strong { font-size: 12px; font-weight: 600; }
.voice-orb small { color: #8aa69a; font-size: 10px; }
.voice-orb:hover:not(:disabled) { background: #e8f4ee; border-color: #8ebfb0; }
.voice-orb.recording { color: var(--danger); border-color: #e4b7b7; background: #fff3f2; animation: pulse 1.1s infinite; }
.voice-visualizer { min-width: 0; flex: 1; }
#levelCanvas { display: block; width: 100%; height: 67px; opacity: .7; }
.voice-visualizer p { margin: 4px 0 0; color: #8a95a3; font-size: 10px; text-align: center; }

.conversation-panel { display: flex; flex-direction: column; min-height: 540px; overflow: hidden; contain: size; }
.conversation-panel > .panel-heading { min-height: 63px; margin: 0; padding: 12px 18px; border-bottom: 1px solid #edf0f2; }
.conversation-panel .ghost-button { min-height: 30px; font-size: 11px; }
.conversation { display: flex; flex-direction: column; gap: 14px; flex: 1; height: 430px; min-height: 0; padding: 20px 18px; overflow: auto; scrollbar-color: #d9e2df transparent; scrollbar-width: thin; }
.empty-state { display: grid; justify-items: center; align-content: center; gap: 10px; margin: auto; color: #96a1ae; text-align: center; font-size: 12px; }
.empty-icon { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 5px; border: 1px solid #e6ece9; border-radius: 17px; color: #97b4a7; background: #f6faf8; transform: rotate(-7deg); }
.empty-icon .icon { width: 25px; height: 25px; }
.empty-state strong { color: #6b7b89; font-size: 13px; font-weight: 500; }
.empty-state p { margin: 0; font-size: 11px; line-height: 1.9; }
.message { flex-shrink: 0; max-width: 88%; padding: 10px 12px; border: 1px solid transparent; border-radius: 10px; font-size: 13px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user { align-self: flex-end; color: #256954; background: #eaf5ee; border-color: #dceee2; border-bottom-right-radius: 3px; }
.message.assistant { align-self: flex-start; color: #495a69; background: #f4f6f8; border-color: #e9edf0; border-bottom-left-radius: 3px; }
.message.system { align-self: center; max-width: 100%; padding: 3px 8px; color: #99a3ae; font-size: 10px; text-align: center; }
.text-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 14px; border-top: 1px solid #edf0f2; }
.text-form input { background: #f9fafb; font-size: 12px; }
.text-form .primary-button { padding-inline: 14px; }

.diagnostics-panel { overflow: hidden; }
.diagnostics-panel .module-summary { min-height: 70px; }
.diagnostics-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.audio-stats { margin: 0; color: #7b8795; font: 10px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; }
.diagnostics { height: 260px; overflow: auto; padding: 13px 15px; border-radius: 8px; color: #647687; background: #f7f9fb; border: 1px solid #e9edf0; scrollbar-color: #d9e2df transparent; font: 10px/1.8 ui-monospace, SFMono-Regular, Consolas, monospace; }
.log-entry { padding: 2px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-entry.success { color: var(--accent); }
.log-entry.error { color: var(--danger); }
.log-entry.warning { color: var(--warning); }
.log-entry.debug { color: #9aa4b0; }
.workspace-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; color: #a0a9b3; font-size: 10px; }

@keyframes pulse { 50% { opacity: .55; } }
@media (min-width: 1200px) {
  .settings-rail { max-height: calc(100dvh - 105px); overflow-y: auto; position: sticky; top: 94px; scrollbar-width: thin; scrollbar-color: #d9e2df transparent; }
}
@media (max-width: 1199px) {
  .workbench { grid-template-columns: 290px minmax(0, 1fr); gap: 16px; }
  .interaction-grid { grid-template-columns: minmax(0, 1fr); }
  .media-column { grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); align-items: start; }
  .voice-orb-wrap { flex-direction: column; }
  .voice-visualizer { width: 100%; }
  .voice-orb { width: 100%; }
  .conversation-panel { min-height: 390px; order: -1; }
  .conversation { flex: auto; height: 300px; }
  .location-caption { display: none; }
  .module-summary { gap: 8px; padding: 14px; }
  .module-body { padding: 0 14px 16px; }
}
@media (max-width: 960px) {
  .header-inner { padding-inline: 20px; }
  .app-shell { padding: 22px 20px; }
  .workbench { grid-template-columns: 270px minmax(0, 1fr); }
  .media-column { grid-template-columns: minmax(0, 1fr); }
  .voice-orb-wrap { flex-direction: row; }
  .voice-orb { width: 105px; }
  .device-panel { padding: 14px; }
}
@media (max-width: 720px) {
  .header-inner { flex-wrap: wrap; gap: 14px; padding: 14px 16px; }
  .brand strong { font-size: 14px; }
  .brand-mark { width: 33px; height: 36px; border-radius: 9px; }
  .brand small { font-size: 8px; }
  .header-actions { flex: 1; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
  .connection-state { margin-right: 4px; font-size: 11px; }
  .header-actions .primary-button, .header-actions .secondary-button { min-height: 33px; padding: 7px 10px; font-size: 11px; }
  .app-shell { padding: 22px 16px; }
  .page-heading { margin-bottom: 18px; }
  h1 { font-size: 21px; }
  .workspace-tag { display: none; }
  .mobile-shortcuts { display: flex; gap: 10px; margin-bottom: 18px; }
  .mobile-shortcuts a { flex: 1; padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: #687b71; font-size: 11px; text-align: center; }
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .settings-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 10px; }
  .device-panel { grid-column: 1 / -1; }
  .module-summary { gap: 8px; min-height: 68px; padding: 12px; }
  .module-icon { display: none; }
  .summary-badge { font-size: 8px; padding: 2px 4px; }
  .summary-copy strong { font-size: 11px; }
  .summary-copy small { font-size: 9px; }
  .module-body { padding-inline: 12px; }
  .device-dock { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .main-workspace { gap: 14px; }
  .location-card { min-height: 83px; padding: 15px; }
  .media-column { grid-template-columns: minmax(0, 1fr); }
  .voice-orb { width: 105px; }
  input, select { font-size: 16px; }
  .text-form input { font-size: 16px; }
  .conversation { height: 330px; }
  .workspace-footer { font-size: 9px; }
}
@media (max-width: 430px) {
  .header-inner { gap: 12px; }
  .header-actions { flex-basis: 100%; justify-content: flex-start; }
  .connection-state { margin-right: auto; }
  #workspace, #deviceSettings, #interaction { scroll-margin-top: 140px; }
  .settings-rail { grid-template-columns: minmax(0, 1fr); }
  .device-dock { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-icon { display: grid; }
  .module-summary { min-height: 70px; }
  .summary-copy strong { font-size: 12px; }
  .summary-copy small { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
