:root {
  --bg: #f1f3ef;
  --surface: #fffefb;
  --surface-soft: #e9ede7;
  --ink: #17211f;
  --muted: #6d7974;
  --line: #d7ded8;
  --accent: #14796e;
  --accent-dark: #0c5b53;
  --accent-soft: #dceee9;
  --blue: #2e66a2;
  --blue-soft: #e1ecf7;
  --amber: #a96112;
  --amber-soft: #f8ead4;
  --danger: #b43e35;
  --danger-soft: #fbe5e1;
  --console: #111e1b;
  --console-ink: #d9e8e3;
  --shadow: 0 10px 30px rgba(26, 42, 37, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow-x: hidden;
  touch-action: manipulation;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.12em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 27px;
  font-weight: 720;
  letter-spacing: -0.01em;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  font-weight: 680;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  padding: max(32px, env(safe-area-inset-top)) 22px max(30px, env(safe-area-inset-bottom));
  place-items: center;
  background: #e9eee8;
}

.login-shell {
  width: min(390px, 100%);
}

.app-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: #29473f;
  color: #a9e0d4;
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 10px;
  font-weight: 800;
}

.app-mark.large {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 14px;
  background: var(--accent-dark);
  color: #e8fff9;
  font-size: 15px;
  box-shadow: 0 12px 30px rgba(21, 80, 70, 0.2);
}

.login-shell h1 {
  margin-top: 18px;
  font-size: 32px;
}

