/* === Web Fonts (Variable, latin subset) === */
/* Apple: SF Pro Rounded (system). Non-Apple: Nunito (variable, 400-800). */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/Nunito-Variable.woff2") format("woff2");
}

/* Mono: JetBrains Mono (variable, 400-700). */
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/JetBrainsMono-Variable.woff2") format("woff2");
}

/* === Design Tokens === */
:root {
  /* Fonts: SF Pro Rounded first (Apple system rounded), Nunito fallback (non-Apple),
     then system fallbacks. */
  --font-sans: "SF Pro Rounded", "Nunito", -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --bg-page: #fffbf5;
  --bg-card: #ffffff;
  --bg-soft: #fff5eb;
  --bg-chip: #fef9f4;
  --text-primary: #1c1917;
  --text-secondary: #78716c;
  --text-muted: #7c756f;
  --text-placeholder: #8a827c;
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.1);
  --accent: #e8793a;
  --accent-deep: #c2410c;
  --accent-soft: #fff5eb;
  --accent-softer: #fef9f4;
  --accent-gradient: linear-gradient(135deg, #f97316, #ea580c);
  --accent-glow: rgba(232, 121, 58, 0.35);
  --accent-text: #ffffff;
  --accent-dim: rgba(255, 140, 66, 0.15);
  --danger: #ef4444;
  --danger-text: #ffffff;
  --shadow-card: 0 2px 12px rgba(200, 120, 50, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-button: 0 1px 4px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.06);
  --shadow-button-hover: 0 4px 14px rgba(200, 120, 50, 0.12), 0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-accent: 0 2px 10px rgba(232, 121, 58, 0.3);
  --shadow-accent-lg: 0 4px 16px rgba(232, 121, 58, 0.35);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --gap: clamp(6px, 0.9svh, 10px);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  color-scheme: light dark;
  font-family: var(--font-sans);
  background: linear-gradient(165deg, #fffbf5 0%, #fff5eb 40%, #fef7f0 100%);
  background-attachment: fixed;
  color: var(--text-primary);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: linear-gradient(165deg, #fffbf5 0%, #fff5eb 40%, #fef7f0 100%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

button,
textarea {
  font: inherit;
}

button {
  min-width: 0;
}

svg {
  display: block;
}

.hidden {
  display: none !important;
}

/* === Shell === */
.shell {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  height: 100svh;
  display: grid;
  place-items: center;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  overflow: hidden;
}

.panel {
  width: min(calc(100vw - 20px), 420px);
  max-width: 100%;
  height: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  overflow: hidden;
}

/* === Header === */
.app-header {
  min-height: clamp(36px, 5svh, 48px);
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.brand-mark {
  width: clamp(28px, 4.2svh, 38px);
  height: clamp(28px, 4.2svh, 38px);
  display: grid;
  place-items: center;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 22.37%;
}

.brand {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(20px, 2.8svh, 30px);
  font-weight: 800;
  letter-spacing: 0;
  color: var(--text-primary);
}

h1.brand {
  margin: 0;
}

fieldset.add-cmd-fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

fieldset.add-cmd-fieldset legend {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding: 0;
}

.refresh-button {
  width: clamp(30px, 4.2svh, 40px);
  height: clamp(30px, 4.2svh, 40px);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.2s var(--ease-smooth), transform 0.2s var(--ease-bounce);
}

.refresh-button:active {
  transform: scale(0.9);
}

.refresh-button svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.billing-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.billing-button {
  min-height: 32px;
  max-width: 76px;
  padding: 0 9px;
  border: 1px solid rgba(232, 121, 58, 0.18);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: var(--shadow-button);
}

.billing-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.billing-upgrade-button {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* === Target Device === */
.device-pill {
  min-height: clamp(44px, 6svh, 58px);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: clamp(5px, 1.5vw, 10px);
  padding: 6px clamp(8px, 2vw, 12px);
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  flex: 0 0 auto;
  min-width: 0;
}

.device-icon {
  width: clamp(34px, 5svh, 46px);
  height: clamp(34px, 5svh, 46px);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent-gradient);
  color: var(--accent-text);
  box-shadow: var(--shadow-accent);
}

.device-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--text-muted);
  cursor: pointer;
}

.status-dot.connected {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(232, 121, 58, 0.4);
}

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

.status-dot.connecting {
  background: var(--text-muted);
  animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
  0%,
  100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.status-badge {
  flex: 0 0 auto;
  padding: 3px 8px;
  border: 1px solid rgba(232, 121, 58, 0.15);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: clamp(11px, 1.4svh, 13px);
  font-weight: 700;
  white-space: nowrap;
}

.status-badge.error {
  border-color: #f3c6c6;
  background: #fef2f2;
  color: var(--danger);
}

.status-badge.connecting {
  border-color: var(--border);
  background: var(--bg-soft);
  color: var(--text-secondary);
}

/* === Window Selector === */
.window-selector {
  position: relative;
  min-width: 0;
  flex: 1 1 auto;
}

.window-btn {
  width: 100%;
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: clamp(13px, 2svh, 17px);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

#windowBtnLabel {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.window-btn.active {
  color: var(--text-primary);
}

.window-btn-arrow {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 13px;
}

.window-dropdown {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, calc(100vw - 28px));
  max-height: min(340px, 55svh);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: 0 14px 34px rgba(200, 120, 50, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}

.window-dropdown:not(.hidden) {
  display: flex;
}

.window-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
}

.window-list-loading,
.window-list-empty {
  padding: 16px;
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.window-app-group {
  border-bottom: 1px solid var(--border);
}

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

.window-app-label {
  padding: 7px 12px 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
}

.window-item {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.window-item:hover,
.window-item.selected {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.window-item-check {
  width: 16px;
  flex: 0 0 auto;
  font-size: 12px;
}

.window-item-title {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.window-refresh-btn {
  width: 100%;
  padding: 10px;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}

/* === Toast === */
.toast {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--text-primary);
  color: var(--bg-card);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  visibility: visible;
}

.toast.error {
  background: var(--danger);
  color: var(--danger-text);
}

.toast-copy-btn {
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  border: none;
  padding: 4px 10px;
  margin-left: 8px;
  border-radius: 4px;
  font-size: 0.75em;
  cursor: pointer;
  white-space: nowrap;
}

.toast-copy-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* === Input === */
.input-card {
  min-height: clamp(120px, 20svh, 200px);
  display: flex;
  flex-direction: column;
  padding: clamp(10px, 1.6svh, 16px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
  flex: 1 1 auto;
  min-width: 0;
  transition: box-shadow 0.3s var(--ease-smooth);
}

.input-card:focus-within {
  box-shadow: var(--shadow-button-hover);
}

.input-card.editing {
  border-color: var(--accent);
  box-shadow: var(--shadow-accent);
}

.edit-label-input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 0 6px 0;
  margin-bottom: 6px;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  outline: none;
}

.edit-label-input::placeholder {
  color: var(--text-placeholder);
  font-weight: 600;
}

.edit-label-input:focus {
  border-bottom-color: var(--accent);
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.text-input {
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: clamp(18px, 2.5svh, 24px);
  line-height: 1.45;
  resize: none;
  overflow-y: auto;
  word-break: break-word;
}

.text-input::placeholder {
  color: var(--text-placeholder);
}

.input-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  color: var(--text-secondary);
  flex: 0 0 auto;
}

.char-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

/* === Main Actions === */
.primary-actions {
  min-height: clamp(62px, 9svh, 84px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 1.5vw, 8px);
  flex: 0 0 auto;
  min-width: 0;
}

/* === Utility Keys === */
.utility-keys {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 0 8px;
  flex: 0 0 auto;
}

.util-key-btn {
  flex: 1 1 0;
  max-width: 104px;
  min-height: 52px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 14px;
  box-shadow: var(--shadow-card);
  transition: all 0.15s;
}

.util-key-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.util-key-btn:active {
  transform: scale(0.94);
  background: var(--accent-soft);
}

.util-key-btn.new-key {
  border-color: rgba(249, 115, 22, 0.4);
  color: #f97316;
}

.util-key-sep {
  flex: 1 1 0;
  max-width: 8px;
}

/* Pink accent — reuses cmd-recent colors */
.util-key-btn.pink-key {
  border-color: rgba(253, 110, 158, 0.3);
  color: #F53F80;
}
.util-key-btn.pink-key svg {
  stroke: #F53F80;
}
.side-action-btn.pink-accent {
  background: rgba(253, 110, 158, 0.12);
  border-color: rgba(253, 110, 158, 0.3);
  color: #F53F80;
}
.side-action-btn.pink-accent svg {
  stroke: #F53F80;
}

.side-action-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: clamp(60px, 9svh, 80px);
  max-width: 120px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: clamp(11px, 1.5svh, 14px);
  font-weight: 700;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
}

.side-action-btn:hover {
  box-shadow: var(--shadow-button-hover);
}

.side-action-btn svg {
  width: clamp(20px, 3svh, 24px);
  height: clamp(20px, 3svh, 24px);
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.record-button {
  width: clamp(62px, 8.5svh, 80px);
  height: clamp(62px, 8.5svh, 80px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-gradient);
  color: var(--accent-text);
  box-shadow: var(--shadow-accent-lg);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform 0.2s var(--ease-bounce), box-shadow 0.2s var(--ease-smooth);
}

.record-button:active:not(:disabled) {
  transform: scale(0.9);
  box-shadow: var(--shadow-accent);
}

.record-button:disabled {
  background: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

.record-button.recording {
  background: var(--danger);
  box-shadow: 0 12px 28px rgba(239, 68, 68, 0.35);
}

.record-icon {
  width: clamp(24px, 3.4svh, 32px);
  height: clamp(24px, 3.4svh, 32px);
  display: grid;
  place-items: center;
}

.record-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.record-icon-stop svg {
  stroke-width: 0;
}

.record-icon-stop svg rect {
  fill: currentColor;
}

.record-button.recording .record-icon {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.34); }
  50% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
}

.record-label {
  font-size: clamp(12px, 1.75svh, 16px);
  font-weight: 800;
  line-height: 1.1;
}

/* === Fallback Upload === */
.fallback-button {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 700;
  cursor: pointer;
  flex: 0 0 auto;
}

/* === Command Library Panel === */
.library-panel {
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* === Library Tabs === */
.library-tabs {
  display: flex;
  align-items: center;
  min-height: 44px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.tab-scroll {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 8px;
  scrollbar-width: none;
}

.tab-scroll::-webkit-scrollbar { display: none; }

.tab-item {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s var(--ease-smooth);
  user-select: none;
}

.tab-item.active {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 1px 6px rgba(232, 121, 58, 0.3);
}

.tab-count {
  font-size: 10px;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255,255,255,0.25);
  color: inherit;
  padding: 0 4px;
}

.tab-item:not(.active) .tab-count {
  background: var(--accent-dim);
  color: var(--accent);
}

.tab-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  flex: 0 0 auto;
  border-left: 1px solid var(--border);
  margin-left: 2px;
}

.icon-btn {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
}

.icon-btn:active {
  transform: scale(0.92);
  color: var(--accent);
}

.icon-btn svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn.add-btn {
  padding: 0 10px;
  background: var(--accent-dim);
  color: var(--accent);
}

.icon-btn.add-btn:active {
  background: var(--accent);
  color: var(--accent-text);
}

.device-search-btn {
  flex: 0 0 auto;
  min-height: 28px;
  min-width: 28px;
  padding: 0;
  border-radius: 999px;
  color: var(--text-muted);
}

.device-search-btn:active {
  color: var(--accent);
}

/* === Command Search Bar === */
.cmd-search-bar {
  padding: 6px clamp(10px, 2.5vw, 14px);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.cmd-search-input {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  transition: border-color 0.2s var(--ease-smooth);
}

.cmd-search-input::placeholder {
  color: var(--text-muted);
}

.cmd-search-input:focus {
  border-color: var(--accent);
  border-width: 2px;
  outline: none;
}

/* === Command Area Content === */
.command-library {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0;
}

/* === Command Grid === */
.cmd-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 2px clamp(8px, 2vw, 12px) clamp(8px, 1.1svh, 12px);
  min-width: 0;
}

.cmd-separator {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--border);
  margin: 4px 0 2px;
  opacity: 0.5;
}

.cmd-btn {
  min-width: 0;
  min-height: clamp(30px, 4.2svh, 40px);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  gap: 3px;
  padding: 0 6px;
  border: none;
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: clamp(12px, 1.7svh, 15px);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
  box-shadow: var(--shadow-card);
}

.cmd-btn:active {
  transform: scale(0.92);
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow-accent);
}

.cmd-btn.cmd-recent {
  background: rgba(253, 110, 158, 0.12);
  color: #F53F80;
}

.cmd-btn.slash {
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
}

.cmd-btn.dimmed {
  opacity: 0.35;
  pointer-events: none;
}

/* === Edit Mode Action Buttons === */
.edit-action-btn {
  min-height: 28px;
  padding: 0 10px;
  gap: 5px;
  font-size: 12px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
  border: 1px solid rgba(232, 121, 58, 0.2);
  background: var(--accent-soft);
  color: var(--accent);
}

.edit-delete-btn {
  background: #fef2f2;
  border-color: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.edit-save-btn {
  background: var(--accent-gradient);
  border: none;
  color: var(--accent-text);
  box-shadow: var(--shadow-accent);
}

.edit-cancel-btn {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-secondary);
}

.cmd-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === Add Command Dialog === */
.add-cmd-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
}

.add-cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(200, 120, 50, 0.15);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.add-cmd-sheet {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  max-width: 430px;
  margin: 0 auto;
  padding: 20px;
  border-radius: 22px 22px 0 0;
  background: var(--bg-card);
  z-index: 101;
}

.add-cmd-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 0 auto 14px;
}

