/* ==========================================================================
   CARPINTARIA STUDIO — DESIGN SYSTEM CLARO & VERDE EDITORIAL v3.2
   Inspirado na identidade oficial da Carpintaria Digital (site principal):
   Fundo Marfim (#F5F2ED), Areia (#EDEAE3), Verde Floresta Nobre (#2C4A3E),
   Texto Grafite Profundo (#1C1C1A) e Tipografia Cormorant Garamond / Inter.
   ========================================================================== */

:root {
  /* Paleta Oficial Carpintaria Digital (Light Mode Editorial & Verde) */
  --cor-fundo: #F5F2ED;
  --cor-fundo-alt: #EDEAE3;
  --color-surface: #FFFFFF;
  --color-surface-card: #FFFFFF;
  --color-surface-elevated: #F2EFE9;

  /* Verde Floresta Oficial da Carpintaria Digital */
  --color-green-primary: #2C4A3E;
  --color-green-hover: #1F352C;
  --color-green-bg: rgba(44, 74, 62, 0.08);
  --color-green-border: rgba(44, 74, 62, 0.22);
  --color-green-glow: rgba(44, 74, 62, 0.12);

  /* Acento Dourado / Âmbar Sutil */
  --color-gold: #2C4A3E;
  --color-gold-hover: #1F352C;
  --color-gold-border: rgba(44, 74, 62, 0.25);
  --color-gold-glow: rgba(44, 74, 62, 0.1);
  --color-gold-tag: #9E7422;

  --color-border: #DCD7CE;
  --color-border-focus: #2C4A3E;

  --color-text-main: #1C1C1A;
  --color-text-muted: #6B6B67;
  --color-text-dim: #8E8E89;

  /* Tipografia */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Bordas e Sombras */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-subtle: 0 2px 8px rgba(28, 28, 26, 0.06);
  --shadow-card: 0 4px 16px rgba(28, 28, 26, 0.08);
  --shadow-gold: 0 4px 14px rgba(44, 74, 62, 0.18);

  --transition-fast: 0.15s ease-out;
  --transition-smooth: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset básico */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--color-text-main);
  background: var(--cor-fundo);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Container Principal */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 1240px;
  margin: 0 auto;
  position: relative;
  background: var(--cor-fundo-alt);
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   1. HEADER
   ========================================================================== */
.app-header {
  background: var(--cor-fundo);
  border-bottom: 1px solid var(--color-border);
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  z-index: 10;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: #1C1C1A;
  border: 1px solid var(--color-green-border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  padding: 4px;
}

.brand-logo-svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.avatar-logo-svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  padding: 2px;
}

.modal-logo-svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.lock-logo-svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  padding: 4px;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-green-primary);
  line-height: 1.1;
  letter-spacing: 0.4px;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.control-btn:hover {
  background: var(--color-surface-elevated);
  border-color: var(--color-green-primary);
  color: var(--color-green-primary);
}

.btn-header-nav:hover {
  border-color: var(--color-green-primary);
  background: var(--color-green-bg);
  color: var(--color-green-primary);
}

.btn-header-lock {
  padding: 7px 10px;
  color: #6B6B67;
}

.btn-header-lock:hover {
  background: #FFEBEE;
  border-color: #EF9A9A;
  color: #B71C1C;
}

/* ==========================================================================
   2. BARRA DE TRABALHO (CONTROLS BAR)
   ========================================================================== */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid rgba(220, 215, 206, 0.7);
}

.dropdown-control {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  transition: var(--transition-fast);
}

.dropdown-control.control-agent {
  flex: 1.2 1 220px;
}

.dropdown-control.control-skills {
  flex: 2 1 260px;
}

.dropdown-control.control-temp {
  flex: 0.8 1 130px;
}

.dropdown-control:focus-within {
  border-color: var(--color-green-primary);
  box-shadow: 0 0 0 2px var(--color-green-bg);
}

.dropdown-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-green-primary);
  white-space: nowrap;
}

.styled-select {
  background: transparent;
  border: none;
  color: var(--color-text-main);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 4px 2px;
  outline: none;
  cursor: pointer;
  width: 100%;
}

.styled-select option {
  background: #FFFFFF;
  color: #1C1C1A;
}

.styled-select optgroup {
  background: #F2EFE9;
  color: var(--color-green-primary);
  font-weight: 700;
}

.btn-clear-memory {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
  margin-left: auto;
}

.btn-clear-memory:hover {
  background: #FFEBEE;
  border-color: #EF9A9A;
  color: #B71C1C;
}

/* ==========================================================================
   3. ÁREA DE CHAT (CHAT-MAIN)
   ========================================================================== */
.chat-main, .app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--cor-fundo-alt);
  min-height: 0;
}

.agent-banner {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.agent-banner-info {
  width: 100%;
}

.banner-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.agent-banner-title {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--color-green-primary);
}

