*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --bg-2: #f5f5f4;
  --bg-3: #e8e8e6;
  --text: #1a1a1a;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --border: rgba(0,0,0,0.12);
  --border-md: rgba(0,0,0,0.25);
  --radius: 8px;
  --radius-lg: 12px;
  --blue-bg: #eff6ff;
  --blue-text: #1d4ed8;
  --green-bg: #f0fdf4;
  --green-text: #15803d;
  --red-text: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --bg-2: #2c2c2e;
    --bg-3: #3a3a3c;
    --text: #f5f5f5;
    --text-2: #a1a1aa;
    --text-3: #71717a;
    --border: rgba(255,255,255,0.1);
    --border-md: rgba(255,255,255,0.2);
    --blue-bg: #1e3a5f;
    --blue-text: #93c5fd;
    --green-bg: #14532d;
    --green-text: #86efac;
  }
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg-2); color: var(--text); font-size: 15px; line-height: 1.6; }

.app { max-width: 720px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

.header { display: flex; align-items: center; gap: 12px; margin-bottom: 1.5rem; flex-wrap: wrap; }
.header-icon { width: 40px; height: 40px; border-radius: 10px; background: #1a1a1a; color: white; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; flex-shrink: 0; }
.header h1 { font-size: 17px; font-weight: 600; }
.header p { font-size: 12px; color: var(--text-2); }
.tab-nav { margin-left: auto; display: flex; gap: 4px; background: var(--bg-3); border-radius: var(--radius); padding: 3px; }
.tab-nav-btn { padding: 5px 14px; border-radius: 6px; border: none; background: none; font-size: 13px; cursor: pointer; color: var(--text-2); }
.tab-nav-btn.active { background: var(--bg); color: var(--text); font-weight: 500; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.steps { display: flex; gap: 6px; margin-bottom: 1.25rem; }
.step { flex: 1; padding: 8px; border-radius: var(--radius); border: 0.5px solid var(--border); background: var(--bg-2); font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.step.active { border-color: #1a1a1a; background: var(--bg); color: var(--text); font-weight: 500; }
.step.done { background: var(--green-bg); color: var(--green-text); border-color: transparent; }
.step-num { font-size: 11px; width: 18px; height: 18px; border-radius: 50%; border: 1px solid currentColor; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.section { background: var(--bg); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: 1rem; }
.section-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.icon { font-size: 16px; }
.hidden { display: none !important; }

.hint { font-size: 12px; color: var(--text-2); background: var(--bg-2); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 12px; line-height: 1.5; }

input, textarea, select {
  width: 100%; padding: 8px 12px; border: 0.5px solid var(--border-md); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit;
  outline: none; transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: #1a1a1a; box-shadow: 0 0 0 2px rgba(26,26,26,0.1); }
textarea { resize: vertical; min-height: 100px; line-height: 1.6; }

.input-row { margin-bottom: 10px; }
.input-row label { font-size: 12px; color: var(--text-2); display: block; margin-bottom: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn-primary {
  background: #1a1a1a; color: white; border: none; border-radius: var(--radius);
  padding: 10px 18px; font-size: 14px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: background 0.15s;
}
.btn-primary:hover { background: #333; }
.btn-primary:disabled { background: var(--bg-3); color: var(--text-3); cursor: not-allowed; }
.btn-primary.full { width: 100%; justify-content: center; }
.btn-primary.sm { padding: 8px 14px; font-size: 13px; }

.btn-secondary {
  background: transparent; color: var(--text); border: 0.5px solid var(--border-md);
  border-radius: var(--radius); padding: 8px 14px; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: background 0.15s;
}
.btn-secondary:hover { background: var(--bg-2); }
.btn-secondary.sm { padding: 6px 12px; font-size: 12px; }

.action-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.action-row .btn-primary { flex: 2; justify-content: center; }
.action-row .btn-secondary { flex: 1; justify-content: center; }

.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row input { flex: 1; }

.keyword-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  padding: 4px 12px; border-radius: 999px; border: 0.5px solid var(--border-md);
  font-size: 12px; cursor: pointer; color: var(--text-2); background: var(--bg);
  transition: all 0.15s;
}
.chip:hover { background: var(--bg-2); }
.chip.active { background: #1a1a1a; color: white; border-color: #1a1a1a; }

.trend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.trend-card { border: 0.5px solid var(--border); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; background: var(--bg); transition: border-color 0.15s; }
.trend-card:hover { border-color: var(--border-md); }
.trend-card.selected { border: 1.5px solid #1a1a1a; }
.trend-tag { font-size: 11px; color: var(--blue-text); background: var(--blue-bg); padding: 2px 8px; border-radius: 999px; display: inline-block; margin-bottom: 5px; }
.trend-text { font-size: 13px; font-weight: 500; line-height: 1.4; }
.trend-meta { font-size: 11px; color: var(--text-3); margin-top: 5px; display: flex; gap: 10px; }

.post-preview { background: var(--bg-2); border-radius: var(--radius); padding: 14px; font-size: 14px; line-height: 1.7; min-height: 80px; white-space: pre-wrap; margin-bottom: 6px; }
.post-preview.loading { color: var(--text-3); font-style: italic; }

.char-count { font-size: 12px; color: var(--text-3); text-align: right; margin-bottom: 10px; }
.char-count.over { color: var(--red-text); }

.variant-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.vtab { padding: 6px 14px; font-size: 13px; cursor: pointer; color: var(--text-2); border: 0.5px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.vtab.active { background: #1a1a1a; color: white; border-color: #1a1a1a; }

.status-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; font-size: 13px; font-weight: 500; }
.status-bar.success { background: var(--green-bg); color: var(--green-text); }
.status-bar.error { background: #fef2f2; color: var(--red-text); }

.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 0.5px solid var(--border); }
.setting-row:last-of-type { border-bottom: none; margin-bottom: 12px; }
.setting-label { font-size: 13px; }
.setting-desc { font-size: 12px; color: var(--text-3); }
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; inset: 0; background: var(--bg-3); border-radius: 999px; cursor: pointer; transition: background 0.2s; }
.toggle input:checked + .toggle-slider { background: #1a1a1a; }
.toggle-slider::before { content: ""; position: absolute; height: 14px; width: 14px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: transform 0.2s; }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* Queue */
.queue-item { border: 0.5px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; display: flex; gap: 10px; align-items: flex-start; }
.queue-item-body { flex: 1; min-width: 0; }
.queue-item-text { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.queue-item-meta { font-size: 12px; color: var(--text-3); }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-posted { background: var(--green-bg); color: var(--green-text); }
.badge-failed { background: #fef2f2; color: var(--red-text); }
.badge-processing { background: var(--blue-bg); color: var(--blue-text); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal { background: var(--bg); border-radius: var(--radius-lg); padding: 1.5rem; width: 100%; max-width: 480px; }
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 1rem; }

.loading-state { text-align: center; padding: 2rem; color: var(--text-3); font-size: 13px; }