/* === Account Drawer === */
.account-drawer {
  position: fixed;
  inset: 0;
  z-index: 150;
}
.account-drawer.hidden {
  display: none;
}
.account-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(200, 120, 50, 0.15);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}
.account-drawer-sheet {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  max-width: 430px;
  margin: 0 auto;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--bg-card);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
  z-index: 151;
  max-height: 80svh;
  display: grid;
  grid-template-rows: auto 1fr;
  transform: translateY(100%);
  transition: transform 0.35s var(--ease-smooth);
}
.account-drawer:not(.hidden) .account-drawer-sheet {
  transform: translateY(0);
}
.account-drawer-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 0 auto 14px;
}
.account-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.account-drawer-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}
.account-drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: var(--bg-soft);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.account-drawer-close:hover {
  background: var(--border-strong);
}
.account-drawer-body {
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.account-drawer-body::-webkit-scrollbar {
  width: 4px;
}
.account-drawer-body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

/* === Plan Badge === */
.plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: var(--bg-soft);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.plan-badge.pro {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: rgba(232, 121, 58, 0.2);
}

/* === Account Section === */
.account-section {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-soft);
}
.account-section-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 10px;
}
.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.account-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.account-row-label {
  font-size: 14px;
  color: var(--text-secondary);
}
.account-row-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.account-action-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.account-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.account-action-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.account-action-btn.primary:hover {
  background: var(--accent-deep);
}
.account-action-btn.danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}
.account-action-btn.danger:hover {
  background: #fef2f2;
}

