:root {
  color-scheme: dark;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ink: #f1f5ed;
  --muted: #9ba7a1;
  --panel: #171d1d;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #b8f34a;
  background: #0c1011;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 70% 12%, rgba(184, 243, 74, 0.09), transparent 30%),
    linear-gradient(160deg, #121818 0%, #090c0d 70%);
  overscroll-behavior: none;
}

button, input { font: inherit; }

.shell {
  height: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas:
    "top"
    "pair"
    "pad";
  gap: 14px;
}

.topbar { grid-area: top; display: flex; align-items: center; justify-content: space-between; }
h1 { margin: 0; font-size: 25px; line-height: 1; letter-spacing: -.04em; }
.topbar-actions { position: relative; display: flex; align-items: center; justify-content: flex-end; gap: 7px; }

.status {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 12px; background: rgba(255,255,255,.03);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #65706b; }
.status[data-state="online"] { color: var(--ink); }
.status[data-state="online"] .status-dot { background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.mode-menu-control {
  position: relative;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}
.viewport-mode-button {
  min-width: 44px;
  height: 34px;
  padding: 0 8px;
  color: #aebbb4;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  background: rgba(31,39,37,.78);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
  touch-action: manipulation;
}
.viewport-mode-button[data-active="true"] {
  color: #e7f5cd;
  border-color: rgba(184,243,74,.24);
  background: rgba(68,84,38,.58);
}
.viewport-mode-button:active { transform: translateY(1px); }
.viewport-mode-button[data-awake="true"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: #e7f5cd;
  border-color: rgba(184,243,74,.28);
  background: rgba(55,73,34,.72);
}
.viewport-mode-button[data-awake="true"]::after {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #b8f34a;
  box-shadow: 0 0 8px rgba(184,243,74,.72);
}
.viewport-mode-menu[hidden] { display: none; }
.viewport-mode-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  width: 152px;
  padding: 6px;
  display: grid;
  gap: 3px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  background: rgba(24,31,30,.98);
  box-shadow: 0 18px 40px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.025);
  backdrop-filter: blur(18px);
}
.viewport-mode-menu-item {
  width: 100%;
  min-height: 36px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  color: #b9c4bf;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  font-size: 11px;
  letter-spacing: .04em;
  touch-action: manipulation;
}
.viewport-mode-menu-item:hover,
.viewport-mode-menu-item[data-active="true"] {
  color: #f2f7f4;
  border-color: rgba(184,243,74,.14);
  background: rgba(184,243,74,.075);
}
.mode-menu-caption {
  color: #8f9c95;
  font-size: 9px;
  font-weight: 650;
  letter-spacing: .02em;
  white-space: nowrap;
}
.mode-switch-hint[hidden] { display: none; }
.mode-switch-hint {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 35;
  width: max-content;
  max-width: min(220px, 72vw);
  padding: 8px 9px 8px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f1f7f3;
  border: 1px solid rgba(194,156,255,.42);
  border-radius: 10px;
  background: rgba(45,34,58,.97);
  box-shadow: 0 12px 28px rgba(0,0,0,.28);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.mode-switch-hint::before {
  content: "";
  position: absolute;
  top: -5px;
  right: 34px;
  width: 9px;
  height: 9px;
  border-top: 1px solid rgba(194,156,255,.42);
  border-left: 1px solid rgba(194,156,255,.42);
  background: #2d223a;
  transform: rotate(45deg);
}
.mode-switch-hint button {
  min-height: 24px;
  padding: 0 7px;
  color: #d7c4f3;
  border: 1px solid rgba(215,196,243,.26);
  border-radius: 6px;
  background: rgba(255,255,255,.06);
  font-size: 9px;
  white-space: nowrap;
  touch-action: manipulation;
}
.mode-menu-trigger {
  min-width: 78px;
  height: 34px;
  padding: 0 9px 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #cfd8d2;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  background: rgba(31,39,37,.92);
  box-shadow: 0 5px 14px rgba(0,0,0,.18);
  font-size: 11px;
  letter-spacing: .04em;
  touch-action: manipulation;
}
.mode-current-dot,
.mode-item-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #9ead54;
  box-shadow: 0 0 9px rgba(184,243,74,.32);
  transition: background .18s, box-shadow .18s;
}
.mode-menu-trigger[data-mode="common"] .mode-current-dot { background: #5be5d2; box-shadow: 0 0 9px rgba(91,229,210,.5); }
.mode-menu-trigger[data-mode="browser"] .mode-current-dot { background: #76d8ff; box-shadow: 0 0 9px rgba(118,216,255,.5); }
.mode-menu-trigger[data-mode="coding"] .mode-current-dot { background: #55d3ff; box-shadow: 0 0 9px rgba(85,211,255,.5); }
.mode-menu-trigger[data-mode="presentation"] .mode-current-dot { background: #ff6c63; box-shadow: 0 0 9px rgba(255,108,99,.5); }
.mode-menu-trigger[data-mode="singlehand"] .mode-current-dot { background: #a7f33f; box-shadow: 0 0 9px rgba(167,243,63,.48); }
.mode-menu-chevron {
  margin-top: -3px;
  color: #74817b;
  font-size: 13px;
  line-height: 1;
  transition: transform .16s, color .16s;
}
.mode-menu-trigger[aria-expanded="true"] {
  color: #f1f7f3;
  border-color: rgba(184,243,74,.28);
  background: #252e2c;
}
.mode-menu-trigger[aria-expanded="true"] .mode-menu-chevron { color: #b8f34a; transform: rotate(180deg); }
.mode-menu[hidden] { display: none; }
.mode-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  width: 142px;
  padding: 6px;
  display: grid;
  gap: 3px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  background: rgba(24,31,30,.98);
  box-shadow: 0 18px 40px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.025);
  backdrop-filter: blur(18px);
}
.mode-menu-item {
  position: relative;
  width: 100%;
  height: 39px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  color: #b9c4bf;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  font-size: 11px;
  letter-spacing: .06em;
  touch-action: manipulation;
}
.mode-menu-item::after {
  content: "";
  position: absolute;
  right: 12px;
  width: 5px;
  height: 9px;
  border-right: 1.5px solid transparent;
  border-bottom: 1.5px solid transparent;
  transform: rotate(45deg);
}
.mode-menu-item:hover { color: #eef4f1; background: rgba(255,255,255,.045); }
.mode-menu-item[aria-checked="true"] {
  color: #f2f7f4;
  border-color: rgba(184,243,74,.14);
  background: rgba(184,243,74,.075);
}
.mode-menu-item[aria-checked="true"]::after { border-color: #b8f34a; }
.mode-menu-item-singlehand .mode-item-dot { background: #9ead54; box-shadow: none; }
.mode-menu-item-touchpad .mode-item-dot { background: #5be5d2; box-shadow: none; }
.mode-menu-item-browser .mode-item-dot { background: #76d8ff; box-shadow: 0 0 8px rgba(118,216,255,.32); }
.mode-menu-item-media .mode-item-dot { background: #c59aff; box-shadow: 0 0 8px rgba(197,154,255,.32); }
.mode-menu-item-coding .mode-item-dot { background: #55d3ff; box-shadow: none; }
.mode-menu-item-presentation .mode-item-dot { background: #ff6c63; box-shadow: none; }
.mode-menu-item-sketch .mode-item-dot { background: #5be5d2; box-shadow: 0 0 8px rgba(91,229,210,.36); }
.mode-menu-item-tactics .mode-item-dot { background: #f0c86b; box-shadow: 0 0 8px rgba(240,200,107,.32); }
.mode-menu-trigger[data-mode="tactics"] .mode-current-dot { background: #f0c86b; box-shadow: 0 0 9px rgba(240,200,107,.52); }

/* Landscape-first tablet pointer surface with a compact control rail. */
.sketch-pad[hidden] { display: none; }
body.sketchpad-mode {
  background:
    radial-gradient(circle at 68% 8%, rgba(91,229,210,.09), transparent 32%),
    linear-gradient(155deg, #111819 0%, #080c0d 72%);
}
body.sketchpad-mode .shell,
body.sketchpad-mode .landscape-touchpad {
  display: none !important;
}
.sketch-pad {
  --sketch-accent: #5be5d2;
  --sketch-accent-rgb: 91, 229, 210;
  --landscape-accent: var(--sketch-accent);
  --landscape-accent-rgb: var(--sketch-accent-rgb);
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100%;
  height: 100dvh;
  min-width: 0;
  min-height: 0;
  padding:
    max(8px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: 70px minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
  color: #edf5f2;
  background:
    radial-gradient(circle at 48% 108%, rgba(91,229,210,.07), transparent 44%),
    linear-gradient(155deg, #141a1b 0%, #0b0f10 58%, #080c0d 100%);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}
.sketch-toolbar {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.sketch-brand,
.sketch-toolbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
}
.sketch-brand { gap: 8px; }
.sketch-brand strong {
  color: #f0f6f3;
  font-size: 13px;
  letter-spacing: .08em;
}
.sketch-keyboard-button,
.sketch-toolbar-button {
  color: #cbd6d1;
  border: 1px solid rgba(255,255,255,.11);
  background: linear-gradient(180deg, rgba(38,48,46,.96), rgba(25,32,31,.98));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035), 0 7px 16px rgba(0,0,0,.18);
  touch-action: manipulation;
}
.sketch-keyboard-button {
  min-width: 70px;
  height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 11px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.sketch-keyboard-button > span:first-child { color: var(--sketch-accent); font-size: 16px; }
.sketch-keyboard-button.pressed {
  color: #071311;
  border-color: rgba(var(--sketch-accent-rgb),.86);
  background: var(--sketch-accent);
  box-shadow: 0 0 20px rgba(var(--sketch-accent-rgb),.2);
}
.sketch-keyboard-button.pressed > span:first-child { color: inherit; }
.sketch-keyboard-button:active,
.sketch-toolbar-button:active { transform: scale(.98); }
.sketch-toolbar-actions { justify-content: flex-end; gap: 7px; }
.sketch-quick-input-slot {
  width: min(100%, 480px);
  min-width: 0;
  justify-self: center;
}
.sketch-quick-input-slot .quick-input {
  width: 100%;
  grid-template-columns: minmax(0, 1fr) 46px 66px;
  gap: 7px;
}
.sketch-quick-input-slot .quick-text,
.sketch-quick-input-slot .quick-key {
  height: 46px;
  min-height: 46px;
  border-radius: 12px;
  font-size: 12px;
}
.sketch-quick-input-slot .quick-send { font-size: 20px; }
.sketch-quick-input-slot .enter-key { font-size: 12px; }
.sketch-mode-menu-wrap { position: relative; }
.sketch-mode-switcher[hidden] { display: none; }
.sketch-mode-switcher {
  position: absolute;
  z-index: 20;
  top: calc(100% + 7px);
  right: 0;
  width: 184px;
  max-height: calc(100dvh - 62px);
  padding: 6px;
  display: grid;
  gap: 3px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 13px;
  background: rgba(20,29,27,.98);
  box-shadow: 0 18px 38px rgba(0,0,0,.42);
  backdrop-filter: blur(16px);
}
.sketch-mode-switcher button {
  min-height: 42px;
  padding: 6px 9px;
  display: grid;
  justify-items: start;
  gap: 2px;
  color: #d2ddd7;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  font: inherit;
  text-align: left;
  touch-action: manipulation;
}
.sketch-mode-switcher button:hover,
.sketch-mode-switcher button:active { border-color: rgba(var(--sketch-accent-rgb),.24); background: rgba(var(--sketch-accent-rgb),.09); }
.sketch-mode-switcher b { font-size: 11px; letter-spacing: .04em; }
.sketch-mode-switcher span { color: #8c9a94; font-size: 9px; line-height: 1.25; }
.sketch-toolbar-button {
  min-width: 58px;
  height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 10px;
  letter-spacing: .05em;
}
.sketch-workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(210px, .4fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
}
.sketch-canvas-shell {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(91,229,210,.28);
  border-radius: 18px;
  background-color: #fbfcf8;
  background-image:
    linear-gradient(rgba(91,229,210,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91,229,210,.07) 1px, transparent 1px);
  background-size: 28px 28px;
  box-shadow:
    0 20px 42px rgba(0,0,0,.3),
    inset 0 0 0 5px rgba(9,18,18,.05);
  touch-action: none;
}
.sketch-canvas-shell::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px dashed rgba(23,32,30,.13);
  border-radius: 11px;
  pointer-events: none;
}
#sketchCanvas,
#sketchDragCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#sketchCanvas { pointer-events: none; }
#sketchDragCanvas[hidden] { display: none; }
.sketch-trackpad-slot {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
}
.sketch-keyboard-slot[hidden] { display: none; }
.sketch-keyboard-slot {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.sketch-pad.keyboard-open > .sketch-workspace { display: none; }
.sketch-pad.keyboard-open > .sketch-keyboard-slot { display: block; }
.sketch-keyboard-slot > .computer-keyboard {
  width: 100%;
  height: 100%;
  --landscape-accent: var(--sketch-accent);
  --landscape-accent-rgb: var(--sketch-accent-rgb);
}
.sketch-trackpad-slot .sketch-shared-trackpad {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 17px;
}
.sketch-shared-trackpad .pure-mouse-cluster,
.sketch-shared-trackpad .pure-gesture-labels,
.sketch-shared-trackpad .landscape-zone-labels { display: none; }
.sketch-move-shell {
  border-color: rgba(91,229,210,.18);
  background:
    radial-gradient(circle at 50% 48%, rgba(91,229,210,.12), transparent 48%),
    linear-gradient(145deg, #1b2826, #111a19 72%);
  box-shadow: 0 18px 40px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.05);
}
.sketch-move-shell::before {
  inset: 8px;
  border-style: solid;
  border-color: rgba(255,255,255,.05);
}
.sketch-drag-shell {
  border-color: rgba(240,200,107,.34);
  background-color: #fffdf5;
  background-image:
    linear-gradient(rgba(240,200,107,.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(240,200,107,.09) 1px, transparent 1px);
}
.sketch-drag-shell::before { border-color: rgba(72,57,23,.16); }
.sketch-control-panel {
  position: relative;
  z-index: 2;
  min-height: 0;
  height: 100%;
  padding: clamp(12px, 1.5vw, 18px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(10px, 1.5vw, 16px);
}
.sketch-hold-button.pressed,
.sketch-hold-button:active {
  transform: scale(.955);
  filter: brightness(.9);
}
.sketch-history-actions {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 1.1vw, 12px);
}
.sketch-history-button {
  min-width: 0;
  min-height: clamp(52px, 7.5vh, 68px);
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: #d9eee7;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  background: linear-gradient(155deg, rgba(43,62,58,.96), rgba(28,40,38,.98));
  box-shadow: 0 8px 18px rgba(0,0,0,.18), inset 0 1px rgba(255,255,255,.05);
  font-size: clamp(12px, 1.55vw, 15px);
  font-weight: 650;
  letter-spacing: .03em;
  touch-action: manipulation;
}
.sketch-history-button:first-child { color: #8df2dc; }
.sketch-history-button:last-child { color: #f0ce81; }
.sketch-history-button:active { transform: scale(.96); }
.sketch-zoom-modifier {
  min-width: 0;
  min-height: 0;
  padding: 14px 10px;
  display: grid;
  place-content: center;
  gap: 7px;
  color: #d8f8ee;
  border: 1px solid rgba(91,229,210,.26);
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 38%, rgba(91,229,210,.14), transparent 45%),
    linear-gradient(145deg, rgba(37,61,56,.98), rgba(20,34,31,.99));
  box-shadow: 0 14px 28px rgba(0,0,0,.22), inset 0 1px rgba(255,255,255,.06);
  font: inherit;
  touch-action: none;
  user-select: none;
}
.sketch-zoom-modifier b { color: #8cf4dc; font-size: clamp(38px, 6vw, 68px); line-height: .8; font-weight: 350; }
.sketch-zoom-modifier strong { font-size: clamp(15px, 2vw, 20px); letter-spacing: .14em; }
.sketch-zoom-modifier span { color: #97aea6; font-size: 10px; letter-spacing: .05em; }
.sketch-zoom-modifier.pressed { border-color: rgba(91,229,210,.72); background: rgba(33,84,74,.98); }
@media (max-height: 430px) and (orientation: landscape) {
  .sketch-pad { grid-template-rows: 58px minmax(0, 1fr); gap: 6px; }
  .sketch-toolbar { gap: 7px; }
  .sketch-brand strong { font-size: 12px; }
  .sketch-keyboard-button, .sketch-toolbar-button { height: 32px; }
  .sketch-quick-input-slot { min-width: min(200px, 25vw); }
  .sketch-quick-input-slot .quick-text,
  .sketch-quick-input-slot .quick-key { height: 40px; min-height: 40px; }
  .sketch-control-panel { padding: 9px; gap: 7px; }
  .sketch-history-actions { gap: 6px; }
  .sketch-history-button { min-height: 44px; padding: 0 7px; font-size: 11px; }
  .sketch-scroll-modifier { padding: 9px; gap: 5px; border-radius: 15px; }
  .sketch-scroll-modifier b { font-size: clamp(32px, 6vw, 48px); }
  .sketch-scroll-modifier strong { font-size: 13px; }
  .sketch-scroll-modifier span { font-size: 8px; }
}

@media (max-height: 620px) {
  .shell.single-hand-mode .control-ring {
    width: min(78vw, 38vh, 318px);
    min-width: 220px;
  }
  .shell.single-hand-mode .window-utility-row { bottom: 12px; }
}