.login-subtitle {
  margin: 7px 0 28px;
  color: var(--muted);
  font-size: 13px;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form > label,
.stack-form > label,
.task-panel label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.password-field {
  display: flex;
  height: 52px;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.password-field:focus-within {
  border-color: var(--accent);
}

.password-field svg {
  color: var(--muted);
}

.password-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.primary-button,
.secondary-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  display: inline-flex;
  min-height: 43px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 650;
}

.primary-button:active {
  background: var(--accent-dark);
}

.primary-button.full {
  width: 100%;
  min-height: 48px;
  margin-top: 5px;
}

.primary-button svg {
  width: 17px;
  height: 17px;
}

.primary-button:disabled,
.secondary-button:disabled,
.icon-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.form-error {
  min-height: 18px;
  margin: 5px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.app-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  background: var(--bg);
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: calc(66px + env(safe-area-inset-top));
  align-items: center;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(241, 243, 239, 0.94);
  backdrop-filter: blur(18px);
}

.header-copy {
  min-width: 0;
  flex: 1;
}

.header-copy strong,
.header-copy span {
  display: block;
}

.header-copy strong {
  font-size: 15px;
}

.header-copy span {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-status,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 99px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.header-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
}

.header-status.online,
.status-pill.online {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.header-status.online i {
  background: var(--accent);
}

.header-status.offline,
.status-pill.offline {
  background: var(--danger-soft);
  color: var(--danger);
}

.header-button,
.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  background: var(--surface);
}

.header-button {
  border: 0;
}

.icon-button.loading svg {
  animation: spin 700ms linear infinite;
}

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

.content {
  min-height: calc(100vh - 66px);
  padding: 20px 16px calc(94px + env(safe-area-inset-bottom));
}

.page {
  display: none;
}

.page.active {
  display: block;
}

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

.page-heading .icon-button {
  margin-top: 2px;
}

.identity-band,
.agent-band {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.identity-band > div:nth-child(2),
.agent-band > div:first-child {
  min-width: 0;
  flex: 1;
}

.identity-band span,
.identity-band strong,
.identity-band small,
.agent-band span,
.agent-band strong,
.agent-band small {
  display: block;
}

.identity-band span,
.agent-band span {
  color: var(--muted);
  font-size: 10px;
}

.identity-band strong,
.agent-band strong {
  overflow: hidden;
  margin: 4px 0 2px;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity-band small,
.agent-band small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: #24443c;
  color: #bce9df;
  font-size: 20px;
  font-weight: 750;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.metric-grid article {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-grid article > svg {
  width: 16px;
  height: 16px;
  margin-bottom: 12px;
  color: var(--accent);
}

.metric-grid article > span,
.metric-grid article > strong,
.metric-grid article > small {
  display: block;
}

.metric-grid article > span {
  color: var(--muted);
  font-size: 10px;
}

.metric-grid article > strong {
  overflow: hidden;
  margin: 5px 0 2px;
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 21px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-grid article > small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress {
  display: block;
  height: 3px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-soft);
}

.progress b {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.section {
  margin-top: 24px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-heading > span {
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 9px;
}

.section-heading.compact {
  margin-bottom: 16px;
}

.list,
.container-control,
.job-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.service-row,
.credential-row {
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.service-row:last-child,
.credential-row:last-child {
  border-bottom: 0;
}

.service-symbol {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--danger);
}

.service-symbol.online {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.service-copy,
.credential-copy {
  min-width: 0;
  flex: 1;
}

.service-copy strong,
.service-copy small,
.credential-copy strong,
.credential-copy small {
  display: block;
}

.service-copy strong,
.credential-copy strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-copy small,
.credential-copy small {
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-state {
  color: var(--muted);
  font-size: 10px;
}

.service-state.online {
  color: var(--accent-dark);
}

.shortcut-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.shortcut {
  display: grid;
  min-height: 98px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.shortcut.disabled,
.app-entry.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.shortcut svg {
  width: 25px;
  height: 25px;
  margin-bottom: 10px;
  color: var(--accent);
}

.shortcut span,
.shortcut small {
  display: block;
}

.shortcut span {
  font-size: 13px;
  font-weight: 680;
}

.shortcut small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.detail-panel {
  padding: 4px 14px;
}

.detail-row {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row span {
  color: var(--muted);
  font-size: 12px;
}

.detail-row strong {
  min-width: 0;
  font-size: 12px;
  text-align: right;
}

.container-control > div {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.container-control > div:last-child {
  border-bottom: 0;
}

.container-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.container-title strong {
  font-size: 14px;
}

.container-title small {
  color: var(--muted);
  font-size: 10px;
}

.container-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.secondary-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
}

.secondary-button.danger {
  color: var(--danger);
}

.path-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 15px;
}

.path-panel span {
  padding: 6px 8px;
  border-radius: 5px;
  background: var(--surface-soft);
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 9px;
}

.path-panel i {
  height: 1px;
  flex: 1;
  background: var(--line);
}

.agent-band {
  box-shadow: none;
}

.agent-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.agent-metrics > div {
  min-width: 0;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.agent-metrics > div:nth-child(2) {
  border-right: 0;
}

.agent-metrics > div:last-child {
  grid-column: 1 / -1;
  border-right: 0;
  border-bottom: 0;
}

.agent-metrics span,
.agent-metrics strong {
  display: block;
}

.agent-metrics span {
  color: var(--muted);
  font-size: 10px;
}

.agent-metrics strong {
  margin-top: 4px;
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 20px;
}

.agent-metrics strong.tiny {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-panel {
  padding: 15px;
}

.task-panel form {
  display: grid;
  gap: 8px;
}

.task-panel input,
.task-panel textarea,
.stack-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  background: #fafbf8;
  color: var(--ink);
  font-size: 16px;
}

.task-panel input,
.stack-form input {
  min-height: 44px;
  padding: 0 11px;
}

.task-panel textarea {
  min-height: 118px;
  padding: 10px 11px;
  line-height: 1.5;
  resize: vertical;
}

.task-panel input:focus,
.task-panel textarea:focus,
.stack-form input:focus {
  border-color: var(--accent);
  background: white;
}

.task-panel .primary-button {
  margin-top: 7px;
}

.job-item {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.job-item:last-child {
  border-bottom: 0;
}

.job-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.job-head code {
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 11px;
}

.job-status {
  padding: 3px 7px;
  border-radius: 99px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}

.job-status.running,
.job-status.queued,
.job-status.starting {
  background: var(--amber-soft);
  color: var(--amber);
}

.job-status.completed {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.job-status.failed,
.job-status.timeout,
.job-status.cancelled {
  background: var(--danger-soft);
  color: var(--danger);
}

.job-meta,
.job-result {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.job-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-result {
  margin-top: 5px;
  color: var(--ink);
}

.job-cancel {
  margin-top: 8px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: var(--danger);
  font-size: 10px;
}

.empty-state {
  padding: 30px 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.segmented {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(25, 38, 33, 0.1);
}

.log-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 2px;
  color: var(--muted);
  font-size: 10px;
}

.log-meta label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.log-meta input {
  accent-color: var(--accent);
}

.log-view {
  height: calc(100vh - 250px);
  height: calc(100svh - 250px);
  min-height: 380px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border-radius: 8px;
  background: var(--console);
  color: var(--console-ink);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.app-entry-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.app-entry {
  display: flex;
  min-height: 70px;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.app-entry:last-child {
  border-bottom: 0;
}

.app-entry > div {
  min-width: 0;
  flex: 1;
}

.app-entry strong,
.app-entry small {
  display: block;
}

.app-entry strong {
  font-size: 14px;
}

.app-entry small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.app-icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
}

.app-icon.astrbot {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.app-icon.snowluma {
  background: var(--blue-soft);
  color: var(--blue);
}

.app-icon.novnc {
  background: var(--amber-soft);
  color: var(--amber);
}

.chevron {
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.app-note {
  margin: 18px 2px 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.credential-row button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.credential-row svg {
  width: 15px;
  height: 15px;
}

.tab-bar {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  width: min(760px, 100%);
  min-height: calc(62px + env(safe-area-inset-bottom));
  margin: 0 auto;
  padding: 6px 8px env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: rgba(255, 254, 251, 0.94);
  backdrop-filter: blur(18px);
  grid-template-columns: repeat(5, 1fr);
}

.tab-bar button {
  display: grid;
  min-width: 0;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.tab-bar button.active {
  color: var(--accent-dark);
}

.tab-bar svg {
  width: 21px;
  height: 21px;
}

.tab-bar span {
  font-size: 9px;
  font-weight: 600;
}

.sheet-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(16, 28, 24, 0.48);
}

.sheet {
  width: min(760px, 100%);
  max-height: 88vh;
  max-height: 88svh;
  padding: 8px 18px calc(22px + env(safe-area-inset-bottom));
  overflow: auto;
  border-radius: 16px 16px 0 0;
  background: var(--surface);
}

.sheet-handle {
  width: 38px;
  height: 4px;
  margin: 2px auto 12px;
  border-radius: 99px;
  background: var(--line);
}

.sheet-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.stack-form {
  display: grid;
  gap: 8px;
}

.logout-button {
  width: 100%;
  min-height: 46px;
  margin-top: 22px;
  border: 1px solid var(--danger-soft);
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 650;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 16px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  left: 16px;
  max-width: 420px;
  margin: 0 auto;
  padding: 11px 14px;
  border-radius: 8px;
  background: #1a2d28;
  color: #f1f8f5;
  font-size: 12px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 700px) {
  body {
    background: #dfe6e1;
  }

  .app-shell {
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
    box-shadow: 0 0 60px rgba(24, 42, 36, 0.08);
  }

  .metric-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .shortcut-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .container-control {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .container-control > div:first-child {
    border-right: 1px solid var(--line);
  }

  .container-control > div {
    border-bottom: 0;
  }
}

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