:root {
  color-scheme: dark;
  --bg: #11100e;
  --panel: #171613;
  --panel-2: #1d1b17;
  --line: rgba(239, 229, 208, 0.13);
  --muted: #8f897d;
  --text: #f0eadf;
  --acid: #d7ff55;
  --acid-soft: rgba(215, 255, 85, 0.12);
  --error: #ff806f;
  --serif: Georgia, "Times New Roman", serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow: hidden;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

.shell {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(1120px, 100%);
  height: 100dvh;
  margin: 0 auto;
  border-inline: 1px solid var(--line);
  background: rgba(17, 16, 14, 0.86);
}

.topbar,
.workspace-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.topbar {
  min-height: 76px;
  padding: 0 30px;
}

.brand {
  display: inline-flex;
  gap: 13px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font: 700 13px/1.1 var(--mono);
  letter-spacing: 0.14em;
}

.brand small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  display: flex;
  align-items: end;
  gap: 3px;
  width: 30px;
  height: 30px;
  padding: 6px;
  border: 1px solid var(--acid);
  border-radius: 50%;
}

.brand-mark i {
  display: block;
  width: 3px;
  background: var(--acid);
  border-radius: 2px;
}

.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 16px; }
.brand-mark i:nth-child(3) { height: 11px; }

.connection {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font: 12px var(--mono);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5b5750;
}

.dot.online {
  background: var(--acid);
  box-shadow: 0 0 13px rgba(215, 255, 85, 0.65);
}

.workspace-bar {
  min-height: 82px;
  padding: 14px 30px;
  background: rgba(255, 255, 255, 0.015);
}

.workspace-bar strong {
  display: block;
  margin-top: 7px;
  font-size: 14px;
}

.eyebrow {
  margin: 0;
  color: var(--acid);
  font: 700 10px/1.2 var(--mono);
  letter-spacing: 0.16em;
}

.permissions {
  display: flex;
  gap: 8px;
}

.permissions span {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font: 10px var(--mono);
}

.ghost-button {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.ghost-button:hover {
  border-color: rgba(215, 255, 85, 0.45);
  color: var(--text);
}

.workspace-actions {
  display: flex;
  gap: 7px;
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-left: 5px;
  padding-inline: 5px;
  border-radius: 9px;
  background: var(--acid);
  color: #11120c;
  font: 700 10px var(--mono);
}

.badge[hidden] { display: none; }

.chat {
  overflow-y: auto;
  scrollbar-color: #39352f transparent;
}

.welcome {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 60px 24px;
  text-align: center;
}

.welcome[hidden],
.messages[hidden] {
  display: none;
}

.orb {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 26px;
  border: 1px solid rgba(215, 255, 85, 0.34);
  border-radius: 50%;
  box-shadow: 0 0 70px rgba(215, 255, 85, 0.09);
}

.orb span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 20px rgba(215, 255, 85, 0.8);
}

.welcome h1 {
  margin: 17px 0 21px;
  font: 400 clamp(38px, 6vw, 70px)/0.98 var(--serif);
  letter-spacing: -0.04em;
}

.welcome-copy {
  max-width: 590px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 31px;
}

.suggestions button {
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: transparent;
  color: #aaa397;
  cursor: pointer;
  font-size: 12px;
}

.suggestions button:hover {
  border-color: var(--acid);
  color: var(--text);
}

.messages {
  width: min(780px, calc(100% - 44px));
  margin: 0 auto;
  padding: 42px 0 70px;
}

.message {
  position: relative;
  padding: 23px 46px 23px 0;
  border-bottom: 1px solid var(--line);
}

.message-user {
  margin-left: 12%;
}

.message-meta {
  margin-bottom: 10px;
  color: var(--muted);
  font: 700 10px var(--mono);
  letter-spacing: 0.15em;
}

.message-agent .message-meta {
  color: var(--acid);
}

.message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.72;
}

.message-error .message-body,
.message-error .message-meta {
  color: var(--error);
}

.copy-button {
  position: absolute;
  top: 21px;
  right: 0;
  padding: 3px;
  border: 0;
  background: transparent;
  color: #69645c;
  cursor: pointer;
  font: 10px var(--mono);
}

.copy-button:hover {
  color: var(--text);
}

.composer-wrap {
  position: relative;
  padding: 12px 30px 18px;
  border-top: 1px solid var(--line);
  background: rgba(17, 16, 14, 0.96);
}

