:root {
  --bg: #f3efe7;
  --card: #fffdfa;
  --ink: #1c2a2a;
  --brand: #183a37;
  --brand-2: #265f59;
  --line: #d2c7b8;
  --danger: #b24534;
  --ok: #357a38;
  --muted: #7a6f62;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at 10% 20%, #efe7db 0, transparent 40%),
    radial-gradient(circle at 80% 0%, #d9ebe3 0, transparent 35%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(80px);
  opacity: 0.25;
  pointer-events: none;
}

.bg-shape-a {
  width: 220px;
  height: 220px;
  left: -50px;
  top: -30px;
  background: #ffbb70;
}

.bg-shape-b {
  width: 260px;
  height: 260px;
  right: -80px;
  bottom: 80px;
  background: #7bc6b2;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: env(safe-area-inset-top) 14px env(safe-area-inset-bottom);
}

.system-bar {
  margin-top: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(6px);
}

.status-group {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.dot-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #a8a8a8;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.dot.ok {
  background: var(--ok);
}

.dot.warn {
  background: #d79d2f;
}

.dot.bad {
  background: var(--danger);
}

.exec-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
}

.view {
  display: none;
  animation: fadeIn 220ms ease;
  padding: 16px 4px 84px;
}

.view.active {
  display: block;
}

h2 {
  margin: 8px 0 14px;
  font-size: 20px;
}

.keyboard-layout {
  display: grid;
  gap: 12px;
}

.pc-common-block {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 253, 250, 0.88);
  margin-bottom: 12px;
}

.keyboard-block {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 253, 250, 0.85);
}

.shortcut-builder h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--brand);
}

.pc-tools {
  display: grid;
  gap: 8px;
}

.pc-tools-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.5);
}

.pc-tools-group-title {
  margin: 0 0 6px;
  display: flex;
  align-items: center;
}

.pc-tools-group-icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  background: #e9f1ed;
  border: 1px solid #b8ccc3;
}

.pc-tools-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.alpha-rows {
  display: grid;
  gap: 8px;
}

.alpha-row {
  display: grid;
  gap: 8px;
}

.alpha-row.alpha-row-10 {
  grid-template-columns: repeat(10, minmax(0, 1fr));
}

.alpha-row.alpha-row-9 {
  grid-template-columns: repeat(9, minmax(0, 1fr));
  margin: 0 12px;
}

.alpha-row.alpha-row-7 {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin: 0 34px;
}

.alpha-row.alpha-ctrl-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
}

.alpha-row.alpha-ctrl-row .wide {
  grid-column: span 2;
}

.common-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

button,
textarea,
input {
  font: inherit;
}

.alpha-row button,
.common-grid button,
.pc-tools button,
.mouse-buttons-split button,
.mouse-wheel-row button,
.speed-btn,
.profile-actions button,
#sendCustomText,
#addShortcut,
.shortcut-run,
.shortcut-del {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 10px;
  transition: transform 120ms ease, background 120ms ease;
}

.alpha-row button:active,
.common-grid button:active,
.pc-tools button:active,
.mouse-buttons-split button:active,
.mouse-wheel-row button:active,
.speed-btn:active,
.profile-actions button:active,
#sendCustomText:active,
#addShortcut:active,
.shortcut-run:active,
.shortcut-del:active {
  transform: translateY(1px) scale(0.99);
  background: #f4ede1;
}

.alpha-row button,
.common-grid button {
  min-height: 42px;
}

.pc-tools button {
  min-height: 32px;
  padding: 7px 5px;
  font-size: 11px;
}

.pc-tools button.toggle-on {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.common-grid .wide {
  grid-column: span 2;
}

.speed-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.speed-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.mouse-pad {
  height: 220px;
  border: 1px dashed #9ca99f;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(24, 58, 55, 0.08), rgba(255, 255, 255, 0.8));
  user-select: none;
  touch-action: none;
  margin-bottom: 12px;
}

.mouse-buttons-split {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.mouse-buttons-split button {
  text-align: center;
}

.mouse-wheel-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
}

textarea,
input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.shortcut-builder {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 250, 0.85);
  padding: 10px;
}

.shortcut-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.shortcut-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 10px;
}

.shortcut-title {
  margin: 0 0 4px;
  font-size: 15px;
}

.shortcut-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.shortcut-actions {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.shortcut-del {
  color: var(--danger);
}

.form-grid {
  margin-bottom: 10px;
}

.profile-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.profile-actions .ghost {
  grid-column: 1 / span 2;
  background: transparent;
}

.diag-panel {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 10px;
}

.diag-panel h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.diag-grid {
  display: grid;
  gap: 8px;
}

.diag-grid div {
  display: grid;
  gap: 4px;
}

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

.diag-grid strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  word-break: break-all;
}

.tips {
  color: var(--muted);
  font-size: 12px;
}

.tab-bar {
  position: sticky;
  bottom: 0;
  border-top: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.9);
  backdrop-filter: blur(8px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 4px calc(10px + env(safe-area-inset-bottom));
}

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

.tab.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

@keyframes fadeIn {
  from {
    transform: translateY(4px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (min-width: 768px) {
  .app-shell {
    padding: 18px;
  }

  .keyboard-layout {
    grid-template-columns: 1.35fr 1fr;
  }
}
