/* VC Ping — Design System & Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-primary: #0a0a0c;
  --bg-card: rgba(20, 20, 26, 0.85);
  --bg-card-hover: rgba(26, 26, 34, 0.95);
  --bg-input: #14141a;
  --bg-input-focus: #181822;
  --bg-chip: rgba(255, 255, 255, 0.05);
  --bg-chip-hover: rgba(37, 211, 102, 0.12);

  --accent: #25D366;
  --accent-hover: #1ebe5a;
  --accent-dark: #128C7E;
  --accent-glow: rgba(37, 211, 102, 0.25);
  --accent-subtle: rgba(37, 211, 102, 0.08);

  --text-primary: #f4f4f6;
  --text-secondary: #90909f;
  --text-muted: #5e5e70;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(37, 211, 102, 0.5);
  --border-card: rgba(255, 255, 255, 0.06);

  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.25);
  --warning: #f59e0b;
  --success: #25D366;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.6), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  --shadow-btn: 0 4px 20px -2px rgba(37, 211, 102, 0.4);
}

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

html, body {
  min-height: 100%;
  min-height: 100dvh;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Background atmospheric gradient */
body::before {
  content: '';
  position: fixed;
  top: -150px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(circle, rgba(37, 211, 102, 0.12) 0%, rgba(18, 140, 126, 0.04) 50%, transparent 70%);
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

/* App shell container with mobile safe-areas */
.app-container {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: max(40px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 1;
  min-height: 100dvh;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.2), rgba(18, 140, 126, 0.1));
  border: 1px solid rgba(37, 211, 102, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  box-shadow: 0 0 15px -2px var(--accent-glow);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
  stroke: var(--accent);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #ffffff 40%, #b0b0c0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-title .accent-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  display: inline-block;
}

.brand-tagline {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Install banner / quick button */
.install-btn {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--bg-chip);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}

.install-btn:hover {
  background: var(--accent-subtle);
  border-color: rgba(37, 211, 102, 0.4);
  color: var(--accent);
}

.install-btn svg {
  width: 14px;
  height: 14px;
}

/* Main card */
.main-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Input group */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.input-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.input-badge.active {
  background: rgba(37, 211, 102, 0.15);
  color: var(--accent);
  border: 1px solid rgba(37, 211, 102, 0.3);
}

/* Phone input container */
.phone-field-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.25s ease;
  overflow: hidden;
}

.phone-field-wrapper:focus-within {
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle), 0 0 16px -2px var(--accent-glow);
}

.phone-field-wrapper.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-glow);
}

.country-flag-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px 0 14px;
  height: 52px;
  border-right: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 600;
  user-select: none;
  white-space: nowrap;
}

.country-flag {
  font-size: 1.15rem;
  line-height: 1;
}

.country-code-prefix {
  color: var(--accent);
  font-weight: 700;
}

.phone-input {
  flex: 1;
  height: 52px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 600;
  padding: 0 12px;
  letter-spacing: 0.03em;
}

.phone-input::placeholder {
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 0.95rem;
  letter-spacing: normal;
}

.field-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
}

.field-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.field-btn:hover {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: rgba(37, 211, 102, 0.3);
}

.field-btn.icon-only {
  padding: 7px;
  border-radius: 50%;
}

.clear-btn {
  display: none;
}

.clear-btn.visible {
  display: flex;
}

/* Error message banner */
.field-error-text {
  font-size: 0.74rem;
  color: var(--danger);
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 4px;
  padding-left: 2px;
}

.field-error-text.visible {
  display: flex;
}

/* Message field */
.message-field-wrapper {
  position: relative;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
}

