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

:root {
  --orange: #F26B1F;
  --orange-dark: #D85A14;
  --orange-light: #FF8540;
  --orange-50: #FFF4ED;
  --orange-100: #FFE6D5;
  --orange-200: #FFCBA4;
  --white: #FFFFFF;
  --bg: #FAFAF7;
  --bg-3: #F5F4F0;
  --bg-4: #EBEAE4;
  --line: #E5E3DC;
  --line-2: #D4D1C8;
  --text: #1A1815;
  --text-2: #5C5851;
  --text-3: #8A867D;
  --text-muted: #B5B1A6;
  --tiktok: #000000;
  --youtube: #FF0000;
  --facebook: #1877F2;
  --green: #16A34A;
  --amber: #D97706;
  --red: #DC2626;
  --blue: #2563EB;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow', sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 0 1fr 420px;
  grid-template-rows: 56px 1fr 32px;
  height: 100vh;
  width: 100vw;
}

/* Sidebar thu về 0 (giữ trong grid để main/panel không dạt cột) — bộ lọc thành chip, tài khoản vào Cài đặt */
.sidebar {
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  border: none !important;
  overflow: hidden !important;
}

/* ===== BỘ LỌC DẠNG CHIP ===== */
.filter-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.chip {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--text-2);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--orange); }
.chip b { font-weight: 700; opacity: 0.6; font-size: 12px; }
.chip.active { background: var(--mode-accent, var(--orange)); color: #fff; border-color: var(--mode-accent, var(--orange)); }
.chip.active b { opacity: 0.9; }
.chip-alt { background: var(--bg-3); }
.chip-spacer { flex: 1 1 auto; }

/* === TITLE BAR === */
.titlebar {
  grid-column: 1 / -1;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

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

.brand-logo {
  width: 36px;
  height: 36px;
  background: var(--orange);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-weight: 700;
  font-size: 17px;
  box-shadow: 0 2px 8px rgba(242, 107, 31, 0.25);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: 0.02em; }
.brand-sub { font-size: 11.5px; color: var(--text-3); }

.titlebar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1.5px solid var(--line-2);
  background: var(--white);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.btn:hover { background: var(--bg-3); border-color: var(--text-muted); }
.btn-primary {
  background: var(--orange);
  color: var(--white);
  border-color: var(--orange);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(242, 107, 31, 0.25);
}
.btn-primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
.btn-small { padding: 6px 12px; font-size: 12px; }
.btn-ai {
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-light) 100%);
  color: var(--white);
  border: none;
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  font-weight: 600;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-ai:hover { opacity: 0.9; }
.btn-ai:disabled { opacity: 0.6; cursor: not-allowed; }

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 100px;
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  font-size: 12px;
  color: var(--green);
  font-weight: 500;
}
.status-pill.error { background: #FEF2F2; border-color: #FECACA; color: var(--red); }
.status-pill.warning { background: #FEF3C7; border-color: #FDE68A; color: var(--amber); }

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* === SIDEBAR === */
.sidebar {
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-section { margin-bottom: 18px; }
.nav-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  padding: 8px 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.12s;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active {
  background: var(--orange-50);
  color: var(--orange-dark);
}
.nav-icon { font-size: 14px; }
.nav-count {
  margin-left: auto;
  font-size: 11.5px;
  background: var(--bg-3);
  padding: 1px 8px;
  border-radius: 100px;
  font-weight: 600;
  color: var(--text-3);
}
.nav-item.active .nav-count { background: var(--orange-100); color: var(--orange-dark); }
.nav-count.warning { background: #FEF3C7; color: var(--amber); }

.account-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--text-2);
}
.account-item.disconnected { opacity: 0.5; }
.platform-mini {
  width: 18px; height: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: white;
}
.platform-mini.tt { background: var(--tiktok); }
.platform-mini.yt { background: var(--youtube); }
.platform-mini.fb { background: var(--facebook); }
.status-mini {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--text-3);
  font-style: italic;
}
.status-mini.connected { color: var(--green); font-style: normal; font-weight: 600; }

.source-config {
  margin-top: auto;
  padding: 14px;
  background: var(--orange-50);
  border-radius: 10px;
  border: 1px solid var(--orange-100);
}
.source-title { font-size: 11.5px; color: var(--orange-dark); font-weight: 600; margin-bottom: 6px; }
.source-path { font-size: 12.5px; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.source-info { font-size: 11px; color: var(--text-3); }

/* === MAIN === */
.main { overflow-y: auto; background: var(--bg); padding: 28px 32px; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.page-title-wrap h1 {
  font-family: 'Barlow', sans-serif;
  font-weight: 700;
  font-size: 32px;
  line-height: 1.1;
  margin-bottom: 6px;
}
.page-title-wrap h1 em { font-style: italic; color: var(--orange); font-weight: 700; }
.page-subtitle { color: var(--text-3); font-size: 13px; }
.header-actions { display: flex; gap: 8px; }

/* === BANNER === */
.info-banner {
  background: var(--orange-50);
  border: 1px solid var(--orange-100);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 22px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
}
.info-banner-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--orange);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.info-banner b { color: var(--text); font-weight: 600; }

/* === DROP ZONE === */
.drop-zone {
  border: 2px dashed var(--orange-200);
  border-radius: 14px;
  padding: 36px 28px;
  text-align: center;
  margin-bottom: 26px;
  background: var(--orange-50);
  transition: all 0.2s;
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--orange);
  background: #FFF8F1;
  transform: scale(1.005);
}
.drop-zone-icon { font-size: 40px; margin-bottom: 10px; }
.drop-zone-title { font-size: 15.5px; margin-bottom: 5px; font-weight: 600; }
.drop-zone-subtitle { font-size: 12.5px; color: var(--text-3); }

/* === SECTION === */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title { font-size: 14.5px; font-weight: 600; }
.section-meta { font-size: 12px; color: var(--text-3); }

/* === VIDEO GRID === */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.video-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.18s;
  position: relative;
}
.video-card:hover {
  border-color: var(--orange-200);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.video-card.selected {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-100);
}