/* === Usage Bar === */
.usage-bar-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-top: 6px;
}
.usage-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-gradient);
  transition: width 0.4s var(--ease-smooth);
}
.usage-bar-fill.warning {
  background: linear-gradient(90deg, #f59e0b, #d97706);
}
.usage-bar-fill.critical {
  background: linear-gradient(90deg, #ef4444, #dc2626);
}
.usage-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.usage-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.usage-stat-label {
  color: var(--text-secondary);
}
.usage-stat-value {
  font-weight: 700;
  color: var(--text-primary);
}

/* === Pricing Cards === */
.pricing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pricing-card {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  text-align: center;
}
.pricing-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.pricing-card-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 8px;
}
.pricing-card.active .pricing-card-name {
  color: var(--accent);
}
.pricing-card-item {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 3px 0;
}
.pricing-card-btn {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  border-radius: 999px;
  border: none;
  background: var(--accent-gradient);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-accent);
}
.pricing-card-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.pricing-card-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 800;
  margin-left: 4px;
}

/* === Device List === */
.device-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.device-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.device-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--text-muted);
  flex-shrink: 0;
}
.device-status-dot.online {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(232, 121, 58, 0.4);
}
.device-info {
  flex: 1;
  min-width: 0;
}
.device-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-last-seen {
  font-size: 12px;
  color: var(--text-muted);
}
.device-remove-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
.device-remove-btn:hover {
  color: var(--danger);
  background: #fef2f2;
}