.message-field-wrapper:focus-within {
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.message-textarea {
  width: 100%;
  min-height: 80px;
  max-height: 180px;
  background: transparent;
  border: none;
  outline: none;
  resize: vertical;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.45;
  padding: 12px 14px 40px;
}

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

.message-footer-bar {
  position: absolute;
  bottom: 6px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.char-counter {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.save-template-btn {
  pointer-events: auto;
  display: none;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(37, 211, 102, 0.12);
  border: 1px solid rgba(37, 211, 102, 0.3);
  color: var(--accent);
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.save-template-btn:hover {
  background: var(--accent);
  color: #0a0a0c;
}

.save-template-btn.visible {
  display: inline-flex;
}

/* Quick chips */
.chips-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chips-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chips-scroller {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.chips-scroller::-webkit-scrollbar {
  display: none;
}

.quick-chip {
  flex-shrink: 0;
  background: var(--bg-chip);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.quick-chip:hover {
  background: var(--bg-chip-hover);
  border-color: rgba(37, 211, 102, 0.35);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.quick-chip:active {
  transform: translateY(0);
}

/* Custom Saved Templates Accordion */
.templates-accordion {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
  transition: all 0.25s ease;
}

.templates-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background 0.2s ease;
}

.templates-header:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

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

.templates-count-badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(37, 211, 102, 0.15);
  color: var(--accent);
  font-weight: 700;
}

.templates-chevron {
  width: 16px;
  height: 16px;
  transition: transform 0.25s ease;
}

.templates-accordion.open .templates-chevron {
  transform: rotate(180deg);
}

.templates-body {
  display: none;
  padding: 4px 10px 10px;
  border-top: 1px solid var(--border-subtle);
  flex-direction: column;
  gap: 6px;
}

.templates-accordion.open .templates-body {
  display: flex;
}

.template-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.template-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-subtle);
}

.template-item.active {
  background: rgba(37, 211, 102, 0.08);
  border-color: rgba(37, 211, 102, 0.35);
}

.template-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.template-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-snippet {
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.7;
}

.template-item:hover .template-actions {
  opacity: 1;
}

.template-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.template-action-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.template-action-btn.delete:hover {
  color: var(--danger);
}

.empty-templates-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 10px;
  font-style: italic;
}

/* Primary CTA Button */
.send-btn {
  position: relative;
  width: 100%;
  height: 52px;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  border: none;
  border-radius: var(--radius-md);
  color: #0a0a0c;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.send-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  transform: skewX(-25deg);
  transition: 0.6s ease;
}

.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px -2px rgba(37, 211, 102, 0.55);
}

.send-btn:hover::after {
  left: 150%;
}

.send-btn:active {
  transform: translateY(0);
}

.send-btn svg {
  width: 22px;
  height: 22px;
}

/* History section */
.history-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.history-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-title svg {
  width: 15px;
  height: 15px;
}

.history-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease;
  display: none;
}

.history-clear-btn:hover {
  color: var(--danger);
}

.history-clear-btn.visible {
  display: block;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  cursor: pointer;
}

.history-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(37, 211, 102, 0.3);
  transform: translateX(2px);
}

.history-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.history-flag {
  font-size: 1.25rem;
}

