/* ============================================================
   EmojiPad — Minimal Design (Claude-inspired warm palette)
   ============================================================ */

/* ─── Design Tokens ─────────────────────────────────────── */
:root {
  /* Warm off-white palette */
  --bg:          #f9f7f4;
  --surface:     #ffffff;
  --surface-2:   #f4f1ec;
  --surface-3:   #ede9e3;

  /* Borders */
  --border:      #e4e0da;
  --border-soft: #ede9e3;
  --border-focus:#cf7c4e;

  /* Text */
  --text:        #1d1b18;
  --text-2:      #6b6865;
  --text-3:      #a8a5a0;

  /* Brand — warm terracotta like Claude */
  --primary:       #cf7c4e;
  --primary-hover: #b86c3c;
  --primary-muted: #f5e8de;
  --primary-text:  #ffffff;

  /* Semantic */
  --danger:   #c0392b;
  --success:  #2e7d52;
  --warning:  #b45309;

  /* UI */
  --header-h: 52px;
  --toolbar-h: 40px;
  --qbar-h:   38px;
  --radius:   8px;
  --radius-sm:5px;
  --radius-lg:14px;
  --radius-xl:20px;

  /* Type */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Courier New', monospace;

  /* Motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur:  0.15s;
  --dur-md: 0.25s;

  /* Scrollbar */
  --sb-thumb: #d4cfc9;
  --sb-track: #f4f1ec;

  /* Mobile bottom bar */
  --mobile-bar-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --bg:          #1a1918;
  --surface:     #242220;
  --surface-2:   #2c2a27;
  --surface-3:   #343230;

  --border:      #3d3a36;
  --border-soft: #302e2b;
  --border-focus:#e8945a;

  --text:        #e8e5e0;
  --text-2:      #9a9690;
  --text-3:      #5c5955;

  --primary:       #e8945a;
  --primary-hover: #f0a366;
  --primary-muted: #3a2a1e;

  --danger:   #e05c4b;
  --success:  #4caf84;
  --warning:  #e09840;

  --sb-thumb: #3d3a36;
  --sb-track: #2c2a27;
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

/* ─── SEO helpers ──────────────────────────────────────── */
.seo-h1 {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.seo-tagline {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-soft);
  text-align: center;
  padding: 4px 12px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: .02em;
}
.seo-footer {
  border-top: 1px solid var(--border-soft);
  background: var(--bg-secondary);
  padding: 14px 20px;
  font-size: 12px;
  color: var(--text-muted);
}
.seo-footer-inner { max-width: 960px; margin: 0 auto; }
.seo-footer-inner p { margin: 0 0 8px; line-height: 1.7; }
.seo-footer-inner strong { color: var(--text-secondary); }
.seo-footer-inner nav {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  margin-bottom: 8px;
}
.seo-footer-inner nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
}
.seo-footer-inner nav a:hover { color: var(--primary); }
.seo-footer-copy { font-size: 11px; margin: 0 !important; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background var(--dur), color var(--dur);
  -webkit-font-smoothing: antialiased;
}

button {
  cursor: pointer; border: none; background: none;
  font-family: inherit; color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

input, select, textarea {
  font-family: inherit;
  color: inherit;
  outline: none;
}

a { text-decoration: none; color: var(--primary); }

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--sb-thumb);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ─── Utility ────────────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; clip: rect(0,0,0,0); overflow: hidden; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.855rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background var(--dur), color var(--dur), box-shadow var(--dur), transform 0.08s;
  border: 1px solid transparent;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}
.btn-danger:hover { background: #fef2f2; color: var(--danger); border-color: var(--danger); }
[data-theme="dark"] .btn-danger:hover { background: #2a1010; }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-xs { padding: 3px 8px; font-size: 0.75rem; }

/* ─── Header ──────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
  z-index: 200;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.logo-icon { font-size: 1.2rem; line-height: 1; }
.logo-text {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}

/* Platform selector */
.platform-selector {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--text-3);
}
.platform-selector select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color var(--dur);
  appearance: auto;
}
.platform-selector select:focus { border-color: var(--border-focus); }

/* Header icon buttons */
.icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-2);
  transition: background var(--dur), color var(--dur);
  border: 1px solid transparent;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn:active { transform: scale(0.92); }

