:root {
  --ink: #17242b;
  --ink-soft: #24353d;
  --ink-muted: #5f6e70;
  --paper: #fbf8f1;
  --paper-strong: #ffffff;
  --canvas: #ebe7dd;
  --line: #d7d1c4;
  --line-dark: #34464d;
  --green: #2d8b68;
  --green-bright: #69c39d;
  --green-soft: #e2f1e9;
  --copper: #b96f42;
  --copper-soft: #f7e8dc;
  --red: #ad4f4b;
  --red-soft: #f9e7e4;
  --blue: #547c9e;
  --shadow: 0 20px 60px rgba(10, 23, 28, 0.18);
  --sans: "Segoe UI", "Microsoft YaHei UI", "Noto Sans SC", system-ui, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0;
  color: var(--copper);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a6aea9;
  box-shadow: 0 0 0 4px rgba(166, 174, 169, 0.12);
}

.status-dot.online {
  background: var(--green-bright);
  box-shadow: 0 0 0 4px rgba(105, 195, 157, 0.12);
}

.status-dot.error {
  background: #f08a82;
  box-shadow: 0 0 0 4px rgba(240, 138, 130, 0.12);
}

.login-view {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--ink);
  color: var(--paper);
  padding: max(22px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #eef3f0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand-mark {
  width: 38px;
  height: 38px;
}

.login-stage {
  display: grid;
  align-items: center;
  width: min(960px, 100%);
  margin: auto;
}

.access-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  gap: clamp(30px, 7vw, 90px);
  align-items: center;
}

.access-copy {
  min-width: 0;
}

.access-copy .eyebrow {
  color: var(--green-bright);
}

.access-copy h1 {
  max-width: 640px;
  margin: 15px 0 0;
  color: #ffffff;
  font-size: 56px;
  line-height: 1.05;
  letter-spacing: 0;
}

.login-subtitle {
  max-width: 540px;
  margin: 20px 0 0;
  color: #a9b8b3;
  font-size: 15px;
  line-height: 1.7;
}

.access-signal {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 42px;
  color: #9fb2ab;
}

.signal-screen {
  width: min(230px, 42vw);
  aspect-ratio: 16 / 10;
  border: 1px solid #42565b;
  border-radius: 8px;
  background: #203139;
  padding: 22px 20px;
  display: grid;
  align-content: center;
  gap: 12px;
}

.signal-screen span {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: #536a6d;
}

.signal-screen span:first-child {
  width: 68%;
  background: var(--green-bright);
}

.signal-screen span:nth-child(2) {
  width: 88%;
}

.signal-screen span:last-child {
  width: 48%;
  background: #d59a70;
}

.signal-line {
  width: 56px;
  height: 1px;
  background: repeating-linear-gradient(
    to right,
    #6d8581 0 5px,
    transparent 5px 10px
  );
}

.signal-phone {
  width: 46px;
  height: 78px;
  border: 1px solid #667c78;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--green-bright);
}

.signal-phone .icon,
.signal-phone svg {
  width: 24px;
  height: 24px;
}

.login-form {
  border: 1px solid #3b4d53;
  border-radius: 8px;
  background: #f9f6ee;
  color: var(--ink);
  padding: 28px;
  box-shadow: var(--shadow);
}

.form-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 22px;
}

.login-form label {
  display: block;
  margin: 14px 0 7px;
  color: #4a5650;
  font-size: 11px;
  font-weight: 700;
}

.login-form input,
.chat-composer textarea,
.keyboard-panel textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-strong);
  color: var(--ink);
  font-size: 16px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.login-form input {
  height: 46px;
  padding: 0 13px;
}

.login-form input:focus,
.chat-composer textarea:focus,
.keyboard-panel textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(45, 139, 104, 0.1);
  outline: none;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 48px;
}

.field-icon {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #70807b;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.field-icon:hover {
  background: #eee9df;
}

.form-error {
  min-height: 18px;
  margin: 9px 0 0;
  color: var(--red);
  font-size: 11px;
  line-height: 1.45;
}

.primary-button,
.secondary-button,
.send-button,
.tool-button,
.round-action,
.icon-button,
.key-button,
.zoom-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  height: 46px;
  margin-top: 10px;
  border-radius: 6px;
  background: var(--green);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
}

.primary-button:hover,
.send-button:hover,
.tool-primary:hover {
  filter: brightness(0.94);
}

.primary-button:disabled,
.secondary-button:disabled,
.send-button:disabled,
.tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.security-note {
  margin: 14px 0 0;
  color: #7b8580;
  font-size: 9px;
  line-height: 1.55;
}

.login-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid #304148;
  padding-top: 14px;
  color: #7f928d;
  font-size: 9px;
}