.history-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.history-number {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.history-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-preview {
  color: var(--text-secondary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.history-delete-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.history-empty {
  text-align: center;
  padding: 24px 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.015);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
}

/* Toast container */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  width: 90%;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(24, 24, 30, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.accent-toast {
  border-color: rgba(37, 211, 102, 0.4);
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-primary);
  min-width: 0;
}

.toast-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toast-btn {
  background: var(--accent);
  color: #0a0a0c;
  border: none;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

.toast-btn.dismiss {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

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

/* Modal for saving template */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

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

.modal-box {
  background: #14141a;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
}

.modal-input {
  width: 100%;
  height: 44px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
}

.modal-input:focus {
  border-color: var(--border-focus);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.modal-btn.cancel {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.modal-btn.confirm {
  background: var(--accent);
  color: #0a0a0c;
  font-weight: 700;
}

/* Footer note */
.app-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.app-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
}

.app-footer a:hover {
  color: var(--accent);
}

/* Desktop shortcut hint */
.desktop-shortcut-hint {
  display: none;
  text-align: center;
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: -6px;
  user-select: none;
}

.desktop-shortcut-hint kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* ==========================================================
   RESPONSIVE BREAKPOINTS FOR ALL DEVICES
   ========================================================== */

/* 1. MOBILE SMARTPHONES (<= 440px: all standard mobile phones) */
@media (max-width: 440px) {
  .app-container {
    padding-left: 12px;
    padding-right: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    gap: 13px;
  }

  .main-card {
    padding: 14px 10px;
    gap: 12px;
    border-radius: var(--radius-md);
  }

  .app-header {
    padding: 2px 2px 8px;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
  }

  .brand-icon svg {
    width: 18px;
    height: 18px;
  }

  .brand-title {
    font-size: 1.02rem;
  }

  .brand-tagline {
    font-size: 0.68rem;
  }

  .install-btn {
    padding: 4px 8px;
    font-size: 0.7rem;
  }

  .install-btn span {
    font-size: 0.68rem;
  }

  /* Compact Phone Input to maximize digit space */
  .phone-field-wrapper {
    height: 48px;
  }

  .country-flag-box {
    padding: 0 8px;
    font-size: 0.85rem;
    height: 48px;
  }

  .country-flag {
    font-size: 1rem;
  }

  .phone-input {
    height: 48px;
    font-size: 0.98rem;
    padding: 0 8px;
  }

  /* Hide "Paste" word on extra-narrow screens, keep clipboard icon */
  .field-btn span {
    display: none;
  }

  .field-btn {
    padding: 6px 7px;
  }

  .message-textarea {
    min-height: 72px;
    font-size: 0.88rem;
    padding: 10px 10px 36px;
  }

  .quick-chip {
    padding: 5px 9px;
    font-size: 0.74rem;
  }

  .send-btn {
    height: 48px;
    font-size: 0.94rem;
  }

  .send-btn svg {
    width: 20px;
    height: 20px;
  }

  .history-card {
    padding: 8px 10px;
  }

  .history-number {
    font-size: 0.88rem;
  }

  .history-preview {
    max-width: 90px;
  }

  .templates-header {
    padding: 8px 10px;
    font-size: 0.78rem;
  }
}

/* Extra Compact for Foldable outer screens / sub-340px */
@media (max-width: 340px) {
  .app-container {
    padding-left: 6px;
    padding-right: 6px;
  }

  .main-card {
    padding: 12px 8px;
  }

  .country-flag-box {
    padding: 0 6px;
    font-size: 0.8rem;
  }

  .phone-input {
    font-size: 0.92rem;
    padding: 0 6px;
  }
}

/* 2. TABLETS & DESKTOPS (>= 768px) */
@media (min-width: 768px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .app-container {
    max-width: 500px;
    padding-top: 32px;
    padding-bottom: 32px;
  }

  .main-card {
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7), 0 0 1px 1px rgba(255, 255, 255, 0.08);
  }

  .desktop-shortcut-hint {
    display: block;
  }

  .phone-input {
    font-size: 1.2rem;
  }

  .send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px -2px rgba(37, 211, 102, 0.6);
  }
}

/* 3. LARGE MONITORS (>= 1200px) */
@media (min-width: 1200px) {
  .app-container {
    max-width: 520px;
  }

  body::before {
    width: 800px;
    height: 500px;
  }
}

/* 4. SHORT VIEWPORTS & MOBILE KEYBOARD ACTIVE (<= 680px height) */
@media (max-height: 680px) {
  .app-container {
    gap: 10px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .main-card {
    padding: 14px;
    gap: 10px;
  }

  .phone-field-wrapper,
  .country-flag-box,
  .phone-input {
    height: 46px;
  }

  .message-textarea {
    min-height: 60px;
    padding-top: 8px;
    padding-bottom: 32px;
  }

  .send-btn {
    height: 46px;
  }

  .history-empty {
    padding: 14px 10px;
  }
}