/* ─── Main layout ────────────────────────────────────────── */
.app-main {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ─── Editor Panel ───────────────────────────────────────── */
.editor-panel {
  display: flex;
  flex-direction: column;
  width: 50%;
  min-width: 300px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}

/* ─── Toolbar ────────────────────────────────────────────── */
.editor-toolbar {
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  background: var(--surface);
  overflow-x: auto;
  overflow-y: hidden;
}
.editor-toolbar::-webkit-scrollbar { height: 0; }

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 5px;
  flex-shrink: 0;
}

.toolbar-spacer { flex: 1; min-width: 8px; }

.tool-btn {
  width: 32px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px;
  font-size: 0.875rem;
  color: var(--text-2);
  transition: background var(--dur), color var(--dur);
  flex-shrink: 0;
}
.tool-btn:hover { background: var(--surface-2); color: var(--primary); }
.tool-btn:active { background: var(--primary-muted); transform: scale(0.92); }

/* Char counter */
.char-counter {
  font-size: 0.73rem;
  color: var(--text-3);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding-right: 4px;
}
.limit-warning { color: var(--warning); font-weight: 600; }
.limit-over    { color: var(--danger);  font-weight: 600; }

/* ─── Quick Insert Bar ───────────────────────────────────── */
.quick-bar {
  height: var(--qbar-h);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 2px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  scrollbar-width: none;
}
.quick-bar::-webkit-scrollbar { display: none; }

.quick-bar-section {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.quick-bar-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  white-space: nowrap;
  padding: 0 4px 0 2px;
}

.quick-bar-sep {
  width: 1px; height: 18px;
  background: var(--border);
  margin: 0 6px;
  flex-shrink: 0;
}

.quick-btn {
  min-width: 30px; height: 28px;
  padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem;
  border-radius: 5px;
  color: var(--text);
  border: 1px solid transparent;
  transition: background var(--dur), border-color var(--dur), transform 0.08s;
  flex-shrink: 0;
  white-space: nowrap;
  line-height: 1;
}
.quick-btn:hover {
  background: var(--surface);
  border-color: var(--border);
}
.quick-btn:active, .quick-btn.quick-btn-active {
  background: var(--primary);
  color: var(--primary-text);
  border-color: transparent;
  transform: scale(0.88);
}
.quick-btn-wide {
  min-width: 40px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  letter-spacing: -0.5px;
  padding: 0 6px;
}

/* ─── Textarea ───────────────────────────────────────────── */
.textarea-wrapper {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  position: relative;
}

.main-editor {
  width: 100%; height: 100%;
  padding: 16px 18px;
  font-size: 15px;
  line-height: 1.85;
  background: var(--surface);
  color: var(--text);
  border: none;
  resize: none;
  caret-color: var(--primary);
  transition: background var(--dur), color var(--dur);
}
.main-editor::placeholder { color: var(--text-3); }
.main-editor:focus {
  outline: none;
}

/* Focus ring via wrapper */
.textarea-wrapper:focus-within::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--primary);
  border-radius: 0;
  pointer-events: none;
  opacity: 0.4;
}


/* ─── Resize Handle ──────────────────────────────────────── */
.resize-handle {
  width: 4px;
  background: var(--border-soft);
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  transition: background var(--dur-md);
}
.resize-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 2px; height: 32px;
  background: var(--border);
  border-radius: 2px;
  transition: background var(--dur-md);
}
.resize-handle:hover,
.resize-handle.dragging {
  background: var(--primary-muted);
}
.resize-handle:hover::after,
.resize-handle.dragging::after {
  background: var(--primary);
}

/* ─── Symbol Panel ───────────────────────────────────────── */
.symbol-panel {
  flex: 1;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}

/* ─── Tab Bar ────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.tab-btn {
  flex: 1;
  padding: 0 2px;
  height: 36px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--dur), border-color var(--dur);
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text-2); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Search ─────────────────────────────────────────────── */
.search-bar {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  background: var(--surface);
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 10px;
  transition: border-color var(--dur), background var(--dur);
}
.search-input-wrap:focus-within {
  border-color: var(--border-focus);
  background: var(--surface);
}

.search-icon { font-size: 0.75rem; opacity: 0.45; flex-shrink: 0; }

.search-input-wrap input {
  flex: 1;
  border: none;
  background: none;
  font-size: 0.82rem;
  color: var(--text);
  min-width: 0;
}
.search-input-wrap input::placeholder { color: var(--text-3); }

.search-clear {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-3);
  font-size: 0.6rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--dur);
  line-height: 1;
}
.search-clear:hover { background: var(--text-3); color: var(--surface); }