/* === Profile Edit === */
.profile-edit-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-edit-input {
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
}
.profile-edit-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 121, 58, 0.15);
}
.profile-edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.add-cmd-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 14px;
}

.add-cmd-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.add-cmd-textarea {
  width: 100%;
  min-height: 96px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.45;
  resize: none;
  margin-bottom: 14px;
}

.add-cmd-select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

.add-cmd-new-cat {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 14px;
}

.add-cmd-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.add-cmd-cancel {
  flex: 1;
  min-height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.add-cmd-confirm {
  flex: 1;
  min-height: 42px;
  border-radius: var(--radius-sm);
  border: 0;
  background: var(--accent-gradient);
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-accent);
}

/* === Save Button === */
.save-btn {
  min-height: clamp(36px, 5svh, 48px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 clamp(14px, 3vw, 22px);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: clamp(14px, 2svh, 18px);
  font-weight: 800;
  box-shadow: var(--shadow-button);
  cursor: pointer;
}

.save-btn svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: var(--accent);
}

.save-btn.saved {
  color: var(--text-secondary);
  pointer-events: none;
}

.save-btn-sm {
  min-height: 28px;
  padding: 0 10px;
  gap: 5px;
  font-size: 12px;
  border: 1px solid rgba(232, 121, 58, 0.2);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
}