.memory-badge {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--color-green-primary);
  background: var(--color-green-bg);
  border: 1px solid var(--color-green-border);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.agent-banner-desc {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 2px;
  line-height: 1.35;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message-card {
  display: flex;
  gap: 12px;
  animation: fadeIn 0.2s ease-out;
}

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

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: #1C1C1A;
  border: 1px solid var(--color-green-border);
  color: var(--color-green-primary);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message-card.user-msg .msg-avatar {
  background: var(--color-green-primary);
  border-color: var(--color-green-hover);
  color: #FFFFFF;
  font-size: 0.8rem;
}

.msg-content {
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-subtle);
  max-width: 92%;
}

.message-card.user-msg .msg-content {
  background: #EAF0EC;
  border-color: #C2D6CA;
}

.msg-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(220, 215, 206, 0.6);
  padding-bottom: 4px;
}

.msg-sender {
  font-weight: 600;
  color: var(--color-green-primary);
}

.message-card.user-msg .msg-sender {
  color: var(--color-green-hover);
}

.msg-body {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--color-text-main);
}

.msg-body p {
  margin-bottom: 8px;
}

.msg-body p:last-child {
  margin-bottom: 0;
}

.msg-body pre {
  background: #1C1C1A;
  border: 1px solid var(--color-border);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
  font-size: 0.82rem;
  margin: 10px 0;
  color: #86EFAC;
}

.msg-body code {
  font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
  background: #EAE6DE;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--color-green-primary);
  font-weight: 600;
}

.msg-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(220, 215, 206, 0.5);
}

.tool-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition-fast);
}

.tool-btn:hover {
  background: var(--color-surface-elevated);
  border-color: var(--color-green-primary);
  color: var(--color-green-primary);
}

.btn-whatsapp-copy {
  background: #E8F5E9;
  border-color: #A5D6A7;
  color: #1B5E20;
  font-weight: 600;
}

.btn-whatsapp-copy:hover {
  background: #C8E6C9;
  color: #0A3D12;
}

/* ==========================================================================
   4. BARRA DE INPUT E ANEXOS (INPUT-AREA)
   ========================================================================== */
.input-area {
  background: var(--cor-fundo);
  border-top: 1px solid var(--color-border);
  padding: 12px 20px 16px;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

.attachments-preview-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-green-bg);
  border: 1px solid var(--color-green-border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.76rem;
  color: var(--color-green-primary);
}

.attachment-chip-remove {
  background: transparent;
  border: none;
  color: #B71C1C;
  font-weight: 700;
  cursor: pointer;
  padding: 0 2px;
}

.input-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  box-shadow: var(--shadow-subtle);
  position: relative;
  transition: var(--transition-fast);
}

.input-form:focus-within {
  border-color: var(--color-green-primary);
  box-shadow: 0 0 0 3px var(--color-green-bg);
}

.attach-dropdown-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.btn-attach {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.btn-attach:hover {
  background: var(--color-green-bg);
  color: var(--color-green-primary);
}

.attach-menu {
  position: absolute;
  bottom: 48px;
  left: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(28, 28, 26, 0.15);
  display: none;
  flex-direction: column;
  min-width: 250px;
  z-index: 100;
  overflow: hidden;
  padding: 4px;
}

.attach-menu.active {
  display: flex;
  animation: fadeIn 0.15s ease-out;
}

.attach-menu-item {
  background: transparent;
  border: none;
  padding: 10px 14px;
  text-align: left;
  font-size: 0.82rem;
  font-family: var(--font-body);
  color: var(--color-text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  width: 100%;
}

.attach-menu-item:hover {
  background: var(--color-green-bg);
  color: var(--color-green-primary);
}

#messageInput {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--color-text-main);
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.45;
  resize: none;
  min-height: 24px;
  max-height: 140px;
  outline: none;
  padding: 6px 4px;
}

#messageInput::placeholder {
  color: var(--color-text-dim);
}

.btn-send {
  background: linear-gradient(135deg, var(--color-green-primary), var(--color-green-hover));
  border: none;
  color: #FFFFFF;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition-fast);
  box-shadow: 0 2px 6px rgba(44, 74, 62, 0.25);
}

.btn-send:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 10px rgba(44, 74, 62, 0.35);
}

/* ==========================================================================
   5. SIDE DRAWER (BIBLIOTECA DE SKILLS, DOCS & RAG)
   ========================================================================== */
.drawer, .knowledge-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 390px;
  max-width: 90vw;
  height: 100vh;
  height: 100dvh;
  background: var(--cor-fundo);
  border-left: 1px solid var(--color-border);
  box-shadow: -10px 0 32px rgba(28, 28, 26, 0.18);
  z-index: 1200;
  transition: right 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer.open, .knowledge-drawer.open {
  right: 0;
}

.drawer-header {
  padding: 16px 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.drawer-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--color-green-primary);
  font-weight: 700;
}

.btn-close-drawer {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}