/* ─── Tab Contents ───────────────────────────────────────── */
.tab-contents {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.tab-content { padding-bottom: 4px; }

/* ─── Section Label ──────────────────────────────────────── */
.section-label {
  font-size: 0.67rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 5px 10px 2px;
}

/* ─── Category Chips ─────────────────────────────────────── */
.category-chips {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
  overflow-x: auto;
  flex-wrap: nowrap;
  flex-shrink: 0;
  scrollbar-width: none;
}
.category-chips::-webkit-scrollbar { display: none; }

.chip {
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
  transition: all var(--dur);
  line-height: 1.5;
  flex-shrink: 0;
}
.chip:hover {
  background: var(--primary-muted);
  color: var(--primary);
  border-color: var(--primary);
}
.chip.active {
  background: var(--primary);
  color: var(--primary-text);
  border-color: transparent;
}

/* ─── Emoji Grid ─────────────────────────────────────────── */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  padding: 2px 4px;
  gap: 1px;
}

.emoji-btn {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  border-radius: 5px;
  transition: background var(--dur), transform 0.1s;
  position: relative;
  min-height: 30px;
  touch-action: manipulation;
}
.emoji-btn:hover {
  background: var(--surface-2);
  transform: scale(1.18);
}
.emoji-btn:active {
  background: var(--primary-muted);
  transform: scale(0.88);
}

/* Trending badge */
.emoji-btn .trend-badge {
  position: absolute;
  top: 1px; right: 1px;
  font-size: 0.45rem;
  background: var(--danger);
  color: #fff;
  border-radius: 3px;
  padding: 1px 2px;
  line-height: 1.3;
  font-weight: 700;
}

/* Tooltip */
.emoji-btn[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  font-size: 0.68rem;
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.emoji-btn[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--text);
  pointer-events: none;
  z-index: 999;
}

/* ─── Symbol Groups ──────────────────────────────────────── */
.symbol-group { margin-bottom: 0; }

.symbol-group-title {
  font-size: 0.67rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 10px 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.symbol-group-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

.symbol-grid {
  display: flex;
  flex-wrap: wrap;
  padding: 2px 6px 3px;
  gap: 2px;
}

.symbol-btn {
  min-width: 30px; height: 30px;
  padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem;
  border-radius: 5px;
  color: var(--text);
  border: 1px solid transparent;
  background: var(--surface-2);
  font-family: var(--font-mono);
  transition: background var(--dur), color var(--dur), border-color var(--dur), transform 0.1s;
  touch-action: manipulation;
}
.symbol-btn:hover {
  background: var(--primary-muted);
  color: var(--primary);
  border-color: var(--primary);
  transform: scale(1.12);
}
.symbol-btn:active { transform: scale(0.88); }

/* ─── Patterns ───────────────────────────────────────────── */
.patterns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 10px;
}

.pattern-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--dur-md), background var(--dur-md), box-shadow var(--dur-md);
  position: relative;
  overflow: hidden;
}
.pattern-card:hover {
  border-color: var(--primary);
  background: var(--primary-muted);
  box-shadow: 0 2px 8px rgba(207,124,78,0.12);
}

.pattern-preview {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
  max-height: 72px;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, black 55%, transparent);
}

.pattern-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
  gap: 4px;
}

.pattern-category-tag {
  font-size: 0.66rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.pattern-insert-btn {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 600;
  opacity: 0;
  transition: opacity var(--dur);
  white-space: nowrap;
}
.pattern-card:hover .pattern-insert-btn { opacity: 1; }

.pattern-length-select {
  font-size: 0.66rem;
  padding: 2px 4px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
}

/* ─── Custom Pattern Builder ─────────────────────────────── */
.custom-pattern-builder {
  padding: 10px 12px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
  margin-top: 4px;
}

.builder-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.builder-input-sm {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  flex: 1;
  transition: border-color var(--dur);
}
.builder-input-sm:focus { border-color: var(--border-focus); }

.builder-input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  width: 100%;
  transition: border-color var(--dur);
}
.builder-input:focus { border-color: var(--border-focus); }

.builder-preview {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  min-height: 36px;
  word-break: break-all;
  line-height: 1.5;
  display: none;
}

.builder-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* ─── Suggest Tab ────────────────────────────────────────── */
.suggest-input-wrap {
  display: flex;
  gap: 6px;
  padding: 10px 10px 6px;
}

.suggest-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.855rem;
  transition: border-color var(--dur), background var(--dur);
}
.suggest-input:focus {
  border-color: var(--border-focus);
  background: var(--surface);
}

.suggest-results { padding: 0 10px 10px; }