.save-btn-sm svg {
  width: 14px;
  height: 14px;
}

.toggle-switch {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: clamp(13px, 1.9svh, 17px);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input {
  display: none;
}

.toggle-track {
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.2s;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--bg-card);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.22);
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
}

/* === Compact toggle for device-pill === */
.toggle-track-sm {
  width: 36px;
  height: 20px;
}

.toggle-thumb-sm {
  width: 16px;
  height: 16px;
  top: 2px;
  left: 2px;
}

.toggle-switch input:checked + .toggle-track-sm .toggle-thumb-sm {
  transform: translateX(16px);
}

.toggle-label-sm {
  font-size: clamp(11px, 1.5svh, 13px);
}

.device-toggle {
  gap: 6px;
  margin-left: auto;
}

.device-toggle svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

@media (max-width: 395px), (max-height: 760px) {
  :root {
    --gap: 5px;
  }

  .shell {
    padding: max(6px, env(safe-area-inset-top)) 8px max(6px, env(safe-area-inset-bottom));
  }

  .panel {
    width: calc(100vw - 16px);
  }

  .device-pill {
    padding: 5px 8px;
    gap: 4px;
  }

  .status-badge {
    padding: 2px 6px;
    font-size: 10px;
  }

  .primary-actions {
    gap: 4px;
  }

  .utility-keys {
    gap: 4px;
  }

  .util-key-btn {
    min-height: 44px;
    font-size: 12px;
    padding: 0 8px;
  }

  .side-action-btn {
    min-height: 54px;
    padding: 4px 0;
    font-size: 10px;
  }

  .side-action-btn svg {
    width: 20px;
    height: 20px;
  }

  .cmd-grid {
    gap: 5px;
    padding: 2px 6px 6px;
  }

  .input-card {
    padding: 10px;
  }
}