.activity {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 5px 10px;
  color: var(--muted);
  font: 11px var(--mono);
}

.activity[hidden] { display: none; }

.activity button {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--error);
  cursor: pointer;
  font: 11px var(--mono);
}

.spinner {
  width: 10px;
  height: 10px;
  border: 1px solid #565149;
  border-top-color: var(--acid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.composer {
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 12px 13px 12px 18px;
  border: 1px solid #34312b;
  border-radius: 9px;
  background: var(--panel);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.composer:focus-within {
  border-color: rgba(215, 255, 85, 0.55);
  box-shadow: 0 0 0 3px rgba(215, 255, 85, 0.05);
}

.composer textarea {
  flex: 1;
  min-height: 28px;
  max-height: 180px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.55;
}

.composer textarea::placeholder {
  color: #68635b;
}

.send-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--acid);
  color: #14150e;
  cursor: pointer;
}

.send-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.send-button svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.hint {
  margin: 8px 2px 0;
  color: #625d55;
  font: 10px var(--mono);
  text-align: right;
}

.auth-dialog {
  width: min(430px, calc(100% - 32px));
  padding: 0;
  border: 1px solid #3c3830;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.65);
}

.auth-dialog::backdrop {
  background: rgba(9, 9, 8, 0.78);
  backdrop-filter: blur(8px);
}

.auth-dialog form {
  padding: 34px;
}

.lock {
  width: 32px;
  height: 26px;
  margin-bottom: 26px;
  border: 1px solid var(--acid);
  border-radius: 5px;
  box-shadow: inset 0 0 18px rgba(215, 255, 85, 0.07);
}

.auth-dialog h2 {
  margin: 10px 0;
  font: 400 31px var(--serif);
}

.auth-dialog p:not(.eyebrow):not(.auth-error) {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.auth-dialog label span {
  display: block;
  margin: 24px 0 8px;
  color: var(--muted);
  font: 10px var(--mono);
  letter-spacing: 0.08em;
}

.auth-dialog input {
  width: 100%;
  padding: 13px;
  border: 1px solid #403c34;
  border-radius: 5px;
  outline: none;
  background: #12110f;
  color: var(--text);
  font: 13px var(--mono);
}

.auth-dialog input:focus {
  border-color: var(--acid);
}

.auth-error {
  color: var(--error);
  font-size: 12px;
}

.primary-button {
  width: 100%;
  margin-top: 17px;
  padding: 13px;
  border: 0;
  border-radius: 5px;
  background: var(--acid);
  color: #11120c;
  cursor: pointer;
  font-weight: 700;
}

.devices-dialog {
  width: min(560px, calc(100% - 32px));
}

.devices-list {
  display: grid;
  gap: 8px;
  max-height: 42vh;
  margin: 22px 0 5px;
  overflow-y: auto;
}

.device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #151411;
}

.device-row > div {
  display: grid;
  gap: 6px;
}

.device-row strong,
.device-row small {
  display: block;
}

.device-row small {
  color: var(--muted);
  font-size: 11px;
}

.device-row button {
  padding: 8px 10px;
  border: 1px solid var(--acid);
  border-radius: 4px;
  background: var(--acid-soft);
  color: var(--acid);
  cursor: pointer;
  font-size: 11px;
}

.device-row .revoke-button {
  border-color: rgba(255, 128, 111, 0.4);
  background: transparent;
  color: var(--error);
}

.pairing-code {
  color: var(--acid);
  font: 700 22px var(--mono);
  letter-spacing: 0.16em;
}

.empty-devices {
  padding: 20px;
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 680px) {
  .shell { border: 0; }
  .topbar { min-height: 66px; padding-inline: 18px; }
  .workspace-bar { min-height: 66px; padding: 10px 18px; }
  .permissions { display: none; }
  .workspace-actions .ghost-button { padding-inline: 8px; font-size: 10px; }
  .workspace-bar strong { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
  .welcome { padding: 40px 18px; }
  .welcome h1 { font-size: 44px; }
  .suggestions { display: grid; width: 100%; }
  .messages { width: calc(100% - 36px); padding-top: 20px; }
  .message-user { margin-left: 7%; }
  .composer-wrap { padding: 10px 14px 12px; }
  .hint { display: none; }
  .auth-dialog form { padding: 27px 23px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