.suggest-placeholder {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-2);
}
.suggest-placeholder-icon { font-size: 1.8rem; margin-bottom: 8px; }
.suggest-placeholder p { font-size: 0.83rem; line-height: 1.6; color: var(--text-3); }

.suggest-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  margin-top: 10px;
}

.suggest-chip {
  padding: 4px 11px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.76rem;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all var(--dur);
}
.suggest-chip:hover {
  background: var(--primary-muted);
  color: var(--primary);
  border-color: var(--primary);
}

.suggest-section { margin-bottom: 14px; }
.suggest-section h4 {
  font-size: 0.8rem;
  color: var(--text-2);
  margin-bottom: 7px;
  font-weight: 600;
}
.suggest-emoji-row { display: flex; flex-wrap: wrap; gap: 3px; }

/* ─── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--mobile-bar-h) + var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 9px 20px;
  border-radius: 24px;
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
  animation: toastIn var(--dur-md) var(--ease);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Desktop: toast above bottom */
@media (min-width: 641px) {
  .toast { bottom: 20px; }
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn var(--dur) ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18), 0 0 0 1px var(--border);
  animation: slideUp var(--dur-md) var(--ease);
  overflow: hidden;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-wide { max-width: 760px; }
.modal-sm   { max-width: 360px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 1rem; font-weight: 700; }

.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  font-size: 0.8rem;
  transition: all var(--dur);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}

/* ─── Drafts ─────────────────────────────────────────────── */
.draft-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--dur);
  background: var(--surface-2);
}
.draft-item:hover {
  border-color: var(--primary);
  background: var(--primary-muted);
}

.draft-label { font-size: 0.875rem; font-weight: 600; margin-bottom: 3px; }
.draft-preview {
  font-size: 0.78rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.draft-meta { font-size: 0.71rem; color: var(--text-3); margin-top: 3px; }
.draft-actions { display: flex; gap: 6px; margin-top: 8px; }

.empty-state {
  text-align: center;
  color: var(--text-3);
  padding: 36px 16px;
  font-size: 0.855rem;
  line-height: 1.6;
}

/* ─── Stats Modal ────────────────────────────────────────── */
.stats-modal-body { padding: 0; }

/* KPI summary row */
.stats-summary-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}
.stats-kpi {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 8px;
  gap: 3px;
}
.stats-kpi-accent { background: var(--primary-muted); }
.stats-kpi-divider { width: 1px; background: var(--border); flex-shrink: 0; }
.stats-kpi-num {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.5px;
}
.stats-kpi-accent .stats-kpi-num { color: var(--primary); }
.stats-kpi-label {
  font-size: 0.7rem;
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Content blocks */
.stats-block {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.stats-block:last-child { border-bottom: none; }

.stats-block-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.stats-block-title { font-size: 0.83rem; font-weight: 700; color: var(--text); }
.stats-block-sub   { font-size: 0.75rem; color: var(--text-3); }

/* Two-column layout */
.stats-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border-soft);
}
.stats-two-col .stats-block {
  border-bottom: none;
  border-right: 1px solid var(--border-soft);
}
.stats-two-col .stats-block:last-child { border-right: none; }

/* Activity chart */
.activity-chart-wrap { position: relative; }
.activity-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 60px;
}
.ac-col {
  flex: 1;
  display: flex;
  align-items: flex-end;
  height: 100%;
  cursor: default;
}
.ac-bar {
  width: 100%;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
  opacity: 0.55;
  transition: opacity var(--dur);
  min-height: 3px;
}
.ac-col:hover .ac-bar { opacity: 1; }

.activity-chart-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.65rem;
  color: var(--text-3);
}

/* Rank rows (top emoji + trending) */
.stats-rank-list { display: flex; flex-direction: column; gap: 6px; }

.rank-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}
.rank-pos {
  width: 16px;
  font-size: 0.7rem;
  color: var(--text-3);
  font-weight: 700;
  text-align: center;
  flex-shrink: 0;
}
.rank-char {
  font-size: 1.2rem;
  width: 26px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}