@media (max-width: 395px) {
  .pricing-grid {
    grid-template-columns: 1fr;
  }
  .account-drawer-sheet {
    padding: 16px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #181716;
    --bg-card: #272523;
    --bg-soft: #201e1c;
    --bg-chip: #2a2418;
    --text-primary: #f4f1ed;
    --text-secondary: #c1bdb7;
    --text-muted: #a09a94;
    --text-placeholder: #8a827c;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.12);
    --accent: #f97316;
    --accent-deep: #fdba74;
    --accent-soft: #2a1f14;
    --accent-softer: #231a12;
    --accent-gradient: linear-gradient(135deg, #f97316, #ea580c);
    --accent-glow: rgba(249, 115, 22, 0.3);
    --accent-text: #ffffff;
    --danger: #ef4444;
    --shadow-card: 0 12px 28px rgba(0, 0, 0, 0.28);
    --shadow-button: 0 4px 14px rgba(0, 0, 0, 0.22);
    --shadow-accent: 0 2px 10px rgba(249, 115, 22, 0.25);
    --shadow-accent-lg: 0 4px 16px rgba(249, 115, 22, 0.3);
    --shadow-button-hover: 0 6px 20px rgba(0, 0, 0, 0.35);
  }

  .brand-mark,
  .device-pill,
  .input-card,
  .library-panel,
  .save-btn,
  .side-action-btn {
    background: var(--bg-card);
  }

  .status-badge {
    border-color: rgba(249, 115, 22, 0.2);
    background: var(--accent-soft);
    color: var(--accent-deep);
  }

  .status-badge.error {
    border-color: #7f1d1d;
    background: #2a1212;
    color: #fca5a5;
  }

  .status-badge.connecting {
    border-color: var(--border);
    background: var(--bg-soft);
    color: var(--text-secondary);
  }

  .window-dropdown,
  .add-cmd-sheet {
    background: var(--bg-card);
  }

  .edit-delete-btn {
    background: #3b1515;
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
  }

  .add-cmd-textarea,
  .add-cmd-select,
  .add-cmd-new-cat {
    background: var(--bg-soft);
  }

  .input-card {
    border-color: rgba(255, 255, 255, 0.08);
  }

  .window-dropdown {
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.2);
  }

  .toast-copy-btn {
    background: rgba(255, 255, 255, 0.1);
  }

  body {
    background: linear-gradient(165deg, #181716 0%, #1f1c18 40%, #1a1816 100%);
    background-attachment: fixed;
  }

  .auth-card {
    background: var(--bg-card);
    color: var(--text-primary);
  }
  .auth-link-btn {
    color: var(--text-secondary);
  }
  .auth-reset-info {
    color: var(--text-secondary);
  }

  .account-drawer-sheet {
    background: var(--bg-card);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
  }
  .account-drawer-close {
    background: var(--bg-soft);
  }
  .account-section {
    background: var(--bg-soft);
  }
  .pricing-card {
    background: var(--bg-card);
  }
  .profile-edit-input {
    background: var(--bg-card);
    color: var(--text-primary);
  }
  .device-remove-btn:hover {
    background: #3b1515;
    color: #fca5a5;
  }
  .account-action-btn.danger:hover {
    background: #3b1515;
  }
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  overflow-y: auto;
  color-scheme: light;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 181, 201, 0.22), transparent 32%),
    radial-gradient(circle at 88% 92%, rgba(255, 188, 111, 0.18), transparent 34%),
    #f7f6f9;
  color: #201b24;
}

.auth-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-wave {
  position: absolute;
  display: block;
  width: min(62vw, 560px);
  aspect-ratio: 1;
  border: 1px solid rgba(240, 82, 115, 0.12);
  border-radius: 50%;
}

.auth-wave-one {
  top: -38vw;
  right: -24vw;
}

.auth-wave-two {
  top: -32vw;
  right: -18vw;
  transform: scale(0.72);
}

.auth-wave-three {
  bottom: -42vw;
  left: -28vw;
  transform: scale(1.08);
}

