:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #08100e;
  color: #eef8f2;
  --panel: rgba(17, 29, 25, 0.9);
  --panel-border: rgba(154, 215, 185, 0.14);
  --muted: #8fa69b;
  --green: #6ef0a8;
  --cyan: #65d8ce;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(46, 156, 109, 0.18), transparent 32rem),
    radial-gradient(circle at 90% 78%, rgba(40, 132, 138, 0.13), transparent 30rem),
    #08100e;
}

button, input { font: inherit; }
button { cursor: pointer; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 470px); padding: 34px; border: 1px solid var(--panel-border); border-radius: 24px; background: linear-gradient(145deg, rgba(18, 31, 26, .98), rgba(11, 20, 17, .96)); box-shadow: var(--shadow); }
.auth-card h1 { font-size: 31px; }
.auth-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.auth-card label { display: block; margin: 24px 0 8px; color: #cfe2d8; font-size: 12px; }
.auth-input-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.auth-input-row input { min-width: 0; padding: 12px 14px; border: 1px solid var(--panel-border); border-radius: 11px; outline: none; background: #09120f; color: #effbf5; }
.auth-input-row input:focus { border-color: rgba(110, 240, 168, .5); box-shadow: 0 0 0 3px rgba(110, 240, 168, .08); }
.auth-input-row button { padding: 0 21px; border: 0; border-radius: 11px; background: var(--green); color: #082015; font-weight: 800; }
.auth-error { min-height: 20px; margin: 12px 0 0 !important; color: #ff8c95 !important; font-size: 12px; }

.app-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 54px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .18em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(28px, 4vw, 46px); line-height: 1.08; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 18px; letter-spacing: -.02em; }
.subtitle { margin-bottom: 0; color: var(--muted); }
.device-pill { display: flex; align-items: center; gap: 9px; min-width: max-content; padding: 10px 14px; border: 1px solid var(--panel-border); border-radius: 999px; background: rgba(14, 25, 21, .75); color: #c9d8d1; font-size: 13px; }
.logout-button { padding: 10px 14px; border: 1px solid var(--panel-border); border-radius: 999px; background: rgba(14, 25, 21, .75); color: var(--muted); font-size: 12px; }
.logout-button:hover { border-color: rgba(255, 110, 121, .45); color: #ff9ca4; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #f2b84b; box-shadow: 0 0 14px currentColor; }
.status-dot.online { color: var(--green); background: currentColor; }
.status-dot.error { color: #ff6e79; background: currentColor; }

.workspace { display: grid; grid-template-columns: minmax(350px, 520px) minmax(330px, 1fr); gap: 34px; align-items: start; }
.phone-column { display: flex; flex-direction: column; align-items: center; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin-bottom: 15px; padding: 5px; border: 1px solid var(--panel-border); border-radius: 16px; background: #0d1714; }
.mode-button { display: flex; align-items: baseline; justify-content: center; gap: 8px; min-height: 48px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); transition: .18s ease; }
.mode-button span { font-weight: 750; }
.mode-button small { font-size: 10px; }
.mode-button.active { background: linear-gradient(135deg, rgba(97, 235, 161, .2), rgba(66, 196, 190, .1)); box-shadow: inset 0 0 0 1px rgba(110, 240, 168, .22); color: #effff6; }

.viewport { position: relative; width: min(100%, 432px); aspect-ratio: 9 / 16; overflow: hidden; touch-action: none; user-select: none; border: 8px solid #18221f; border-radius: 34px; background: #020504; box-shadow: var(--shadow), 0 0 0 1px rgba(231, 255, 244, .12); }
.viewport canvas, .viewport video { display: block; width: 100%; height: 100%; object-fit: fill; background: #000; }
#webrtc-video { display: none; }
.screen-message { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle, rgba(35, 70, 56, .32), rgba(0, 0, 0, .82)); color: #a9bbb2; font-size: 13px; text-align: center; pointer-events: none; }
.screen-message.hidden { display: none; }

.nav-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; width: min(100%, 432px); margin-top: 14px; }
.nav-controls button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: 1px solid var(--panel-border); border-radius: 12px; background: rgba(19, 31, 27, .85); color: #d9e9e1; }
.nav-controls button:hover { border-color: rgba(110, 240, 168, .4); background: rgba(31, 53, 44, .9); }
.nav-controls span { color: var(--muted); font-size: 11px; }

.diagnostics { display: grid; gap: 16px; }
.panel { padding: 22px; border: 1px solid var(--panel-border); border-radius: 20px; background: linear-gradient(145deg, rgba(18, 31, 26, .96), rgba(11, 20, 17, .92)); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 21px; }
.panel-heading.compact { margin-bottom: 14px; }
.mode-badge { padding: 7px 10px; border: 1px solid rgba(110, 240, 168, .25); border-radius: 999px; background: rgba(110, 240, 168, .08); color: var(--green); font: 750 10px/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .1em; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { position: relative; padding: 15px; border: 1px solid rgba(255, 255, 255, .055); border-radius: 14px; background: rgba(0, 0, 0, .16); }
.metric span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.metric strong { font-size: 27px; line-height: 1; letter-spacing: -.04em; }
.metric small { margin-left: 5px; color: #698077; font-size: 9px; }
.details-list { margin: 20px 0 0; border-top: 1px solid var(--panel-border); }
.details-list div { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255, 255, 255, .045); font-size: 12px; }
.details-list dt { color: var(--muted); }
.details-list dd { margin: 0; color: #d6e8df; }

#text-form { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
#text-input { min-width: 0; padding: 11px 13px; border: 1px solid var(--panel-border); border-radius: 11px; outline: none; background: #09120f; color: #effbf5; }
#text-input:focus { border-color: rgba(110, 240, 168, .5); box-shadow: 0 0 0 3px rgba(110, 240, 168, .08); }
#text-form button { padding: 0 17px; border: 0; border-radius: 11px; background: var(--green); color: #082015; font-weight: 800; }
.hint, .compare-panel p { margin: 13px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.compare-panel h2 { margin-bottom: 4px; }
code { color: var(--cyan); }

@media (max-width: 820px) {
  .app-shell { width: min(100% - 22px, 620px); padding-top: 22px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; justify-content: space-between; }
  .workspace { grid-template-columns: 1fr; }
  .viewport { width: min(100%, 390px); }
  .nav-controls { width: min(100%, 390px); }
}

@media (max-width: 450px) {
  .auth-card { padding: 24px; }
  .auth-input-row { grid-template-columns: 1fr; }
  .auth-input-row button { min-height: 44px; }
  .mode-button { align-items: center; flex-direction: column; gap: 2px; }
  .panel { padding: 18px; }
  .metric strong { font-size: 23px; }
}
