:root {
  --bg-main: #0a0a0c;
  --bg-surface: #121216;
  --bg-elevated: #1a1a20;
  --border-subtle: #26262f;
  --border-focus: #10b981;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #52525b;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-glow: rgba(16, 185, 129, 0.18);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

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

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 1200px;
  margin: 0 auto;
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  background-color: var(--bg-main);
}

/* Header / Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  gap: 0.75rem;
  flex-shrink: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  user-select: none;
}

.brand-zero {
  color: var(--accent);
  text-shadow: 0 0 14px var(--accent-glow);
}

.brand-log {
  color: var(--text-primary);
}

.status-badge {
  margin-left: 0.65rem;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background-color: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.status-badge.saved {
  background-color: rgba(16, 185, 129, 0.12);
  color: var(--accent);
  border-color: rgba(16, 185, 129, 0.35);
}

.meta-stats {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.dot {
  opacity: 0.5;
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-primary);
  background: var(--bg-elevated);
  white-space: nowrap;
}

.btn:hover {
  background: #23232b;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: #383846;
  background: var(--bg-elevated);
}

.btn-primary {
  background: var(--accent);
  color: #04130d;
  font-weight: 600;
  box-shadow: 0 2px 12px var(--accent-glow);
}

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

.btn-accent-subtle {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent);
  border-color: rgba(16, 185, 129, 0.35);
  font-weight: 600;
}

.btn-accent-subtle:hover {
  background: var(--accent);
  color: #04130d;
}

.btn-small {
  padding: 0.38rem 0.72rem;
  font-size: 0.78rem;
}

.hidden {
  display: none !important;
}

/* Link Bar */
.link-bar {
  background-color: rgba(16, 185, 129, 0.07);
  border-bottom: 1px solid rgba(16, 185, 129, 0.25);
  padding: 0.55rem 1.25rem;
  flex-shrink: 0;
  animation: slideDown 0.18s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.link-bar-inner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.link-bar-buttons {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.link-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.share-url-input {
  flex: 1;
  min-width: 0;
  background-color: var(--bg-main);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.42rem 0.65rem;
  border-radius: 6px;
  outline: none;
}

.share-url-input:focus {
  border-color: var(--accent);
}

/* Main Editor */
.editor-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  overflow: hidden;
  background-color: var(--bg-main);
}

.line-numbers {
  padding: 1.25rem 0.75rem 1.25rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-muted);
  text-align: right;
  user-select: none;
  background-color: var(--bg-main);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  min-width: 3.2rem;
  overflow: hidden;
  white-space: pre;
}

.editor {
  flex: 1;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 1.25rem 1.5rem;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.65;
  overflow-y: auto;
  tab-size: 2;
  -webkit-overflow-scrolling: touch;
}

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

.editor.readonly-mode {
  cursor: default;
  background-color: rgba(255, 255, 255, 0.01);
}

/* Custom scrollbar */
.editor::-webkit-scrollbar {
  width: 8px;
}
.editor::-webkit-scrollbar-track {
  background: var(--bg-main);
}
.editor::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}
.editor::-webkit-scrollbar-thumb:hover {
  background: #3b3b48;
}

/* Mobile Action Dock (oculto no desktop) */
.mobile-action-dock {
  display: none;
}

/* Footer / Bottombar */
.bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1.25rem;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-secondary);
  gap: 1rem;
  flex-shrink: 0;
}

.history-section {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.history-section::-webkit-scrollbar {
  display: none;
}

.history-title {
  color: var(--text-muted);
  font-weight: 500;
}

.history-list {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.history-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.6rem;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  transition: all 0.15s ease;
}

.history-chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.history-empty {
  color: var(--text-muted);
  font-style: italic;
}

.shortcut-hint {
  color: var(--text-muted);
  white-space: nowrap;
}

kbd {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 3.5rem;
  right: 1.5rem;
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  padding: 0.7rem 1.05rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 100;
  animation: fadeInUp 0.2s ease-out;
}

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

/* --- OTIMIZAÇÃO COMPLETA PARA CELULAR (MOBILE UX) --- */
@media (max-width: 680px) {
  .app-container {
    border-left: none;
    border-right: none;
  }

  .topbar {
    padding: 0.6rem 0.85rem;
  }

  .brand {
    font-size: 1.2rem;
  }

  .status-badge {
    margin-left: 0.45rem;
    font-size: 0.65rem;
    padding: 0.12rem 0.38rem;
  }

  .meta-stats,
  .shortcut-hint,
  #copyTextBtn,
  #saveBtn {
    display: none;
  }

  #newBtn {
    padding: 0.42rem 0.75rem;
    font-size: 0.8rem;
  }

  .link-bar {
    padding: 0.55rem 0.85rem;
  }

  .link-bar-inner {
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .link-label-text {
    display: none;
  }

  .share-url-input {
    font-size: 0.82rem;
    padding: 0.48rem 0.6rem;
  }

  .line-numbers {
    display: none;
  }

  /* Fonte 16px no mobile impede zoom forçado do iOS Safari ao focar na caixa de texto */
  .editor {
    padding: 0.95rem 1rem;
    font-size: 16px;
    line-height: 1.55;
  }

  /* Dock inferior ergonômico para o polegar no celular */
  .mobile-action-dock {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
  }

  .mobile-dock-btn {
    padding: 0.65rem 0.85rem;
    font-size: 0.84rem;
    border-radius: 8px;
  }

  .mobile-dock-save {
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
  }

  .bottombar {
    padding: 0.48rem 0.85rem calc(0.48rem + env(safe-area-inset-bottom, 0px));
  }

  .toast {
    left: 0.85rem;
    right: 0.85rem;
    bottom: 6.8rem;
    text-align: center;
  }
}