.console-view {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--canvas);
}

.app-header {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(9px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    9px max(14px, env(safe-area-inset-left));
  background: var(--ink);
  color: #ecf2ef;
  border-bottom: 1px solid #2e4047;
}

.workspace-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark-small {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}

.workspace-identity div {
  min-width: 0;
}

.workspace-identity p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.workspace-identity span {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #90a29c;
  font-size: 9px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.connection-badge,
.control-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  font-size: 10px;
  white-space: nowrap;
}

.connection-badge {
  padding: 8px 10px;
  background: #22343b;
  color: #aebcb7;
}

.connection-badge .status-dot {
  width: 6px;
  height: 6px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: #263840;
  color: #dfe8e4;
  display: grid;
  place-items: center;
}

.icon-button:hover {
  background: #31464e;
}

.console-main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 1px;
  background: var(--line);
}

.desktop-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #1b292f;
}

.desktop-meta {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  border-bottom: 1px solid #314149;
  background: #223239;
}

.desktop-size {
  min-width: 0;
  display: flex;
  gap: 12px;
  color: #91a29c;
  font-family: var(--mono);
  font-size: 9px;
  white-space: nowrap;
}

.desktop-size span:last-child {
  color: #d3986e;
}

.control-badge {
  padding: 5px 8px;
  background: #2d4047;
  color: #b7c5c0;
  border: 1px solid #3c5057;
}

.control-badge .icon {
  width: 13px;
  height: 13px;
}

.control-badge.active {
  background: var(--green-soft);
  border-color: #b9dcca;
  color: #276a51;
}

.control-badge.busy {
  background: var(--copper-soft);
  border-color: #eccdb6;
  color: #8d542f;
}

.screen-scroller {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: #111b20;
}

.screen-stage {
  position: relative;
  width: 100%;
  min-height: 100%;
  display: grid;
  align-items: center;
  justify-items: center;
}

#screen-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #0d1519;
  touch-action: none;
  user-select: none;
  cursor: crosshair;
}

.screen-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 28px;
  color: #849691;
  text-align: center;
  pointer-events: none;
}

.screen-placeholder svg {
  width: 50px;
  height: 50px;
  color: #56706e;
}

.screen-placeholder p {
  margin: 4px 0 0;
  color: #c4d0cc;
  font-size: 12px;
  font-weight: 650;
}

.screen-placeholder span {
  font-size: 10px;
}

.chat-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background: var(--paper);
}

.chat-heading {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.chat-heading h2 {
  margin: 4px 0 0;
  font-size: 16px;
  line-height: 1.2;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  scroll-behavior: smooth;
}

.message {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.message:last-child {
  margin-bottom: 0;
}

.message-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e8e2d7;
  color: #48554f;
  font-size: 9px;
  font-weight: 800;
}

.message.assistant .message-avatar {
  background: var(--green-soft);
  color: #286b52;
}

.message-body {
  min-width: 0;
}

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 4px;
}

.message-sender {
  font-size: 10px;
  font-weight: 750;
}

.message-time {
  color: #949d97;
  font-size: 8px;
}

.message-text {
  margin: 0;
  color: #43504a;
  font-size: 11px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty-chat {
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: #87918c;
  text-align: center;
  font-size: 10px;
  line-height: 1.6;
  padding: 20px;
}

.empty-chat svg {
  width: 28px;
  height: 28px;
  color: #b3bcb7;
}

.assistant-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 9px;
  color: #61706a;
  font-size: 9px;
}

.thinking-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.chat-composer {
  border-top: 1px solid var(--line);
  padding: 11px 12px max(11px, env(safe-area-inset-bottom));
  background: #f4f0e8;
}

