/* AutoNomi • Samsung Galaxy Tab A11 (8.7", 1340×800, 5:3) Touch Control Deck */
:root {
  --bg-primary: #0b0f19;
  --bg-surface: #131b2e;
  --bg-surface-elevated: #1b2640;
  --bg-tile: #182238;
  --bg-tile-active: rgba(6, 182, 212, 0.22);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-bright: rgba(56, 189, 248, 0.55);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #38bdf8;
  --accent-emerald: #10b981;
  --accent-red: #f43f5e;
  --accent-amber: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

html,
body.tablet-body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

/* =========================================================
   Compact Top Bar (height: 46px)
   ========================================================= */
.tablet-topbar {
  height: 46px;
  width: 100%;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.topbar-left::-webkit-scrollbar {
  display: none;
}

.status-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

.brand-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-primary);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.status-chip.connected,
.status-chip.online {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.38);
}

.status-chip.waiting {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.35);
}

.status-chip.glasses-active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.24), rgba(16, 185, 129, 0.24));
  color: #67e8f9;
  border-color: rgba(56, 189, 248, 0.65);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.topbar-btn,
.topbar-link {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
}

.topbar-btn:active,
.topbar-link:active {
  transform: scale(0.95);
}

.manage-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.manage-btn.active {
  background: rgba(244, 63, 94, 0.25);
  color: #fecdd3;
  border-color: #f43f5e;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.35);
}

.fullscreen-btn {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.topbar-link {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* =========================================================
   Adaptive 5:3 Split-Pane Workspace (height: calc(100dvh - 46px))
   ========================================================= */
.tablet-workspace {
  height: calc(100dvh - 46px);
  width: 100%;
  padding: 10px;
  gap: 12px;
  display: flex;
  overflow: hidden;
}

/* =========================================================
   Control Dock Elements (Monitor + Giant Clear + Action Pads)
   ========================================================= */
.control-dock {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.dock-primary-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 1. Compact Live Glasses Monitor */
.glasses-monitor {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.monitor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.monitor-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
}

.audio-indicator {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-muted);
}

.audio-indicator.playing {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.monitor-screen {
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  min-height: 78px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.blank-badge {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 4px;
  color: rgba(255, 255, 255, 0.25);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 5px 14px;
}

.digits-value {
  font-size: 46px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  letter-spacing: 3px;
  line-height: 1;
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.65);
  display: inline-block;
  transition: transform 0.18s ease;
}

.text-value {
  font-size: 18px;
  font-weight: 800;
  color: #38bdf8;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.monitor-subtext {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Shared Touch Pad Base */
.touch-pad {
  border: none;
  outline: none;
  cursor: pointer;
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: inherit;
  text-align: left;
  color: var(--text-primary);
  touch-action: manipulation;
  transition: transform 0.1s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.15s ease, background 0.15s ease;
}

.touch-pad:active {
  transform: scale(0.96);
}

.pad-icon {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}

.pad-labels {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pad-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.15;
}

.pad-subtitle {
  font-size: 11px;
  opacity: 0.82;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 2. Giant CLEAR SCREEN Touch Pad (#btn-clear-screen) */
.pad-clear {
  min-height: 64px;
  background: linear-gradient(135deg, #e11d48 0%, #d97706 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 6px 18px rgba(225, 29, 72, 0.38);
}

.pad-clear .pad-title {
  font-size: 16px;
  letter-spacing: 0.4px;
}

/* 3. Touch Action Pads */
.dock-actions-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.pad-mirror {
  min-height: 66px;
  flex: 1;
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}

.dock-secondary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 1;
}

.pad-secondary {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  min-height: 72px;
}

.pad-secondary.playing-active {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.25);
}

/* =========================================================
   Right / Bottom Main Soundboard
   ========================================================= */
.soundboard-pane {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

/* 1. Touch Add-Response Bar */
.add-tile-bar {
  display: flex;
  gap: 8px;
  width: 100%;
  flex-shrink: 0;
}

.tile-input {
  flex: 1;
  min-width: 0;
  height: 48px;
  background: rgba(11, 15, 25, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0 14px;
  color: var(--text-primary);
  font-size: 18px; /* Prevents Android auto-zoom on input focus */
  font-family: inherit;
  outline: none;
}

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

.tile-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.btn-record-mic {
  height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  font-size: 15px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  touch-action: manipulation;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn-record-mic:active {
  transform: scale(0.96);
}

.btn-record-mic.recording {
  background: linear-gradient(135deg, #e11d48 0%, #f43f5e 100%);
  border-color: #fda4af;
  color: #ffffff;
  box-shadow: 0 0 18px rgba(244, 63, 94, 0.65);
  animation: micPulse 1.1s infinite ease-in-out;
}

.btn-record-mic.has-audio {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.55);
  color: #6ee7b7;
}

@keyframes micPulse {
  0%, 100% {
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.55);
  }
  50% {
    box-shadow: 0 0 24px rgba(244, 63, 94, 0.9);
  }
}

.btn-add-tile {
  height: 48px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  touch-action: manipulation;
  transition: transform 0.1s ease;
}

.btn-add-tile:active {
  transform: scale(0.96);
}

/* Voice Attachment Bar */
.voice-attachment-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.4);
  flex-shrink: 0;
}

.voice-attachment-bar.recording-active {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.55);
}

.voice-status-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.voice-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #38bdf8;
  flex-shrink: 0;
}

.voice-attachment-bar.recording-active .voice-status-dot {
  background: #f43f5e;
  box-shadow: 0 0 10px #f43f5e;
}

.voice-status-label {
  font-size: 13px;
  font-weight: 800;
  color: #e0f2fe;
  white-space: nowrap;
}

.voice-actions-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-voice-action {
  height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(15, 23, 42, 0.75);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}

.btn-voice-action:active {
  transform: scale(0.95);
}

.btn-voice-action.mode-both {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}

.btn-voice-action.mode-voice-only {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.55);
  color: #fde68a;
}

.btn-voice-discard {
  background: rgba(244, 63, 94, 0.2);
  border-color: rgba(244, 63, 94, 0.45);
  color: #fecdd3;
}

/* Manage Mode Banner */
.manage-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(244, 63, 94, 0.18);
  border: 1px solid rgba(244, 63, 94, 0.5);
  color: #fecdd3;
  font-size: 13px;
  flex-shrink: 0;
}

.btn-done-manage {
  background: #f43f5e;
  color: #ffffff;
  border: none;
  border-radius: 7px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

/* 2. Scrollable Touch Response Tile Grid */
.tiles-grid {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  grid-auto-rows: minmax(82px, auto);
  align-content: start;
  gap: 10px;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}

.tiles-grid::-webkit-scrollbar {
  width: 6px;
}

.tiles-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

/* Chunky Touch Response Tile */
.response-tile {
  min-height: 82px;
  border-radius: 16px;
  background: var(--bg-tile);
  border: 2px solid rgba(255, 255, 255, 0.1);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.response-tile.voice-tile {
  border-color: rgba(56, 189, 248, 0.38);
  background: linear-gradient(145deg, #182238 0%, rgba(14, 116, 144, 0.25) 100%);
}

.response-tile:active {
  transform: scale(0.96);
}

.tile-phrase {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.22;
  word-break: break-word;
  color: #ffffff;
}

.tile-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
}

.response-tile.voice-tile .tile-badge {
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

/* Active on Glasses Glow State */
.response-tile.active-on-glasses {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.28) 0%, rgba(16, 185, 129, 0.25) 100%);
  border-color: #38bdf8;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.35), inset 0 0 12px rgba(16, 185, 129, 0.2);
}

.response-tile.active-on-glasses .tile-badge {
  background: rgba(16, 185, 129, 0.28);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.5);
}

/* Manage / Delete Mode Tile State */
.response-tile.manage-delete-mode {
  background: rgba(244, 63, 94, 0.14);
  border-color: rgba(244, 63, 94, 0.65);
}

.response-tile.manage-delete-mode .tile-badge {
  background: rgba(244, 63, 94, 0.28);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.5);
}

