/* ==========================================================================
   Threads Autopilot Web Command Center - Premium Dark Design System
   ========================================================================== */

:root {
  --bg-primary: #0a0d14;
  --bg-secondary: #101522;
  --bg-card: rgba(18, 24, 38, 0.7);
  --bg-card-hover: rgba(26, 34, 52, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.4);

  --accent-threads: #ffffff;
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;

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

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  --shadow-glow: 0 0 25px -5px rgba(99, 102, 241, 0.35);
}

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

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.08) 0%, transparent 45%);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.app-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==========================================================================
   Header Styles
   ========================================================================== */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.logo-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.6));
}

.app-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 40%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-subtitle {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.campaign-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 8px 16px;
  border-radius: var(--radius-full);
}

.pill-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-emerald);
}

.pill-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.pill-link {
  font-size: 0.8rem;
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s;
}

.pill-link:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.idle {
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

.status-dot.running {
  background: var(--accent-amber);
  box-shadow: 0 0 12px var(--accent-amber);
  animation: pulse 1.2s infinite;
}

.status-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

/* ==========================================================================
   Workspace Layout Grid
   ========================================================================== */

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  align-items: start;
}

@media (max-width: 1120px) {
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr) 350px;
    gap: 14px;
  }
}

@media (max-width: 880px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-icon {
  font-size: 1.2rem;
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.badge-count, .live-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
  white-space: nowrap;
}

.live-pill {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.3);
}

/* ==========================================================================
   Part Tabs Selector - Responsive Grid
   ========================================================================== */

.parts-tabs-container {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

@media (max-width: 1280px) {
  .parts-tabs-container {
    grid-template-columns: repeat(6, minmax(90px, 1fr));
    overflow-x: auto;
    padding-bottom: 6px;
  }
}

.parts-tabs-container::-webkit-scrollbar {
  height: 3px;
}

.parts-tabs-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}

.part-tab-btn {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  overflow: hidden;
}

.part-tab-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.part-tab-btn.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(6, 182, 212, 0.15));
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 4px 14px -4px rgba(99, 102, 241, 0.5);
}

.tab-badge {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.part-tab-btn.active .tab-badge {
  color: #a5f3fc;
}

.tab-label {
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.part-tab-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.part-tab-btn.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(6, 182, 212, 0.1));
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 4px 16px -4px rgba(99, 102, 241, 0.4);
}