.rank-bar-wrap {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.rank-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  opacity: 0.7;
}
.rank-count {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-2);
  min-width: 30px;
  text-align: right;
  flex-shrink: 0;
}
.rank-label {
  flex: 1;
  font-size: 0.75rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-growth { font-size: 0.72rem; font-weight: 700; flex-shrink: 0; }
.rank-growth.up   { color: var(--success); }
.rank-growth.down { color: var(--danger); }

/* Platform bars */
.plat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.plat-row:last-child { margin-bottom: 0; }
.plat-name {
  font-size: 0.79rem;
  color: var(--text-2);
  width: 88px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plat-track {
  flex: 1;
  height: 7px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.plat-fill { height: 100%; border-radius: 4px; transition: width 0.5s var(--ease); }
.plat-pct {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  min-width: 34px;
  text-align: right;
  flex-shrink: 0;
}
.plat-count {
  font-size: 0.72rem;
  color: var(--text-3);
  min-width: 28px;
  text-align: right;
  flex-shrink: 0;
}

/* Empty/loading state inside stats */
.stats-empty {
  font-size: 0.8rem;
  color: var(--text-3);
  padding: 8px 0;
  line-height: 1.6;
}

/* ─── Loading ────────────────────────────────────────────── */
.loading-spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Recently Used block (bottom of emoji tab) ─────────── */
.recently-block { padding-bottom: 6px; }
.recently-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 6px 8px 0;
}

/* Search results */
.search-results-label {
  font-size: 0.73rem; color: var(--text-3); padding: 4px 12px;
}
.no-results {
  text-align: center; padding: 28px 16px;
  color: var(--text-3); font-size: 0.84rem; line-height: 1.6;
  grid-column: 1 / -1;
}

/* ─── Mobile Bottom Bar ──────────────────────────────────── */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  height: calc(var(--mobile-bar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 500;
  align-items: stretch;
}

.mobile-tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.65rem;
  color: var(--text-3);
  font-weight: 500;
  transition: color var(--dur);
  padding: 6px 4px 2px;
}
.mobile-tab-btn span:first-child { font-size: 1.2rem; line-height: 1; }
.mobile-tab-btn.active { color: var(--primary); }
.mobile-tab-btn:active { background: var(--surface-2); }

/* ─── Responsive: Tablet ─────────────────────────────────── */
@media (max-width: 960px) {
  .editor-panel { width: 46%; }
  .btn-label { display: none; }
  .stats-cards { grid-template-columns: repeat(2,1fr); }
  .stats-grid-2 { grid-template-columns: 1fr; }
}

/* ─── Responsive: Mobile ─────────────────────────────────── */
@media (max-width: 640px) {
  body { overflow: hidden; }

  .app-main {
    flex-direction: column;
    overflow: hidden;
    position: relative;
    /* Space for bottom bar */
    padding-bottom: var(--mobile-bar-h);
  }

  /* Editor takes all available height */
  .editor-panel {
    width: 100%;
    flex: 1;
    min-height: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  /* Textarea fills editor */
  .textarea-wrapper { flex: 1; min-height: 0; }

  /* Hide resize handle */
  .resize-handle { display: none; }

  /* Symbol panel: slides up from bottom */
  .symbol-panel {
    position: fixed;
    bottom: var(--mobile-bar-h);
    left: 0; right: 0;
    height: 58vh;
    z-index: 400;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    transition: transform 0.35s var(--ease);
    box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
  }
  .symbol-panel.open { transform: translateY(0); }

  /* Pull indicator */
  .symbol-panel::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 8px auto 4px;
    flex-shrink: 0;
  }

  /* Show mobile bottom bar */
  .mobile-bottom-bar { display: flex; }

  /* Emoji grid on mobile */
  .emoji-grid { grid-template-columns: repeat(9,1fr); }

  /* Platform selector: hide label */
  .platform-selector label { display: none; }

  /* Stats modal mobile */
  .stats-two-col { grid-template-columns: 1fr; }
  .stats-two-col .stats-block { border-right: none; border-bottom: 1px solid var(--border-soft); }
  .stats-kpi-num { font-size: 1.3rem; }
  .patterns-grid { grid-template-columns: 1fr; }

  /* Modals from bottom */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-height: 88dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
  }

  /* Toast above bottom bar */
  .toast { bottom: calc(var(--mobile-bar-h) + var(--safe-bottom) + 12px); }

  /* Quick bar: hide labels */
  .quick-bar-label { display: none; }
  .quick-btn { min-width: 28px; height: 26px; font-size: 0.95rem; }
  .quick-btn-wide { min-width: 36px; font-size: 0.65rem; }

  /* Header compact */
  .app-header { padding: 0 10px; }
  .logo-text { font-size: 0.95rem; }
}

/* ─── Misc ───────────────────────────────────────────────── */
.fade-in { animation: fadeIn var(--dur) ease; }

/* Pattern no-result full width */
#patterns-grid .no-results { grid-column: 1 / -1; }