.section-title {
  font-size: 0.8rem;
  color: var(--color-green-primary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.doc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doc-link {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  display: block;
}

.doc-link:hover {
  background: var(--color-green-bg);
  color: var(--color-green-primary);
}

.skills-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.skill-tag {
  background: var(--cor-fundo);
  border: 1px solid var(--color-border);
  color: var(--color-green-primary);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 28, 26, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1150;
  display: none;
}

.drawer-overlay.open {
  display: block;
}

/* ==========================================================================
   6. MODAIS (DEFINIÇÕES & SUPABASE AUTH)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 28, 26, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1300;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.auth-modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 440px;
  box-shadow: 0 12px 32px rgba(28, 28, 26, 0.2);
  overflow: hidden;
  animation: modalSlide 0.25s ease-out;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--cor-fundo);
  border-bottom: 1px solid var(--color-border);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-logo {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: #1C1C1A;
  border: 1px solid var(--color-green-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 3px;
}

.modal-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-green-primary);
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.3rem;
  cursor: pointer;
}

.modal-body {
  padding: 18px;
  background: var(--color-surface);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--color-green-primary);
}

.form-group input, .form-group select {
  background: var(--cor-fundo);
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  outline: none;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--color-green-primary);
  box-shadow: 0 0 0 2px var(--color-green-bg);
}

.input-password-wrapper {
  display: flex;
  align-items: center;
  background: var(--cor-fundo);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.input-password-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 10px;
  color: var(--color-text-main);
  outline: none;
}

.btn-toggle-vis {
  background: transparent;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.9rem;
}

.form-hint {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.btn-submit-auth {
  background: linear-gradient(135deg, var(--color-green-primary), var(--color-green-hover));
  border: none;
  color: #FFFFFF;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  margin-top: 6px;
  box-shadow: 0 2px 6px rgba(44, 74, 62, 0.2);
}

.btn-submit-auth:hover {
  filter: brightness(1.1);
}

.auth-tabs {
  display: flex;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.auth-tab.active {
  color: var(--color-green-primary);
  border-bottom-color: var(--color-green-primary);
}

.auth-hint {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 14px;
  text-align: center;
}

.form-status {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  text-align: center;
  display: none;
}

.form-status.success {
  background: #E8F5E9;
  border: 1px solid #A5D6A7;
  color: #1B5E20;
}

.form-status.error {
  background: #FFEBEE;
  border: 1px solid #EF9A9A;
  color: #B71C1C;
}

/* ==========================================================================
   7. ECRÃ DE BLOQUEIO (PIN LOCKSCREEN)
   ========================================================================== */
.lock-screen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(245, 242, 237, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.25s ease-out;
}

.lock-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 340px;
  padding: 26px 20px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(28, 28, 26, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lock-badge {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #1C1C1A;
  border: 1px solid var(--color-green-border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  margin-bottom: 12px;
  overflow: hidden;
  padding: 6px;
}

.lock-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--color-green-primary);
  font-weight: 700;
  margin-bottom: 2px;
}

.lock-sub {
  font-size: 0.74rem;
  color: var(--color-text-muted);
  margin-bottom: 18px;
}

.lock-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.pin-display-wrapper {
  width: 100%;
  max-width: 200px;
}

.pin-display-wrapper input {
  width: 100%;
  background: var(--cor-fundo);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px;
  font-size: 1.6rem;
  letter-spacing: 12px;
  text-align: center;
  color: var(--color-green-primary);
  outline: none;
}

.pin-display-wrapper input:focus {
  border-color: var(--color-green-primary);
  box-shadow: 0 0 0 2px var(--color-green-bg);
}

.lock-status {
  font-size: 0.78rem;
  color: #B71C1C;
  padding: 4px 8px;
  border-radius: 4px;
  background: #FFEBEE;
  border: 1px solid #EF9A9A;
  width: 100%;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 240px;
  margin-top: 6px;
}

.pin-key {
  aspect-ratio: 1.1;
  background: var(--cor-fundo);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-text-main);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.pin-key:hover, .pin-key:active {
  background: var(--color-green-bg);
  border-color: var(--color-green-primary);
  color: var(--color-green-primary);
  transform: scale(0.95);
}

.pin-key-action {
  font-size: 1rem;
  background: var(--cor-fundo-alt);
  color: var(--color-text-muted);
}

.pin-key-enter {
  background: linear-gradient(135deg, var(--color-green-primary), var(--color-green-hover));
  border-color: var(--color-green-primary);
  color: #FFFFFF;
}

.pin-key-enter:hover, .pin-key-enter:active {
  filter: brightness(1.15);
  color: #FFFFFF;
}

.lock-hint {
  font-size: 0.68rem;
  color: var(--color-text-dim);
  margin-top: 14px;
}

/* ==========================================================================
   8. RESPONSIVIDADE
   ========================================================================== */
@media (max-width: 768px) {
  .app-header {
    padding: 10px 14px;
  }
  .controls-bar {
    gap: 6px;
  }
  .dropdown-control {
    flex: 1 1 100%;
  }
  .btn-clear-memory {
    width: 100%;
    text-align: center;
    margin-left: 0;
  }
  .header-actions .control-btn .btn-label {
    display: none;
  }
  .input-area {
    padding: 10px 14px 14px;
  }
  .messages-container {
    padding: 12px 14px;
  }
  .msg-content {
    max-width: 100%;
  }
}