.chat-composer textarea {
  resize: none;
  min-height: 54px;
  max-height: 140px;
  padding: 10px 11px;
  line-height: 1.5;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.round-action,
.send-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.round-action {
  background: #e8e2d8;
  color: #52605a;
}

.round-action.listening {
  background: var(--red-soft);
  color: var(--red);
  animation: pulse 1s ease-in-out infinite;
}

.send-button {
  background: var(--green);
  color: #ffffff;
}

.control-toolbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px max(10px, env(safe-area-inset-right))
    max(7px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: var(--paper);
  border-top: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.control-toolbar::-webkit-scrollbar {
  display: none;
}

.tool-button {
  min-width: 54px;
  height: 48px;
  padding: 5px 8px;
  border-radius: 6px;
  background: transparent;
  color: #53605a;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  font-size: 9px;
  white-space: nowrap;
}

.tool-button:hover {
  background: #ece7dd;
}

.tool-button.active {
  background: var(--green-soft);
  color: #276b52;
}

.tool-primary {
  background: var(--green);
  color: #ffffff;
}

.tool-primary:hover {
  background: var(--green);
}

.zoom-control {
  min-width: 122px;
  height: 38px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f4f0e8;
  display: grid;
  grid-template-columns: 34px minmax(48px, 1fr) 34px;
  align-items: center;
}

.zoom-button {
  height: 34px;
  background: transparent;
  color: #52605a;
  font-size: 18px;
}

.zoom-button:hover {
  color: var(--green);
}

#zoom-label {
  text-align: center;
  color: #66726c;
  font-family: var(--mono);
  font-size: 9px;
}

.keyboard-panel {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(74px + env(safe-area-inset-bottom));
  width: min(680px, calc(100vw - 24px));
  max-height: min(470px, 70dvh);
  overflow: auto;
  transform: translateX(-50%);
  border: 1px solid #cbc4b8;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 18px;
}

.keyboard-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.keyboard-heading h3 {
  margin: 4px 0 0;
  font-size: 16px;
}

.keyboard-panel textarea {
  min-height: 72px;
  resize: vertical;
  padding: 10px;
  line-height: 1.5;
}

.keyboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 11px;
}

.secondary-button,
.key-button {
  min-height: 34px;
  border: 1px solid #d1cabf;
  border-radius: 5px;
  background: #ffffff;
  color: #49564f;
  padding: 6px 11px;
  font-size: 10px;
}

.secondary-button {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
  font-weight: 700;
}

.key-button:hover,
.secondary-button:hover {
  filter: brightness(0.96);
}

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  max-width: min(460px, calc(100vw - 32px));
  transform: translate(-50%, 12px);
  border-radius: 6px;
  background: #223239;
  color: #eef4f1;
  box-shadow: 0 12px 36px rgba(13, 25, 30, 0.25);
  padding: 10px 13px;
  font-size: 10px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.mobile-only {
  display: none;
}

@media (max-width: 920px) {
  .login-stage {
    width: min(520px, 100%);
  }

  .access-panel {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .access-copy {
    text-align: center;
  }

  .access-copy h1,
  .login-subtitle {
    margin-left: auto;
    margin-right: auto;
  }

  .access-signal {
    justify-content: center;
    margin-top: 26px;
  }

  .login-form {
    padding: 22px;
  }
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .login-view {
    padding-left: 17px;
    padding-right: 17px;
  }

  .login-brand {
    justify-content: center;
  }

  .access-panel {
    gap: 24px;
  }

  .access-copy h1 {
    font-size: 38px;
  }

  .login-subtitle {
    font-size: 13px;
  }

  .access-signal {
    display: none;
  }

  .login-form {
    width: min(430px, 100%);
    margin: 0 auto;
  }

  .console-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .desktop-panel {
    min-height: 0;
  }

  .chat-panel {
    position: fixed;
    z-index: 25;
    inset: auto 0 0;
    height: min(76dvh, 680px);
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    box-shadow: 0 -18px 60px rgba(16, 29, 34, 0.24);
    transform: translateY(102%);
    transition: transform 180ms ease;
  }

  .chat-panel.open {
    transform: translateY(0);
  }

  .mobile-only {
    display: grid;
  }

  .connection-badge span:last-child {
    display: none;
  }

  .connection-badge {
    padding: 0;
    width: 32px;
    height: 32px;
    justify-content: center;
    background: transparent;
  }

  .app-header {
    min-height: 56px;
  }

  .brand-mark-small {
    width: 29px;
    height: 29px;
  }

  .header-actions {
    gap: 3px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .control-toolbar {
    min-height: 62px;
  }

  .tool-button {
    min-width: 50px;
  }

  .tool-button .icon {
    width: 17px;
    height: 17px;
  }

  .zoom-control {
    min-width: 100px;
    grid-template-columns: 30px minmax(38px, 1fr) 30px;
  }

  .toast {
    bottom: calc(150px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 430px) {
  .login-view {
    grid-template-rows: auto 1fr;
    gap: 20px;
  }

  .login-footer {
    display: none;
  }

  .access-copy h1 {
    margin-top: 10px;
  }

  .access-copy .eyebrow,
  .login-subtitle {
    display: none;
  }

  .login-form {
    padding: 18px;
  }

  .form-heading {
    margin-bottom: 14px;
  }

  .security-note {
    display: none;
  }

  .desktop-meta {
    min-height: 34px;
    padding: 6px 8px;
  }

  .desktop-size {
    gap: 8px;
  }

  .control-badge {
    max-width: 52%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .control-badge span {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .keyboard-panel {
    bottom: calc(68px + env(safe-area-inset-bottom));
    padding: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