.video-thumb {
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #FFE6D5 0%, #FFCBA4 100%);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--orange-dark);
  font-size: 36px;
  overflow: hidden;
}
.video-thumb img,
.video-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.video-duration {
  position: absolute;
  bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.75);
  color: white;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 4px;
  font-weight: 600;
}
.video-status {
  position: absolute;
  top: 8px; left: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}
.status-ready { color: var(--green); }
.status-publishing { color: var(--blue); }
.status-published { color: var(--green); }
.status-scheduled { color: var(--amber); }
.status-failed { color: var(--red); }

.video-info { padding: 12px 14px; }

.video-title-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 8px;
}

.video-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

/* === 3-DOT CARD MENU === */
.card-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.card-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}
.card-menu-btn:hover {
  background: var(--bg-4);
  color: var(--text);
}

.card-dropdown {
  display: none;
  position: fixed;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  min-width: 150px;
  z-index: 9999;
  overflow: hidden;
}
.card-dropdown.open { display: block; }

.card-dropdown-item {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: background 0.12s;
}
.card-dropdown-item:hover { background: var(--bg-3); }
.card-dropdown-item.danger { color: var(--red); }
.card-dropdown-item.danger:hover { background: #FEF2F2; }
.video-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-3);
}
.video-platforms { display: flex; gap: 4px; margin-left: auto; }
.platform-dot {
  width: 18px; height: 18px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: white;
}
.pd-tt { background: var(--tiktok); }
.pd-yt { background: var(--youtube); }
.pd-fb { background: var(--facebook); }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty-icon { font-size: 60px; margin-bottom: 14px; opacity: 0.5; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-sub { font-size: 13px; }

/* === RIGHT PANEL === */
.right-panel {
  background: var(--white);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.panel-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  padding: 40px;
  text-align: center;
}
.panel-empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.panel-empty-text { font-size: 14px; font-weight: 500; }

.panel-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--orange-50);
}
.panel-title {
  font-family: 'Barlow', sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.panel-title em { font-style: italic; color: var(--orange); }
.panel-subtitle { font-size: 12px; color: var(--text-3); font-weight: 500; }
.panel-body { padding: 18px 22px; flex: 1; }

/* PREVIEW */
.preview-wrap {
  background: var(--bg);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
}
.preview-stage {
  aspect-ratio: 9/16;
  max-height: 240px;
  margin: 0 auto;
  background: linear-gradient(135deg, var(--orange-100) 0%, var(--orange-200) 100%);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-stage img { width: 100%; height: 100%; object-fit: cover; }
.preview-thumb-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 14px;
  color: var(--orange-dark);
  font-size: 12px;
}
.preview-thumb-icon {
  font-family: 'Barlow', sans-serif;
  font-size: 42px;
  font-style: italic;
  margin-bottom: 6px;
  font-weight: 700;
}
.preview-info { font-size: 11.5px; font-weight: 500; }
.upload-thumb-row { margin-top: 12px; text-align: center; }

/* === FORM === */
.form-group { margin-bottom: 16px; }
.ai-section {
  background: linear-gradient(135deg, #FFF4ED 0%, #FFE6D5 100%);
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--orange-100);
}
.ai-info {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--white);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-3);
}
.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 7px;
}
.form-label-meta {
  color: var(--text-3);
  font-weight: 400;
  font-size: 11.5px;
}
.form-input, .form-textarea {
  width: 100%;
  padding: 10px 13px;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  transition: all 0.15s;
}
.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-100);
}
.form-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