.tab-badge {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.part-tab-btn.active .tab-badge {
  color: #fff;
}

.tab-label {
  font-size: 0.85rem;
  font-weight: 600;
}

/* ==========================================================================
   Editor Form
   ========================================================================== */

.editor-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.label-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.label-badge {
  font-size: 0.7rem;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.label-pill-pro {
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(90deg, #6366f1, #06b6d4);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.form-input, .form-textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  background: rgba(0, 0, 0, 0.5);
}

.form-textarea {
  resize: vertical;
  line-height: 1.6;
}

.highlight-group {
  background: rgba(99, 102, 241, 0.05);
  border: 1px dashed rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-md);
  padding: 14px;
}

.help-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 8px;
}

.help-icon {
  font-size: 0.9rem;
}

.reply-textarea {
  background: rgba(0, 0, 0, 0.5);
  font-size: 0.85rem;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.toggle-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-card:hover {
  background: rgba(255, 255, 255, 0.05);
}

.toggle-card input[type="checkbox"] {
  display: none;
}

.toggle-indicator {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.toggle-card input[type="checkbox"]:checked + .toggle-indicator {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.toggle-card input[type="checkbox"]:checked + .toggle-indicator::after {
  content: '✓';
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
}

.toggle-info {
  display: flex;
  flex-direction: column;
}

.toggle-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.toggle-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.action-buttons-wrap {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn-launch-primary {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 20px;
  background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow-glow);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-launch-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 35px rgba(99, 102, 241, 0.6);
}

.btn-launch-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-launch-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

.btn-icon {
  font-size: 1.2rem;
}

.btn-secondary {
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* ==========================================================================
   Threads Live Mockup Frame
   ========================================================================== */

.preview-panel {
  display: flex;
  flex-direction: column;
}

.preview-phone-frame {
  background: #000000;
  border: 6px solid #1e2638;
  border-radius: 30px;
  padding: 16px 14px;
  box-shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.8), inset 0 0 1px 1px rgba(255, 255, 255, 0.1);
  width: 100%;
  max-width: 350px;
  margin: 0 auto;
  position: relative;
  max-height: 560px;
  overflow-y: auto;
}

.preview-phone-frame::-webkit-scrollbar {
  width: 4px;
}

.preview-phone-frame::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
}

.phone-notch {
  width: 80px;
  height: 4px;
  background: #2a354c;
  border-radius: var(--radius-full);
  margin: 0 auto 14px auto;
}

.threads-feed-container {
  display: flex;
  flex-direction: column;
}

.thread-card {
  display: flex;
  flex-direction: column;
  position: relative;
}

.thread-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.avatar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.avatar-ring {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  z-index: 2;
}

.avatar-ring.mini {
  width: 32px;
  height: 32px;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thread-connector-line {
  width: 2px;
  background: rgba(255, 255, 255, 0.15);
  flex: 1;
  min-height: 40px;
  margin: 6px 0;
}

.author-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.author-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.author-handle {
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
}

.verified-badge {
  color: #38bdf8;
  font-size: 0.75rem;
  font-weight: 800;
}

.post-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.topic-tag-chip {
  align-self: flex-start;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 2px;
}

.header-menu-dots {
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
}

.thread-body-col {
  padding-left: 52px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: -14px;
}

.thread-text {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
}

.thread-media-box {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0d1117;
  max-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-media-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.preview-media-img:hover {
  transform: scale(1.02);
}

.thread-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 0;
}

.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.action-btn:hover {
  transform: scale(1.15);
}

.svg-icon {
  width: 18px;
  height: 18px;
  fill: #94a3b8;
  transition: fill 0.2s ease;
}

.action-btn:hover .svg-icon {
  fill: #ffffff;
}

/* Reply Mockup Card */
.reply-card {
  margin-top: 8px;
  padding-top: 8px;
}

.reply-body {
  padding-left: 44px;
  margin-top: -6px;
}

.reply-bubble {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.reply-text {
  font-size: 0.82rem;
  color: #cbd5e1;
}

.reply-inline-link {
  color: var(--accent-cyan);
  text-decoration: underline;
  word-break: break-all;
}

/* ==========================================================================
   Live Console Panel
   ========================================================================== */

.console-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.console-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.red { background: #ef4444; }
.dot.yellow { background: #f59e0b; }
.dot.green { background: #10b981; }

.console-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.console-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-console-clear {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-console-clear:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.sse-status {
  font-size: 0.75rem;
  color: var(--accent-emerald);
  font-weight: 600;
}

.terminal-body {
  background: #06090e;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  min-height: 100px;
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  line-height: 1.4;
}

.terminal-body::-webkit-scrollbar {
  width: 6px;
}

.terminal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}

.log-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: fadeIn 0.15s ease-in;
}

.log-time {
  color: #475569;
  flex-shrink: 0;
}

.log-tag {
  font-weight: 700;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.log-msg {
  color: #e2e8f0;
  word-break: break-word;
}

.log-line.section .log-tag { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.log-line.ok .log-tag { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.log-line.warn .log-tag { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.log-line.err .log-tag { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.log-line.info .log-tag { background: rgba(6, 182, 212, 0.2); color: #22d3ee; }
.log-line.step .log-tag { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.log-line.action .log-tag { background: rgba(217, 70, 239, 0.2); color: #e879f9; }

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

/* ==========================================================================
   Quick Copy Action Bar
   ========================================================================== */

.preview-actions-bar {
  margin-top: 14px;
  display: flex;
}

.btn-copy-bundle {
  width: 100%;
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-copy-bundle:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-primary);
  color: #ffffff;
  transform: translateY(-1px);
}

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

.btn-copy-bundle.copied {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-emerald);
  color: #34d399;
}

/* 휴대폰 화면 (2026-10-22 점검 🟠7) — 375px 에서 632px 로 넘치던 것.
   880px 이하 한 칸 배치가 1fr 이라 안쪽 탭 줄(6칸 × 최소 90px) 폭만큼 커졌다 → minmax(0, 1fr) */
@media (max-width: 720px) {
  body { overflow-x: hidden; }
  html, body { overflow-x: clip; } /* 사파리에서 손가락으로 옆으로 밀리지 않게(clip 은 머리글 sticky 를 깨지 않는다) */
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .glass-card { min-width: 0; }
  .app-header { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .header-center, .header-right { max-width: 100%; min-width: 0; }
}
