:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #eef3f8;
  --line: #d8e1ea;
  --text: #17202a;
  --muted: #667586;
  --accent: #1677ff;
  --accent-2: #12a594;
  --danger: #d64545;
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  background: var(--accent);
  color: #fff;
  height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(25, 38, 52, .12);
  display: grid;
  gap: 22px;
}

.login-brand {
  align-items: flex-start;
}

.login-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.login-links a {
  color: var(--accent);
  text-decoration: none;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 340px 1fr;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #17202a;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 20px;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
}

.panel-section {
  display: grid;
  gap: 10px;
}

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

.stack-form label,
.section-title {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.download-link,
.cms-link {
  display: grid;
  place-items: center;
  min-height: 38px;
  border-radius: 6px;
  background: #17202a;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
}

.cms-link {
  background: #526170;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--panel-2);
  padding: 4px;
  border-radius: 8px;
}

.seg {
  background: transparent;
  color: var(--muted);
}

.seg.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(20, 31, 43, .12);
}

input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.account-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.account-card span {
  color: var(--muted);
  font-size: 13px;
}

.secondary-btn {
  background: #526170;
}

.stage {
  display: grid;
  grid-template-rows: 72px 1fr;
  min-width: 0;
}

.toolbar {
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid var(--line);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.active-title {
  font-size: 18px;
  font-weight: 700;
}

.active-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.stage-body {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.device-shelf {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 18px 22px 6px;
  min-height: 160px;
  align-items: stretch;
}

.placeholder-card {
  width: 100%;
  min-height: 96px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, .72);
  color: var(--muted);
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
}

.phone-card {
  position: relative;
  width: 116px;
  min-width: 116px;
  height: 138px;
  border-radius: 18px;
  border: 2px solid #243344;
  background: #fff;
  color: var(--text);
  padding: 18px 10px 10px;
  display: grid;
  align-content: start;
  gap: 5px;
  text-align: center;
  box-shadow: 0 10px 24px rgba(26, 39, 52, .12);
}

.phone-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(22, 119, 255, .14), 0 12px 26px rgba(26, 39, 52, .14);
}

.phone-card.offline {
  opacity: .68;
  border-style: dashed;
}

.desktop-card {
  width: 150px;
  min-width: 150px;
  height: 116px;
  border-radius: 8px;
  padding-top: 14px;
}

.desktop-card .phone-top {
  top: auto;
  bottom: 7px;
  width: 46px;
  height: 5px;
}

.phone-top {
  position: absolute;
  top: 7px;
  left: 50%;
  width: 34px;
  height: 4px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #243344;
}

.phone-delete {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #eef3f8;
  color: #526170;
  font-size: 16px;
  line-height: 1;
}

.phone-delete:hover {
  background: #ffe1e1;
  color: var(--danger);
}

.phone-card strong {
  font-size: 14px;
}

.phone-card em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  min-height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phone-card small {
  color: #0f5132;
  font-size: 12px;
}

.phone-card.offline small {
  color: #7a4c00;
}

.badges,
.mini-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
}

.badge {
  color: #0f5132;
  background: #d7f6e5;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-style: normal;
}

.badge.warn {
  color: #7a4c00;
  background: #fff2cc;
}

.screen-workspace {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 22px 28px 28px;
}

.screen-placeholder {
  width: min(620px, 100%);
  min-height: 220px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, .72);
  color: var(--muted);
  border-radius: 8px;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
}

.screen-placeholder strong {
  color: var(--text);
  font-size: 18px;
}

.viewer-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  min-height: 0;
}

.viewer-wrap.closed {
  display: none;
}

.viewer {
  position: relative;
  height: min(72vh, 760px);
  aspect-ratio: 9 / 18.5;
  background: #111820;
  border-radius: 8px;
  border: 1px solid #0a0f14;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(25, 38, 52, .24);
}

.viewer.desktop-viewer {
  width: min(78vw, 1180px);
  height: auto;
  max-height: 72vh;
  aspect-ratio: 16 / 9;
}

.viewer.phone-viewer {
  width: auto;
  height: min(72vh, 760px);
  aspect-ratio: 9 / 18.5;
}

.screen-actions {
  width: 132px;
  display: grid;
  gap: 8px;
  align-self: center;
}

.screen-actions button {
  width: 100%;
}

.screen-actions #backBtn,
.screen-actions #homeBtn,
.screen-actions #homeSwipeBtn {
  background: #26384d;
}

#stopBtn {
  background: var(--danger);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.remote-cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 14px;
  height: 14px;
  border: 2px solid #39ff88;
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  transform: translate(-999px, -999px);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .35);
}

.remote-cursor::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 5px;
  width: 2px;
  height: 2px;
  background: #39ff88;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: #dce7f3;
  padding: 24px;
}

.empty-state span {
  color: #9fb0c2;
  line-height: 1.5;
}

.viewer.has-frame .empty-state {
  display: none;
}

.cms-shell {
  min-height: 100vh;
  padding: 24px;
}

.cms-header {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.admin-form {
  width: min(440px, 100%);
  display: flex;
  gap: 8px;
}

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

.cms-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel-title {
  font-weight: 700;
  margin-bottom: 12px;
}

.table-list {
  display: grid;
  gap: 10px;
}

.table-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.table-row strong,
.table-row span {
  display: block;
}

.table-row span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.danger-small {
  background: var(--danger);
}

@media (max-width: 900px) {
  .shell,
  .cms-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage {
    grid-template-rows: auto 1fr;
  }

  .toolbar,
  .cms-header,
  .table-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions,
  .admin-form {
    width: 100%;
  }

  .viewer-wrap {
    flex-direction: column;
  }

  .screen-actions {
    width: min(360px, 100%);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .viewer {
    height: min(68vh, 680px);
  }
}