/* PLATFORM TABS */
.platform-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  background: var(--bg-3);
  padding: 4px;
  border-radius: 9px;
}
.platform-tab {
  flex: 1;
  padding: 7px;
  background: transparent;
  border: none;
  color: var(--text-3);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.platform-tab.active {
  background: var(--white);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.tab-dot { width: 8px; height: 8px; border-radius: 50%; }

/* PLATFORM TOGGLES */
.platforms { display: flex; flex-direction: column; gap: 8px; }
.platform-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.platform-row:not(.disabled):hover { border-color: var(--line-2); }
.platform-row.enabled {
  border-color: var(--orange-200);
  background: var(--orange-50);
}
.platform-row.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg-3);
}
.platform-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 12px;
}
.platform-icon.tt { background: var(--tiktok); }
.platform-icon.yt { background: var(--youtube); }
.platform-icon.fb { background: var(--facebook); }
.platform-meta { flex: 1; min-width: 0; }
.platform-name { font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
.platform-account {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toggle {
  position: relative;
  width: 36px; height: 22px;
  background: var(--line-2);
  border-radius: 100px;
  transition: background 0.2s;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle.on { background: var(--orange); }
.toggle.on::after { transform: translateX(14px); }

/* PANEL FOOTER */
.panel-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: var(--white);
}
.schedule-row { display: flex; gap: 6px; margin-bottom: 12px; }
.schedule-btn {
  flex: 1;
  padding: 9px;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  color: var(--text-2);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.schedule-btn:hover { border-color: var(--line-2); }
.schedule-btn.active {
  background: var(--orange-50);
  color: var(--orange-dark);
  border-color: var(--orange-200);
}
.publish-btn {
  width: 100%;
  padding: 13px;
  background: var(--orange);
  color: var(--white);
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(242, 107, 31, 0.25);
}
.publish-btn:hover {
  background: var(--orange-dark);
  transform: translateY(-1px);
}
.publish-btn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

/* STATUS BAR */
.statusbar {
  grid-column: 1 / -1;
  background: var(--white);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 16px;
  font-size: 11.5px;
  color: var(--text-3);
}
.status-item { display: flex; align-items: center; gap: 6px; }
.status-sep { color: var(--line-2); }

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;   /* trên cả overlay compose/panel mobile (600) để bảng đăng luôn hiện */
}
.modal-content {
  background: var(--white);
  border-radius: 14px;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 {
  font-family: 'Barlow', sans-serif;
  font-size: 22px;
  font-weight: 700;
}
.btn-close {
  background: var(--bg-3);
  border: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
}
.modal-body { padding: 20px 24px; }
.settings-section { margin-bottom: 20px; }
.settings-section h3 {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 10px;
}
.api-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-3);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.api-status {
  font-weight: 600;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 100px;
}
.api-status.connected { background: #DCFCE7; color: var(--green); }
.api-status.error { background: #FEE2E2; color: var(--red); }
.api-status.warning { background: #FEF3C7; color: var(--amber); }

/* TOAST */
.toast {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.warning { background: var(--amber); }

code {
  background: var(--bg-3);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== WIZARD STEPS ===== */
.wizard-steps {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 24px;
  padding: 14px 20px;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 12px;
}
.wizard-step {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.15s;
  white-space: nowrap;
}
.wizard-step.active {
  color: var(--orange);
  background: var(--orange-50);
}
.wizard-step.done {
  color: var(--green);
}
.wizard-sep {
  color: var(--line-2);
  font-size: 18px;
  flex-shrink: 0;
}
.wiz-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--line-2);
  color: var(--white);
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.wizard-step.active .wiz-num { background: var(--orange); }
.wizard-step.done .wiz-num { background: var(--green); }

/* ===== BRANCH GRID ===== */
.branch-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.branch-card {
  background: var(--white);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 20px 16px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.branch-card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.branch-card.active { border-color: var(--orange); background: var(--orange-50); }
.branch-dot {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin: 0 auto 10px;
}
.branch-name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}
.branch-info {
  font-size: 11px;
  color: var(--text-3);
}
.branch-config-warn {
  font-size: 10.5px;
  color: var(--amber);
  margin-top: 4px;
}

/* ===== FOLDER GRID (dùng lại video-grid) ===== */
.folder-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
}
.folder-card:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.folder-card.selected { border-color: var(--orange); background: var(--orange-50); }
.folder-thumb {
  aspect-ratio: 1;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  overflow: hidden;
  position: relative;
}
.folder-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.folder-badge {
  position: absolute;
  bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.65);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}
.folder-info {
  padding: 10px 12px;
}
.folder-name {
  font-size: 13px; font-weight: 700; margin-bottom: 3px;
}
.folder-meta { font-size: 11.5px; color: var(--text-3); }

/* ===== IMAGE PICKER ===== */
.img-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}
.img-pick-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: all 0.12s;
}
.img-pick-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.img-pick-item.selected { border-color: var(--orange); }
.img-pick-num {
  position: absolute;
  top: 4px; left: 4px;
  width: 22px; height: 22px;
  background: var(--orange);
  color: white;
  border-radius: 50%;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.img-pick-overlay {
  position: absolute;
  inset: 0;
  background: rgba(242,107,31,0.15);
  display: none;
}
.img-pick-item.selected .img-pick-overlay { display: block; }

/* ===== IMAGE ORDER ROW ===== */
.img-order-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.img-order-item {
  position: relative;
  width: 64px; height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--line);
  cursor: grab;
  flex-shrink: 0;
  transition: opacity 0.2s, border-color 0.2s;
  user-select: none;
}
.img-order-item.dragging { opacity: 0.4; cursor: grabbing; }
.img-order-item.drag-over { border-color: var(--orange); box-shadow: 0 0 0 2px var(--orange-200); }
.drag-handle {
  position: absolute;
  top: 2px; left: 3px;
  font-size: 11px; color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  z-index: 2; line-height: 1;
  pointer-events: none;
}
.img-order-item img { width: 100%; height: 100%; object-fit: cover; }
.img-order-item .remove-btn {
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.img-order-num {
  position: absolute;
  bottom: 2px; left: 4px;
  font-size: 10px; color: white;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* ===== LAYOUT SETTINGS ===== */
.layout-settings {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}
.layout-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--orange);
  background: var(--orange-50);
  padding: 3px 10px;
  border-radius: 20px;
}
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.slider-label { font-size: 12.5px; color: var(--text-2); min-width: 90px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--orange); }
.slider-val { font-size: 12px; color: var(--text-3); min-width: 32px; text-align: right; }
.bg-toggle { display: flex; gap: 4px; }
.bg-btn {
  padding: 5px 12px;
  background: var(--bg-3);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-2);
}
.bg-btn.active { background: var(--orange); border-color: var(--orange); color: white; }