.tiles-empty {
  grid-column: 1 / -1;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  border: 1px dashed var(--border-subtle);
  border-radius: 14px;
}

/* =========================================================
   Landscape Layout (@media (min-width: 680px) — Tab A11 893×533)
   ========================================================= */
@media (min-width: 680px) {
  .tablet-workspace {
    flex-direction: row;
  }

  .control-dock {
    width: 265px;
    height: 100%;
    overflow: hidden;
  }
}

/* =========================================================
   Portrait Layout (@media (max-width: 679px) — Tab A11 533×893)
   ========================================================= */
@media (max-width: 679px) {
  .brand-label {
    font-size: 13px;
  }

  .tablet-workspace {
    flex-direction: column;
    padding: 8px;
    gap: 8px;
  }

  .control-dock {
    width: 100%;
    gap: 8px;
  }

  /* Side-by-side Monitor + Giant CLEAR SCREEN pad (1fr 1fr) */
  .dock-primary-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: stretch;
  }

  .glasses-monitor {
    padding: 8px 10px;
  }

  .monitor-screen {
    min-height: 54px;
    padding: 6px;
  }

  .digits-value {
    font-size: 34px;
  }

  .pad-clear {
    min-height: 100%;
    justify-content: center;
  }

  /* 3-column row (1fr 1fr 1fr) for Mirror, Next, and Music */
  .dock-actions-group {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    flex: none;
  }

  .dock-secondary-row {
    display: contents;
  }

  .pad-mirror,
  .pad-secondary {
    min-height: 64px;
    padding: 10px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 4px;
  }

  .pad-icon {
    font-size: 22px;
  }

  .pad-title {
    font-size: 14px;
  }

  /* 2-column Touch Response Tile Grid in thumb zone */
  .tiles-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
