:root {
  --bg: #141414;
  --panel: rgba(42, 42, 42, 0.74);
  --panel-strong: rgba(56, 56, 56, 0.9);
  --line: rgba(255, 255, 255, 0.12);
  --ink: #f4f4f4;
  --muted: #b8bcc4;
  --soft: #7f8794;
  --gold: #d7a64a;
  --cyan: #54c7ec;
  --green: #35c979;
  --danger: #ff5c5c;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    radial-gradient(circle at 20% 10%, rgba(84, 199, 236, 0.18), transparent 28%),
    radial-gradient(circle at 80% 20%, rgba(215, 166, 74, 0.12), transparent 26%),
    #141414;
  background-size: 80px 80px, 80px 80px, auto, auto, auto;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; }

button {
  min-height: 42px;
  border: 1px solid rgba(215, 166, 74, 0.45);
  border-radius: 8px;
  background: linear-gradient(135deg, #b98524, #f2c86e);
  color: #161616;
  cursor: pointer;
  font-weight: 800;
  padding: 0 16px;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.48;
}

button.ghost, .panel-heading button {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
  color: var(--ink);
}

button.danger {
  background: rgba(255, 92, 92, 0.12);
  border-color: rgba(255, 92, 92, 0.38);
  color: #ffd6d6;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.34);
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  min-height: 280px;
  line-height: 1.55;
  resize: vertical;
}

label {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin: 12px 0 6px;
}

.office-atmosphere {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.office-light {
  position: absolute;
  width: 20vw;
  min-width: 180px;
  height: 70vh;
  border-radius: 999px;
  filter: blur(34px);
  opacity: 0.18;
  transform: rotate(12deg);
  will-change: transform, opacity;
}

.light-a { left: 7vw; top: 7vh; background: #d9e8ff; animation: officeSweep 16s ease-in-out infinite; }
.light-b { right: 8vw; top: 15vh; background: #ffd28a; animation: officeSweep 19s ease-in-out infinite reverse; }

.aira-ambient {
  position: absolute;
  max-height: min(72vh, 780px);
  opacity: 0.16;
  filter: drop-shadow(0 20px 60px rgba(0, 0, 0, 0.8));
  transform-origin: center;
  will-change: transform;
}

.ambient-a {
  left: -120px;
  bottom: -80px;
  animation: floatAira 14s ease-in-out infinite;
}

.ambient-b {
  right: -120px;
  top: 80px;
  animation: floatAira 18s ease-in-out infinite reverse;
}

@keyframes officeSweep {
  0%, 100% { transform: translateY(0) rotate(12deg); opacity: 0.13; }
  50% { transform: translateY(28px) rotate(9deg); opacity: 0.25; }
}

@keyframes floatAira {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(24px, -18px, 0) scale(1.025); }
}

.app-shell {
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.topbar {
  align-items: center;
  backdrop-filter: blur(18px);
  background: rgba(24, 24, 24, 0.76);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 42px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  gap: 12px;
  text-decoration: none;
}

.brand img {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
}

.brand strong { display: block; font-size: 18px; }
.brand small { color: var(--muted); display: block; font-size: 12px; }

.status {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 18px rgba(53, 201, 121, 0.75);
}

.status-dot.local, .status-dot.saved, .status-dot.offline {
  background: var(--soft);
  box-shadow: none;
}

.status-dot.checking, .status-dot.function {
  background: var(--gold);
  box-shadow: 0 0 18px rgba(215, 166, 74, 0.6);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 18px rgba(255, 92, 92, 0.58);
}

.status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 18px rgba(53, 201, 121, 0.75);
}

.workspace {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 42px) 54px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  margin-bottom: 18px;
}

.hero-copy, .hero-card, .panel, .install-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-copy {
  background: linear-gradient(135deg, rgba(47, 47, 47, 0.82), rgba(18, 18, 18, 0.66));
  padding: clamp(24px, 5vw, 48px);
}

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(34px, 5vw, 62px); line-height: 1; margin-bottom: 16px; max-width: 850px; }
h2 { font-size: clamp(24px, 3vw, 36px); margin-bottom: 0; }
h3 { font-size: 18px; margin-bottom: 14px; }

.hero-copy p:not(.eyebrow) {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
  max-width: 760px;
}

.hero-card {
  background: var(--panel);
  min-height: 330px;
  overflow: hidden;
  position: relative;
}

.hero-card img {
  width: 100%;
  height: 100%;
  min-height: 330px;
  object-fit: cover;
  opacity: 0.86;
}

.hero-card div {
  position: absolute;
  inset: auto 14px 14px;
  background: rgba(0, 0, 0, 0.48);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.hero-card span { color: var(--muted); display: block; font-size: 12px; }
.hero-card strong { display: block; font-size: 22px; margin-top: 4px; }

.install-panel, .panel {
  background: var(--panel);
  margin-bottom: 16px;
  padding: 20px;
}

.panel-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.permission-row {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 86px;
  padding: 14px;
}

.permission-row span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.permission-row strong {
  color: var(--ink);
  display: block;
  margin-top: 8px;
}

.permission-row.granted strong { color: var(--green); }
.permission-row.denied strong { color: var(--danger); }
.native-only strong { color: var(--gold); }

.consent-line {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  margin: 8px 0 16px;
}

.consent-line input {
  min-height: auto;
  width: auto;
  margin-top: 3px;
}

.install-actions, .button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.tabs button {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
  color: var(--muted);
}

.tabs button.active {
  background: linear-gradient(135deg, #b98524, #f2c86e);
  color: #141414;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; contain: content; }

.grid {
  display: grid;
  gap: 16px;
}

.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}

.metrics div, .empty, .notice, .list-item {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metrics strong {
  color: var(--gold);
  display: block;
  font-size: 30px;
}

.metrics span, .empty {
  color: var(--muted);
  font-size: 13px;
}

.notice {
  border-color: rgba(215, 166, 74, 0.35);
  color: #f0d59a;
  line-height: 1.55;
}

.chat-log {
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 260px;
  padding: 14px;
}

.chat-message {
  max-width: 82%;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
}

.chat-message.assistant {
  align-self: flex-start;
  background: rgba(84, 199, 236, 0.12);
  border: 1px solid rgba(84, 199, 236, 0.25);
}

.chat-message.user {
  align-self: flex-end;
  background: rgba(215, 166, 74, 0.14);
  border: 1px solid rgba(215, 166, 74, 0.28);
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 8px;
  margin-top: 10px;
}

.stacked-form, .list {
  display: grid;
  gap: 10px;
}

.caller-row {
  width: 100%;
  min-height: auto;
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--line);
  color: var(--ink);
  padding: 14px;
  text-align: left;
}

.caller-row:hover, .caller-row.selected {
  border-color: rgba(215, 166, 74, 0.58);
  background: rgba(215, 166, 74, 0.12);
}

.list-item strong { display: block; }
.list-item span { color: var(--muted); display: block; font-size: 13px; margin: 2px 0 8px; }

.caller-detail {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(84, 199, 236, 0.22);
  border-radius: 8px;
  margin-top: 14px;
  padding: 14px;
}

.detail-heading span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-heading strong {
  display: block;
  font-size: 20px;
  margin-top: 2px;
}

.caller-detail dl {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
}

.caller-detail dl div {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 4px;
  padding-top: 10px;
}

.caller-detail dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.caller-detail dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.message-detail dd {
  line-height: 1.55;
}

.action-status {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.action-status.success { color: var(--green); }
.action-status.error { color: var(--danger); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 50;
  max-width: min(92vw, 520px);
  transform: translate(-50%, 24px);
  opacity: 0;
  pointer-events: none;
  background: rgba(20, 20, 20, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--ink);
  padding: 12px 14px;
  transition: opacity 0.18s ease, transform 0.18s ease;
  will-change: transform, opacity;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.success { border-color: rgba(53, 201, 121, 0.42); }
.toast.error { border-color: rgba(255, 92, 92, 0.42); }

.update-banner {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 18px;
  z-index: 60;
  align-items: center;
  display: flex;
  gap: 10px;
  max-width: min(94vw, 560px);
  transform: translateX(-50%);
  background: rgba(24, 24, 24, 0.96);
  border: 1px solid rgba(215, 166, 74, 0.42);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px;
}

.update-banner[hidden] { display: none; }
.update-banner span { color: var(--ink); font-weight: 800; margin-right: 6px; }
.update-banner button { min-height: 36px; }

.capability-list {
  display: grid;
  gap: 10px;
  line-height: 1.55;
  margin: 0 0 16px;
  padding-left: 18px;
}

@media (max-width: 860px) {
  .hero, .grid.two, .permission-grid { grid-template-columns: 1fr; }
  .hero-card { display: none; }
}

@media (max-width: 620px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: 1fr; }
  .chat-form { grid-template-columns: 1fr; }
  .install-actions button { width: 100%; }
}