/* ===== LOGO POSITION GRID ===== */
.logo-pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 32px);
  gap: 4px;
}
.logo-pos-btn {
  width: 32px; height: 32px;
  background: var(--bg-3);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: all 0.15s;
}
.logo-pos-btn:hover { border-color: var(--orange); }
.logo-pos-btn.active { background: var(--orange); border-color: var(--orange); color: white; }

/* PUBLISHING PROGRESS - POST */
.pstatus-uploading {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--orange);
  font-weight: 600;
  animation: pulse 1.5s ease-in-out infinite;
}

/* ========================================================
   MOBILE BOTTOM NAV — hidden on desktop
   ======================================================== */
.mobile-nav {
  display: none;
}
.mnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  cursor: pointer;
  color: var(--text-3);
  transition: color 0.15s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.mnav-item.active { color: var(--orange); }
.mnav-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--orange);
  border-radius: 0 0 2px 2px;
}
.mnav-icon { font-size: 20px; line-height: 1; }
.mnav-label { font-size: 10px; font-weight: 600; }

/* Mobile panel close button */
.mobile-panel-close { display: none; }

/* ========================================================
   MOBILE RESPONSIVE — max-width 768px
   ======================================================== */
@media (max-width: 768px) {
  html, body {
    overflow: auto;
    height: auto;
  }

  /* App grid: 1 column, no fixed height */
  .app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  /* === TITLEBAR === */
  .titlebar {
    flex-shrink: 0;
    padding: 0 14px;
    height: 50px;
  }
  .brand-sub { display: none; }
  .brand-name { font-size: 14px; }
  .brand-logo { width: 30px; height: 30px; font-size: 14px; }

  /* Titlebar actions: hide status pill + stats/history/settings btns (moved to bottom nav) */
  .titlebar-actions .status-pill { display: none; }
  .titlebar-actions { gap: 6px; }
  .titlebar-actions .btn {
    padding: 6px 10px;
    font-size: 11px;
  }
  /* Show only connection status icon, hide label text of stats/history/settings */
  #connectionStatus {
    display: flex !important;
    padding: 5px 10px;
    font-size: 11px;
  }
  /* Hide stats/history/settings from titlebar on mobile (they're in bottom nav) */
  .titlebar-actions > .btn:not(:first-of-type) { display: none; }

  /* === SIDEBAR: hide on mobile === */
  .sidebar { display: none !important; }

  /* === STATUSBAR: hide on mobile === */
  .statusbar { display: none !important; }

  /* === MAIN: flex-grow, scrollable === */
  .main {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 0;
    -webkit-overflow-scrolling: touch;
  }

  /* Chip lọc: cuộn ngang 1 hàng trên mobile; ẩn nút Tạo bài/Lịch sử (đã có ở thanh dưới) */
  .filter-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    margin-bottom: 12px;
  }
  .filter-chips .chip { flex: 0 0 auto; }
  .filter-chips .chip-spacer,
  .filter-chips .chip-alt { display: none; }
  /* Mode switch gọn trên mobile */
  #modeSwitch { margin: 0 4px 0 auto; }
  #modeSwitch button { padding: 6px 10px; font-size: 12px; }

  /* === RIGHT PANEL: full-screen overlay on mobile === */
  /* Hidden by default; shown only via .mobile-open class */
  .right-panel {
    display: none !important;
    position: fixed;
    inset: 0;
    z-index: 600;
    overflow-y: auto;
    flex-direction: column;
    padding-bottom: 80px;
  }
  .right-panel.mobile-open {
    display: flex !important;
    animation: slideInRight 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  @keyframes slideInRight {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
  }

  /* Post composer and step4 panels: full-screen on mobile */
  #postComposerPanel, #postStep4Panel {
    position: fixed !important;
    inset: 0 !important;
    z-index: 600 !important;
    overflow-y: auto !important;
    background: var(--bg) !important;   /* nền đặc, hết lòi nội dung phía sau */
    padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 90px !important;
    border-left: none !important;
    -webkit-overflow-scrolling: touch;
  }
  /* Khung chọn ảnh khi được chuyển vào bảng ghép trên mobile */
  #composerPickerMount:not(:empty) {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 14px;
  }
  #composerPickerMount .img-picker-grid {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 8px;
  }

  /* === MOBILE PANEL CLOSE BUTTON === */
  .mobile-panel-close {
    display: flex !important;
    margin-bottom: 12px !important;
    justify-content: flex-start !important;
    border-color: var(--line-2);
    color: var(--text-2);
    font-size: 13px;
  }

  /* === PAGE HEADER === */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
  }
  .page-title-wrap h1 { font-size: 22px; margin-bottom: 3px; }
  .page-subtitle { font-size: 12px; }
  .header-actions {
    display: flex;
    width: 100%;
    gap: 8px;
  }
  .header-actions .btn {
    flex: 1;
    justify-content: center;
    font-size: 12px;
    padding: 8px 10px;
  }

  /* === VIDEO GRID: 2 columns === */
  .video-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 100px; /* space for bottom nav */
  }
  .video-info { padding: 9px 10px; }
  .video-title { font-size: 12px; }
  .video-meta { font-size: 10px; }

  /* === BRANCH GRID: 2 columns === */
  .branch-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .branch-card { padding: 14px 10px; }
  .branch-dot { width: 36px; height: 36px; font-size: 18px; margin-bottom: 6px; }
  .branch-name { font-size: 12px; }

  /* === WIZARD STEPS: horizontal scroll === */
  .wizard-steps {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 10px 12px;
    margin-bottom: 14px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .wizard-steps::-webkit-scrollbar { display: none; }
  .wizard-step { font-size: 11px; padding: 5px 8px; white-space: nowrap; }
  .wiz-num { width: 18px; height: 18px; font-size: 10px; }

  /* === SECTION HEADER === */
  .section-header { margin-bottom: 10px; }

  /* === MODALS: bottom sheet style === */
  .modal {
    align-items: flex-end;
    padding: 0;
  }
  .modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    animation: slideUp 0.3s ease;
  }
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .modal-header h2 { font-size: 17px; }
  .modal-body { padding: 14px 16px; }

  /* Settings modal: full height scroll */
  #settingsModal .modal-content,
  #statsModal .modal-content,
  #notifModal .modal-content {
    max-height: 95vh;
  }

  /* === MOBILE BOTTOM NAV === */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--white);
    border-top: 1px solid var(--line);
    z-index: 500;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Compensate for bottom nav height */
  .main { padding-bottom: 70px; }

  /* === IMG PICKER GRID: smaller === */
  .img-picker-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
  }

  /* === FORM INPUTS: larger touch targets === */
  .form-input, .form-textarea {
    font-size: 16px; /* prevents iOS zoom */
    padding: 11px 13px;
  }
  .btn-ai { padding: 12px; font-size: 14px; }
  .publish-btn { padding: 14px; font-size: 14px; }

  /* === PLATFORM ROWS: compact === */
  .platform-row { padding: 9px 12px; gap: 10px; }
  .platform-icon { width: 28px; height: 28px; font-size: 11px; }
  .platform-name { font-size: 12px; }

  /* === STATS/FILTER COMPACT === */
  .schedule-btn { padding: 8px 6px; font-size: 11px; }

  /* === Panel body padding === */
  .panel-body { padding: 14px 16px; }
  .panel-header { padding: 14px 16px; }
  .panel-footer { padding: 12px 16px; }

  /* Post pages full-width */
  #postsPage, #postsHistoryPage {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Step2 / step3 back buttons */
  #postStep2 > div:first-child,
  #postStep3 > div:first-child,
  #postStep4 > div:first-child {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Drive video modal */
  #driveVideoModal > div {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 95vh !important;
    margin-top: auto;
  }

  /* Adjust panel in stats modal */
  #adjustPanel { margin: 0 -2px 12px; }

  /* Post filter buttons wrap */
  #postsHistoryPage > div:nth-child(2) { gap: 6px; }
  .post-filter-btn { padding: 6px 10px; font-size: 11px; }

  /* Empty state smaller */
  .empty-icon { font-size: 40px; }
  .empty-title { font-size: 15px; }
  .empty-sub { font-size: 12px; }

  /* Toast above bottom nav */
  .toast { bottom: 80px; }

} /* end @media (max-width: 768px) */