.auth-surface {
  position: relative;
  width: min(100%, 424px);
  display: grid;
  gap: 22px;
  padding: clamp(24px, 5vw, 38px);
  border: 1px solid rgba(42, 34, 48, 0.08);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 30px 80px rgba(67, 45, 72, 0.14), 0 2px 8px rgba(67, 45, 72, 0.06);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

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

.auth-logo {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(241, 92, 126, 0.2);
}

.auth-eyebrow,
.pairing-eyebrow {
  margin: 0 0 5px;
  color: #8b7e8e;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.auth-title {
  margin: 0;
  color: #201b24;
  font-size: clamp(26px, 7vw, 32px);
  font-weight: 850;
  letter-spacing: -0.04em;
  line-height: 1;
  text-align: left;
}

.auth-subtitle {
  max-width: 32ch;
  margin: -6px 0 0;
  color: #6e6471;
  font-size: 14px;
  line-height: 1.65;
  text-align: left;
}

.auth-overlay.hidden {
  display: none;
}

.auth-card {
  width: 100%;
  display: grid;
  gap: 14px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #201b24;
  box-shadow: none;
}

.auth-field {
  display: grid;
  gap: 7px;
}

.auth-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auth-label {
  color: #3d3440;
  font-size: 13px;
  font-weight: 750;
}

.auth-input {
  width: 100%;
  min-height: 50px;
  padding: 0 15px;
  border: 1px solid #ded9e0;
  border-radius: 14px;
  outline: none;
  background: #fbfafc;
  color: #201b24;
  font-size: 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.auth-input::placeholder {
  color: #968d98;
}

.auth-input:hover {
  border-color: #c9c1cc;
  background: #fff;
}

.auth-input:focus {
  border-color: #f05273;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(240, 82, 115, 0.11);
}

.auth-submit-btn,
.auth-switch-btn,
.auth-oauth-btn {
  width: 100%;
  min-height: 50px;
  border-radius: 14px;
  padding: 0 16px;
  white-space: nowrap;
  transition: transform 120ms ease, background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.auth-submit-btn {
  border: 1px solid #211b25;
  background: #211b25;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(33, 27, 37, 0.16);
  cursor: pointer;
}

.auth-submit-btn:hover {
  background: #352d39;
  border-color: #352d39;
}

.auth-submit-btn:active,
.auth-switch-btn:active,
.auth-oauth-btn:active {
  transform: scale(0.985);
}

.auth-submit-btn:disabled,
.auth-switch-btn:disabled,
.auth-oauth-btn:disabled {
  cursor: wait;
  opacity: 0.58;
}

.auth-switch-btn {
  border: 1px solid #ded9e0;
  background: #fff;
  color: #3d3440;
  font-weight: 750;
  cursor: pointer;
}

.auth-switch-btn:hover {
  border-color: #bdb4c0;
  background: #f9f7fa;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #948a96;
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: #e8e4e9;
}

.auth-oauth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #d7d1d9;
  background: #fff;
  color: #28212c;
  font-weight: 750;
  cursor: pointer;
}

.auth-oauth-btn:hover {
  border-color: #aaa0ad;
  background: #f9f7fa;
}

.auth-github-mark {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #24292f;
  color: #fff;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: -0.03em;
}

.auth-link-btn {
  min-height: 28px;
  padding: 3px 0;
  border: 0;
  background: none;
  color: #765f7b;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.auth-link-btn:hover {
  color: #d73961;
}

.auth-message {
  min-height: 0;
  margin: 0;
  color: #4a765f;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.auth-message:empty {
  display: none;
}

.auth-message.error {
  color: #b42318;
}

.auth-reset-copy {
  display: grid;
  gap: 7px;
}

.auth-reset-copy h3 {
  margin: 0;
  color: #201b24;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.auth-reset-info {
  margin: 0;
  color: #6e6471;
  font-size: 13px;
  line-height: 1.6;
}

.auth-footnote {
  margin: -5px 0 0;
  color: #8b818e;
  font-size: 11px;
  text-align: center;
}

.pairing-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  color-scheme: light;
  background: rgba(24, 19, 27, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.pairing-overlay.hidden {
  display: none;
}

.pairing-card {
  width: min(100%, 390px);
  display: grid;
  gap: 13px;
  justify-items: stretch;
  padding: clamp(24px, 6vw, 34px);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 28px;
  background: #fff;
  color: #201b24;
  box-shadow: 0 32px 90px rgba(17, 12, 20, 0.35);
}

.pairing-icon-wrap {
  position: relative;
  justify-self: center;
  width: 72px;
  height: 72px;
}

.pairing-icon-wrap img {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  box-shadow: 0 12px 28px rgba(240, 82, 115, 0.2);
}

.pairing-status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 20px;
  height: 20px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: #36a36e;
}

.pairing-card h2,
.pairing-eyebrow,
.pairing-device-name,
.pairing-description {
  margin: 0;
  text-align: center;
}

.pairing-card h2 {
  color: #201b24;
  font-size: 24px;
  letter-spacing: -0.035em;
}

.pairing-eyebrow {
  margin-top: 3px;
}

.pairing-device-name {
  padding: 11px 14px;
  border: 1px solid #e6e1e7;
  border-radius: 14px;
  background: #f8f6f9;
  color: #4a3f4e;
  font-size: 14px;
  font-weight: 750;
}

.pairing-description {
  color: #706674;
  font-size: 13px;
  line-height: 1.65;
}

.pairing-actions {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

@media (max-width: 520px) {
  .auth-overlay {
    align-items: stretch;
    padding: 0;
    background: #fff;
  }

  .auth-scene {
    display: none;
  }

  .auth-surface {
    width: 100%;
    min-height: 100dvh;
    align-content: center;
    padding: max(30px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .auth-surface,
  .pairing-overlay {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

.cloud-device-select {
  min-width: 120px;
  max-width: 180px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
}
