/* Светлая минималистичная тема Antigravity Remote (Apple-like Glassmorphism + акцент #E4002B) */

:root {
  --bg: #f5f6f8;
  --bg-subtle: #eef0f4;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --surface-hover: rgba(255, 255, 255, 0.96);
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #8b95a5;
  --accent: #e4002b;
  --accent-hover: #c90025;
  --accent-soft: rgba(228, 0, 43, 0.09);
  --accent-glow: 0 8px 24px rgba(228, 0, 43, 0.22);
  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, 0.12);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.07);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --sidebar-w: 300px;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(228, 0, 43, 0.045), transparent 36%),
    radial-gradient(circle at 88% 92%, rgba(15, 23, 42, 0.04), transparent 38%),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand-title {
  font-family: 'Outfit', 'Inter', sans-serif;
  letter-spacing: -0.02em;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

/* ===== Кнопки и инпуты ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: transform 140ms var(--ease), background 160ms var(--ease), box-shadow 180ms var(--ease), border-color 160ms var(--ease);
}

.btn:hover {
  background: #ffffff;
  border-color: var(--border-strong);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(228, 0, 43, 0.18);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(15, 23, 42, 0.05);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.2);
}

.btn-danger:hover {
  background: var(--danger);
  color: #ffffff;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
}

.input, .textarea, .select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 15px;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: #ffffff;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Статусные бейджи ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.badge-ok {
  background: var(--ok-soft);
  color: #047857;
}

.badge-warn {
  background: var(--warn-soft);
  color: #b45309;
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* ===== Экран входа (login.html) ===== */
.auth-page {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px 24px;
}

.auth-header {
  text-align: center;
  margin-bottom: 22px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 20px;
  box-shadow: var(--accent-glow);
}

.auth-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.auth-header p {
  font-size: 14px;
  color: var(--text-secondary);
}

.totp-input {
  text-align: center;
  letter-spacing: 0.35em;
  font-family: 'Outfit', monospace;
  font-size: 22px;
  font-weight: 600;
}

.secret-box {
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  text-align: center;
  word-break: break-all;
  margin: 10px 0;
  user-select: all;
}

.approval-code {
  font-family: 'Outfit', monospace;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
  text-align: center;
  padding: 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  margin: 14px 0;
}

.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.18);
}

.alert-info {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ===== Главный интерфейс пульта (index.html) ===== */
.app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(4px);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--ease);
}

.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.sidebar-head {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
}

.sidebar-search {
  padding: 12px 14px 8px;
}

.sidebar-search .input {
  padding: 9px 12px;
  font-size: 14px;
}

.sidebar-section-title {
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 14px;
}

.list-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  margin-bottom: 3px;
  transition: background 140ms var(--ease), border-color 140ms var(--ease);
}

.list-item:hover {
  background: rgba(15, 23, 42, 0.04);
}

.list-item.active {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.list-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.list-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

/* ===== Основная область ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: transparent;
}

.topbar {
  height: 60px;
  flex-shrink: 0;
  padding: 0 16px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.menu-btn {
  display: none;
}

.current-project-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: 12px;
  overflow-x: auto;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}

.tab-btn.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ===== Панели вкладок ===== */
.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}

.conv-bar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}

.conv-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 500;
}

/* ===== Сообщения чата ===== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-state {
  margin: auto;
  text-align: center;
  max-width: 360px;
  color: var(--text-secondary);
  padding: 24px;
}

.empty-state h3 {
  color: var(--text);
  font-size: 18px;
  margin-bottom: 6px;
}

.msg {
  max-width: 820px;
  width: fit-content;
  min-width: 120px;
  padding: 12px 15px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-user {
  align-self: flex-end;
  background: var(--text);
  color: #ffffff;
  border-bottom-right-radius: 5px;
}

.msg-assistant {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-bottom-left-radius: 5px;
  width: min(100%, 820px);
}

.msg-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-user .msg-meta {
  color: rgba(255, 255, 255, 0.65);
  justify-content: flex-end;
}

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.att-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  text-decoration: none;
  color: inherit;
}

/* ===== Поле ввода задания ===== */
.composer {
  flex-shrink: 0;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
}

.composer-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer-textarea {
  flex: 1;
  min-height: 44px;
  max-height: 150px;
  resize: none;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  font-size: 15px;
  line-height: 1.4;
}

.composer-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-select {
  width: auto;
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: 8px;
}

/* ===== Карточки (Файлы, Localhost, Безопасность) ===== */
.card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 14px;
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.code-viewer {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  max-height: 60vh;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: 8px;
}

.file-row:hover {
  background: rgba(15, 23, 42, 0.04);
}

.file-row:last-child {
  border-bottom: none;
}

.tunnel-frame {
  width: 100%;
  height: 65vh;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.device-row:last-child {
  border-bottom: none;
}

/* ===== Адаптивность под телефон ===== */
@media (max-width: 860px) {
  .menu-btn {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 200ms var(--ease);
    width: min(86vw, 310px);
    box-shadow: var(--shadow-md);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topbar {
    padding: 0 10px;
  }

  .current-project-title {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
