/* Stream Deck Mobile — веб-интерфейс для телефона */

:root {
  --bg: #1a1a1a;
  --key-bg: #2d2d2d;
  --key-bg-active: #3d3d3d;
  --key-border: #404040;
  --text: #e0e0e0;
  --text-dim: #888;
  --accent: #0d99ff;
  --gap: 10px;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* Шапка */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  min-height: 48px;
  flex-shrink: 0;
}

.btn-pages {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: var(--key-bg);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-pages::before { content: "☰"; }
.btn-pages:active { background: var(--key-bg-active); }

.title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.header-placeholder { width: 40px; }

/* Обёртка с прокруткой: поле 95% по ширине */
.keypad-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 0;
  width: 95%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Сетка кнопок — всегда квадратные ячейки, минимальный размер (в app.js), без наслаивания */
.keypad {
  display: grid;
  gap: var(--gap);
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.key {
  aspect-ratio: 1;
  width: 100%;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--key-border);
  border-radius: var(--radius);
  background: var(--key-bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  cursor: pointer;
  transition: background 0.1s, transform 0.05s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: pan-y;
}
.key:active {
  background: var(--key-bg-active);
  transform: scale(0.97);
}
.key.key-has-image {
  padding: 0;
  overflow: hidden;
  position: relative;
}
.key.key-has-image .key-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.key:not(.key-has-image) .key-image {
  display: none;
}
.key .key-icon {
  font-size: 1.75rem;
  line-height: 1;
  margin-bottom: 4px;
}
.key .key-label-bar {
  margin-top: auto;
  width: 100%;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.55);
  box-sizing: border-box;
  flex-shrink: 0;
  border-radius: 8px;
}
.key.key-has-image .key-label-bar {
  position: relative;
  z-index: 1;
  bottom: 2px;
  margin: 35px 6px 0px 6px;
  width: calc(100% - 12px);
}
.key .key-label {
  font-size: 0.7rem;
  text-align: center;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin: 0;
}
.key:not(.key-has-image) .key-label {
  margin-top: 2px;
}
.key-empty {
  opacity: 0.4;
  cursor: default;
}
.key-empty:active { transform: none; }

/* Drawer страниц */
.pages-drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}
.pages-drawer[aria-hidden="false"] {
  pointer-events: auto;
}
.pages-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.2s;
}
.pages-drawer[aria-hidden="false"] .pages-drawer-backdrop {
  opacity: 1;
}
.pages-drawer-content {
  background: var(--key-bg);
  border-radius: 16px 16px 0 0;
  padding: 24px 16px var(--safe-bottom);
  width: 100%;
  max-height: 60vh;
  overflow: auto;
  transform: translateY(100%);
  transition: transform 0.25s ease-out;
}
.pages-drawer[aria-hidden="false"] .pages-drawer-content {
  transform: translateY(0);
}
.pages-drawer-content h2 {
  margin: 0 0 16px;
  font-size: 1.1rem;
}
.pages-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.pages-list li {
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 4px;
  background: var(--bg);
  cursor: pointer;
}
.pages-list li:active { background: var(--key-bg-active); }

/* Статус подключения */
.connection {
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 20px;
  background: rgba(0,0,0,0.7);
  font-size: 0.85rem;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.connection.visible { opacity: 1; }
.connection.connected { background: #0a5f0a; }
.connection.error { background: #8b0000; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  padding: 2rem 1rem;
  margin: 0;
}

