:root {
  --bg: #eceef2;
  --card: #ffffff;
  --ink: #2c2c31;
  --muted: #6e6e76;
  --line: rgba(20, 20, 24, 0.08);
  --shadow: 0 18px 50px rgba(28, 32, 40, 0.12), 0 2px 8px rgba(28, 32, 40, 0.06);
  --screen: #111318;
  --user: #2d2f36;
  --sidebar: 72px;
  --info: 340px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  overflow: hidden;
}

.sidebar {
  flex: 0 0 var(--sidebar);
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0 16px;
  gap: 14px;
  border-right: 1px solid var(--line);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #d9dde6, #c5cad4);
  color: #4a4d55;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.nav-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #5c5f68;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.nav-btn.is-active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(28, 32, 40, 0.08), 0 0 0 1px var(--line);
}

.nav-btn:focus-visible,
.chat-title:focus-visible,
.icon-btn:focus-visible,
.send:focus-visible,
.computer:focus-visible {
  outline: 3px solid rgba(80, 120, 255, 0.45);
  outline-offset: 2px;
}

.chat {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.chat-header {
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  padding: 0 22px;
}

.chat-title {
  border: 0;
  background: transparent;
  padding: 6px 2px;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
  cursor: pointer;
}

.chat-title:hover { opacity: 0.72; }

.thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 8px 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble {
  max-width: min(560px, 86%);
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--card);
  box-shadow: 0 1px 2px rgba(28, 32, 40, 0.04);
}

.bubble.user {
  align-self: flex-end;
  background: var(--user);
  color: #f6f7f9;
}

.composer {
  flex: 0 0 auto;
  margin: 0 20px 18px;
  padding: 8px 8px 8px 16px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(28, 32, 40, 0.04), 0 0 0 1px var(--line);
}

.composer textarea {
  flex: 1;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.45;
  max-height: 140px;
  padding: 8px 0;
  outline: none;
}

.composer textarea::placeholder { color: #9a9aa3; }

.send {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 12px;
  background: #2d2f36;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.send:hover { background: #1f2126; }

.info {
  flex: 0 0 var(--info);
  width: var(--info);
  min-width: 0;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: #f4f5f8;
  transition: flex-basis 200ms ease, width 200ms ease, opacity 160ms ease, border-width 200ms ease;
}

.info-inner {
  width: var(--info);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.info-header {
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 20px;
}

.info-heading {
  font-size: 15px;
  font-weight: 650;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:hover {
  background: rgba(20, 20, 24, 0.06);
  color: var(--ink);
}

.info-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px 16px 24px;
}

.computer {
  width: 100%;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
}

.computer:hover {
  box-shadow: 0 22px 56px rgba(28, 32, 40, 0.16), 0 2px 8px rgba(28, 32, 40, 0.06);
}

.titlebar {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  height: 42px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #f7f8fa;
}

.dots { display: flex; gap: 6px; }

.dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: block;
  background: #d8dbe2;
}

.dots i:nth-child(1) { background: #ff5f57; }
.dots i:nth-child(2) { background: #febc2e; }
.dots i:nth-child(3) { background: #28c840; }

.title {
  justify-self: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.status {
  font-size: 12px;
  color: var(--muted);
}

.screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--screen);
  overflow: hidden;
}

.screen iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--screen);
  pointer-events: none;
}

.veil {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(17, 19, 24, 0.55);
  color: #f4f5f7;
  font-size: 13px;
  pointer-events: none;
  transition: opacity 240ms ease;
}

.veil.hidden { opacity: 0; }
.veil.error { background: rgba(17, 19, 24, 0.78); }

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.veil.error .spinner { display: none; }

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

.hint {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 12px;
}

.routines {
  margin-top: 22px;
  padding: 0 2px;
}

.routines h2 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 650;
}

.routines .empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

body:not(.pane-open) .info {
  flex-basis: 0;
  width: 0;
  opacity: 0;
  border-left-width: 0;
  pointer-events: none;
}

body:not(.pane-open) .chat-title { opacity: 0.55; }

body.is-fullscreen {
  background: #000;
}

body.is-fullscreen .shell {
  display: block;
  height: 100vh;
}

body.is-fullscreen .sidebar,
body.is-fullscreen .chat,
body.is-fullscreen .info-header,
body.is-fullscreen .hint,
body.is-fullscreen .routines,
body.is-fullscreen .titlebar {
  display: none;
}

body.is-fullscreen .info,
body.is-fullscreen .info-inner,
body.is-fullscreen .info-body {
  width: 100%;
  height: 100%;
  max-width: none;
  padding: 0;
  margin: 0;
  border: 0;
  overflow: hidden;
  background: #000;
}

body.is-fullscreen .computer {
  width: 100%;
  height: 100vh;
  border-radius: 0;
  box-shadow: none;
  cursor: default;
}

body.is-fullscreen .screen {
  aspect-ratio: auto;
  height: 100vh;
}

body.is-fullscreen .screen iframe {
  pointer-events: auto;
}

body.is-fullscreen .veil { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }

  .shell { flex-direction: column; }

  .chat-header { padding: 0 16px; }

  .thread { padding: 8px 16px 16px; }

  .composer { margin: 0 12px 12px; }

  .info {
    flex: 0 0 auto;
    width: 100%;
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 46vh;
  }

  .info-inner { width: 100%; }

  body:not(.pane-open) .info {
    max-height: 0;
    border-top-width: 0;
  }

  body.is-fullscreen .info { max-height: none; }
}

@media (max-width: 520px) {
  .bubble { max-width: 92%; }
  .info { max-height: 40vh; }
}
