:root {
  --bg: #ffffff;
  --surface: #f8f8fa;
  --surface2: #f0f0f5;
  --surface3: #e8e8f0;
  --surface4: #dcdce8;
  --border: #e2e2ec;
  --border2: #d0d0de;
  --border3: #b8b8cc;
  --text: #111118;
  --text2: #44445a;
  --text3: #9898b0;
  --accent: #6c5ce7;
  --accent2: #5548c8;
  --accent3: #ede8ff;
  --gold: #c8860a;
  --teal: #00a896;
  --rose: #e0447a;
  --green: #009e7a;
  --orange: #c05a38;
  --sidebar-w: 220px;
  --sidebar-collapsed: 52px;
  --topbar-h: 48px;
  --font: 'DM Sans', sans-serif;
  --display: 'DM Sans', sans-serif;
  --mono: 'DM Mono', monospace;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
  --T: 0.2s cubic-bezier(0.4,0,0.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; font-size: 14px; }

/* ==================== LAYOUT ==================== */
.app { display: flex; height: 100vh; }

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition);
  overflow: hidden;
  z-index: 20;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-top {
  padding: 12px 8px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 8px;
  transition: background var(--transition);
}
.brand-row:hover { background: var(--surface2); }
.brand-logo {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display);
  font-size: 11px; font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}
.brand-name {
  font-family: var(--display);
  font-size: 13px; font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
}
.brand-chevron { margin-left: auto; color: var(--text3); font-size: 10px; flex-shrink: 0; }

.sidebar-icons {
  display: flex;
  gap: 2px;
  padding: 0 2px;
}
.s-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text2);
  font-size: 15px;
  transition: all var(--transition);
  position: relative;
  flex-shrink: 0;
  border: none;
  background: none;
}
.s-icon:hover { background: var(--surface2); color: var(--text); }
.s-icon.active { background: var(--surface3); color: var(--accent2); }
.s-icon .badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 7px; height: 7px;
  background: var(--rose);
  border-radius: 50%;
  border: 1.5px solid var(--surface);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 6px;
}
.sidebar-scroll::-webkit-scrollbar { width: 3px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border3); border-radius: 2px; }

.sidebar-section { margin-bottom: 6px; }
.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 8px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}
.sidebar.collapsed .sidebar-section-label { opacity: 0; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text2);
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  min-height: 30px;
}
.sidebar-item:hover { background: var(--surface2); color: var(--text); }
.sidebar-item.active { background: var(--surface3); color: var(--accent2); }
.sidebar-item-icon { font-size: 14px; flex-shrink: 0; width: 16px; text-align: center; }
.sidebar-item-text { font-size: 12px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.sidebar-item-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  background: var(--surface3);
  padding: 1px 5px;
  border-radius: 10px;
  flex-shrink: 0;
}

.sidebar-more {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text3);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition);
}
.sidebar-more:hover { color: var(--text2); }

.collapse-btn {
  margin: auto 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text3);
  font-size: 12px;
  transition: all var(--transition);
  border: none;
  background: none;
  width: calc(100% - 12px);
  white-space: nowrap;
  overflow: hidden;
}
.collapse-btn:hover { background: var(--surface2); color: var(--text2); }
.collapse-icon { font-size: 14px; flex-shrink: 0; }

/* ==================== MAIN ==================== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ==================== TOPBAR ==================== */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--text2); font-size: 13px; }
.breadcrumb-sep { color: var(--text3); }
.project-name-wrap { position: relative; }
.project-name {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: none;
  border: none;
  border-bottom: 1px dashed transparent;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: text;
  transition: all var(--transition);
  outline: none;
  min-width: 80px;
}
.project-name:hover { border-bottom-color: var(--border3); background: var(--surface2); }
.project-name:focus { border-bottom-color: var(--accent); background: var(--surface2); }
.edit-hint {
  position: absolute;
  top: -20px; left: 0;
  font-size: 10px;
  color: var(--accent2);
  opacity: 0;
  transition: opacity var(--transition);
  white-space: nowrap;
  pointer-events: none;
}
.project-name:focus ~ .edit-hint { opacity: 1; }

.topbar-meta { display: flex; align-items: center; gap: 6px; color: var(--text3); font-size: 11px; font-family: var(--mono); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.t-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: none;
  color: var(--text2);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.t-btn:hover { border-color: var(--border3); color: var(--text); background: var(--surface2); }
.t-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.t-btn.primary:hover { background: var(--accent2); border-color: var(--accent2); color: #ffffff; }
.avatar-stack { display: flex; }
.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  margin-left: -6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.avatar:first-child { margin-left: 0; }

/* ==================== CONTENT AREA ==================== */
.content-area, .page-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}
.content-area::-webkit-scrollbar, .page-body::-webkit-scrollbar { width: 5px; }
.content-area::-webkit-scrollbar-thumb, .page-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ==================== SECTION ==================== */
.section { margin-bottom: 32px; }
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.section-title {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.section-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  background: var(--surface2);
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* Filter tabs */
.filter-tabs { display: flex; gap: 3px; background: var(--surface2); border-radius: var(--radius); padding: 3px; border: 1px solid var(--border); }
.filter-tab {
  padding: 4px 12px;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.filter-tab.active { background: var(--surface4); color: var(--text); }

/* View toggle */
.view-toggle { display: flex; gap: 2px; margin-left: auto; }
.view-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  border: 1px solid transparent;
  background: none;
  color: var(--text3);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}
.view-btn:hover { color: var(--text2); border-color: var(--border); }
.view-btn.active { background: var(--surface3); color: var(--accent2); border-color: var(--border2); }

/* ==================== GALLERY VIEW ==================== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.channel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.channel-card:hover {
  border-color: var(--border3);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
}
.channel-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 24px rgba(108,92,231,0.2);
}

.card-thumb {
  height: 90px;
  background: var(--surface2);
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.card-thumb-placeholder { font-size: 28px; opacity: 0.3; }
.card-thumb-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.4));
}

.card-body { padding: 10px 12px 12px; }
.card-channel-row {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 8px;
}
.channel-icon {
  width: 20px; height: 20px;
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}
.channel-icon.fb { background: rgba(24,119,242,0.15); color: #1877f2; }
.channel-icon.ig { background: rgba(225,48,108,0.15); color: #e1306c; }
.channel-icon.yt { background: rgba(255,0,0,0.15); color: #ff0000; }
.channel-icon.tw { background: rgba(29,161,242,0.15); color: #1da1f2; }
.channel-icon.pi { background: rgba(230,0,35,0.15); color: #e60023; }
.channel-icon.bl { background: rgba(255,152,0,0.15); color: #ff9800; }
.channel-icon.web { background: rgba(0,184,148,0.15); color: #00b894; }
.channel-icon.x { background: rgba(255,255,255,0.1); color: #fff; }

.card-channel-name { font-size: 13px; font-weight: 600; color: var(--text); }
.card-brand-tag {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface3);
  color: var(--text2);
}

.card-stats { display: flex; gap: 10px; }
.card-stat { display: flex; flex-direction: column; gap: 1px; }
.card-stat-label { font-size: 10px; color: var(--text3); }
.card-stat-value { font-size: 12px; font-weight: 500; color: var(--text2); font-family: var(--mono); }

.card-status-bar {
  display: flex; gap: 2px;
  margin-top: 8px;
}
.status-pip {
  height: 3px;
  border-radius: 2px;
  flex: 1;
}

/* ==================== TABLE VIEW ==================== */
.table-view { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 7px 12px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface);
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13px;
}
.data-table tr { cursor: pointer; transition: background var(--transition); }
.data-table tr:hover td { background: var(--surface2); }
.data-table tr.selected td { background: rgba(108,92,231,0.08); }

/* ==================== BOARD VIEW ==================== */
.board-view { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.board-col { flex-shrink: 0; width: 220px; }
.board-col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px;
  margin-bottom: 6px;
}
.board-col-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.board-col-count { font-family: var(--mono); font-size: 10px; color: var(--text3); }
.board-cards { display: flex; flex-direction: column; gap: 5px; }
.board-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  cursor: pointer;
  transition: all var(--transition);
}
.board-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.board-card.selected { border-color: var(--accent); background: rgba(108,92,231,0.07); }
.board-card-title { font-size: 12px; font-weight: 500; color: var(--text); margin-bottom: 7px; line-height: 1.4; }
.board-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ==================== STATUS BADGES ==================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 20px;
  font-size: 10px; font-weight: 500; white-space: nowrap;
}
.badge::before { content:''; width:5px; height:5px; border-radius:50%; flex-shrink:0; }
.b-idea { background:rgba(107,114,128,.12); color:#4b5563; } .b-idea::before { background:#6b7280; }
.b-topublish { background:rgba(59,130,246,.12); color:#1d4ed8; } .b-topublish::before { background:#3b82f6; }
.b-creating { background:rgba(139,92,246,.12); color:#6d28d9; } .b-creating::before { background:#8b5cf6; }
.b-prepare { background:rgba(236,72,153,.12); color:#be185d; } .b-prepare::before { background:#ec4899; }
.b-tocheck { background:rgba(245,158,11,.12); color:#92400e; } .b-tocheck::before { background:#f59e0b; }
.b-published { background:rgba(16,185,129,.12); color:#065f46; } .b-published::before { background:#10b981; }
.b-cancelled { background:rgba(239,68,68,.12); color:#991b1b; } .b-cancelled::before { background:#ef4444; }
.b-active { background:rgba(16,185,129,.10); color:#065f46; border:1px solid rgba(16,185,129,.25); }
.b-active::before { background:#10b981; }
.b-inactive { background:rgba(107,114,128,.10); color:#374151; border:1px solid rgba(107,114,128,.25); }
.b-inactive::before { background:#6b7280; }

.tag { display:inline-block; padding:2px 7px; border-radius:4px; font-size:11px; font-weight:500; background:var(--surface3); color:var(--text2); border:1px solid var(--border); }
.avatar-sm { width:20px; height:20px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-size:8px; font-weight:700; color:#fff; flex-shrink:0; }

/* ==================== CONTENT SECTION ==================== */
.content-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 14px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.selected-channel-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text2);
}
.selected-channel-pill .dot { width:6px; height:6px; border-radius:50%; background: var(--accent2); }
.no-channel-selected {
  display: flex; align-items: center; justify-content: center;
  height: 120px;
  border: 1px dashed var(--border2);
  border-radius: var(--radius-xl);
  color: var(--text3);
  font-size: 13px;
  gap: 8px;
}

/* Post card */
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
}
.post-card:hover { border-color: var(--border3); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.10); }
.post-card-thumb {
  height: 80px;
  background: linear-gradient(135deg, var(--surface2), var(--surface3));
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  opacity: 0.5;
}
.post-card-body { padding: 10px 12px 12px; }
.post-card-title { font-size: 12px; font-weight: 500; color: var(--text); margin-bottom: 7px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-card-meta { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

/* ==================== EMPTY ==================== */
.empty { display:flex; flex-direction:column; align-items:center; justify-content:center; height:200px; gap:10px; color:var(--text3); }
.empty h3 { font-size:14px; color:var(--text2); }

/* ==================== INBOX PANEL ==================== */
.inbox-panel {
  position: fixed;
  top: 0; right: -360px;
  width: 360px; height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border2);
  z-index: 100;
  display: flex; flex-direction: column;
  transition: right var(--transition);
}
.inbox-panel.open { right: 0; }
.inbox-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.inbox-title { font-family: var(--display); font-size: 15px; font-weight: 700; }
.inbox-body { flex: 1; overflow-y: auto; padding: 12px; }
.inbox-body::-webkit-scrollbar { width: 3px; }
.inbox-item { padding: 10px 12px; border-radius: var(--radius-lg); cursor: pointer; transition: background var(--transition); margin-bottom: 4px; border: 1px solid transparent; }
.inbox-item:hover { background: var(--surface2); }
.inbox-item.unread { border-color: var(--border); background: var(--surface2); }
.inbox-item-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.inbox-item-msg { font-size: 12px; color: var(--text2); line-height: 1.5; }
.inbox-item-time { margin-left: auto; font-size: 10px; color: var(--text3); font-family: var(--mono); white-space: nowrap; }
.unread-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--rose); flex-shrink: 0; }

/* ==================== TOAST ==================== */
.toast-wrap { position:fixed; bottom:20px; right:20px; display:flex; flex-direction:column; gap:6px; z-index:200; }
.toast { background:#ffffff; border:1px solid var(--border2); border-radius:var(--radius-lg); padding:9px 14px; font-size:13px; color:var(--text); min-width:180px; animation:slideIn .2s ease; box-shadow:0 4px 16px rgba(0,0,0,0.10); }
.toast.success { border-left:3px solid var(--green); }
.toast.info { border-left:3px solid var(--accent2); }
.toast.danger { border-left:3px solid var(--rose); }
@keyframes slideIn { from{transform:translateX(16px);opacity:0} to{transform:translateX(0);opacity:1} }

/* ==================== DIVIDER ==================== */
.section-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 24px 0 18px;
}
.section-divider-line { flex: 1; height: 1px; background: var(--border); }
.section-divider-label {
  font-family: var(--display);
  font-size: 13px; font-weight: 700;
  color: var(--text2);
  white-space: nowrap;
}

/* Login page (added for consistency) */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 360px;
  text-align: center;
}
.login-container h2 { font-family: var(--display); margin-bottom: 20px; }
.login-container input {
  width: 100%;
  padding: 10px;
  margin: 8px 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.login-container button {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
}
.login-container .error, .login-container .success { margin: 10px 0; font-size: 12px; }
.login-container .error { color: var(--rose); }
.login-container .success { color: var(--green); }
.login-container a { color: var(--accent2); text-decoration: none; font-size: 12px; display: inline-block; margin-top: 15px; }

/* Modal styles (for channel page group modal) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(80,80,120,0.25);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 400px;
}
.modal-title {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
}
.modal-field { margin-bottom: 14px; }
.modal-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 5px;
  display: block;
}
.modal-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
}
.modal-input:focus { outline: none; border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.color-swatches { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--T);
  border: 2px solid transparent;
}
.swatch:hover { transform: scale(1.2); }
.swatch.selected { border-color: var(--text); transform: scale(1.15); }
/* ============================================================
   MOBILE RESPONSIVE — Content Hub
   Breakpoints: 768px (tablet), 480px (phone)
   All desktop styles unchanged — media queries only
   ============================================================ */

/* ── Hamburger button — hidden on desktop ── */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--text2);
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--surface2); }

/* ── Sidebar overlay — hidden on desktop ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 299;
}

/* ── Bottom navigation bar — hidden on desktop ── */
.bottom-nav {
  display: none;
}

/* ── Admin desktop-only message ── */
.admin-mobile-block {
  display: none;
}

/* Sidebar close button — mobile only */
.sidebar-close-btn { display: none; }

/* ============================================================
   TABLET — 768px and below
   ============================================================ */
@media (max-width: 768px) {

  /* ── Base mobile reset ── */
  * { -webkit-tap-highlight-color: transparent; }
  input, select, textarea { font-size: 16px !important; }

  /* ── Layout: main fills entire screen ── */
  html, body {
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .app {
    display: block;
    width: 100%;
    min-height: 100vh;
    position: relative;
  }

  /* ── Sidebar: off-screen via transform, overlays content when open ── */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 280px !important;
    min-width: unset !important;
    max-width: 85vw !important;
    z-index: 1000 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-shadow: none !important;
    background: var(--surface) !important;
    border-right: 1px solid var(--border) !important;
    /* Always visible in DOM, just off-screen */
    display: flex !important;
    flex-direction: column !important;
    visibility: visible !important;
  }
  .sidebar.mobile-open {
    transform: translateX(0) !important;
    box-shadow: 8px 0 32px rgba(0,0,0,0.25) !important;
  }
  /* Override collapsed state on mobile */
  .sidebar.collapsed {
    transform: translateX(-100%) !important;
    width: 280px !important;
  }
  .sidebar.collapsed.mobile-open {
    transform: translateX(0) !important;
  }
  .sidebar.collapsed .sidebar-section-label,
  .sidebar.collapsed .sidebar-item-text,
  .sidebar.collapsed .brand-name {
    opacity: 1 !important;
    display: block !important;
  }
  .collapse-btn { display: none !important; }

  /* Close sidebar button — shown inside sidebar on mobile */
  .sidebar-close-btn {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    padding: 10px 12px 4px;
    flex-shrink: 0;
    width: 100%;
  }
  .sidebar-close-btn:hover { color: var(--text) !important; }

  /* ── Overlay behind sidebar ── */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
  }
  .sidebar-overlay.active {
    display: block !important;
  }
  .sidebar-overlay.hidden { display: none !important; }

  /* ── Main: always full width ── */
  .main {
    width: 100% !important;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 60px;
  }

  /* ── Topbar: static (not sticky) so it scrolls with page ── */
  .topbar {
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: nowrap;
    position: static !important;
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border) !important;
    min-height: 50px;
  }
  /* Hamburger — visible on mobile */
  .hamburger-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    font-size: 22px;
  }
  /* Topbar actions — only show sign out */
  .topbar-actions .t-btn:not(.primary):not(.t-btn-keep) { display: none !important; }
  .topbar-actions a[href="logout.php"] { display: inline-flex !important; }
  .topbar-actions { gap: 6px; flex-shrink: 0; }
  /* Breadcrumb — truncate long paths */
  .breadcrumb {
    font-size: 12px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
  }

  /* ── Page body ── */
  .page-body {
    overflow-y: visible !important;
    height: auto !important;
    flex: 1;
    padding: 12px;
  }

  /* Bottom navigation bar — always visible on mobile */
  .bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    z-index: 200;
    align-items: stretch;
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    border: none;
    background: none;
    color: var(--text3);
    font-family: var(--font);
    font-size: 10px;
    font-weight: 500;
    padding: 6px 4px;
    position: relative;
    transition: color 0.15s;
    text-decoration: none;
  }
  .bottom-nav-item:hover,
  .bottom-nav-item.active { color: var(--accent); }
  .bottom-nav-icon { font-size: 20px; line-height: 1; }
  .bottom-nav-badge {
    position: absolute;
    top: 4px;
    left: calc(50% + 6px);
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: #e0447a;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
  }

  /* Toast — full width on mobile */
  .toast-wrap { left: 12px; right: 12px; bottom: 66px; }
  .toast { min-width: unset; }

  /* Dashboard — channel cards full width */
  .channels-gallery { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }

  /* Filter tabs — horizontal scroll */
  .filter-tabs { overflow-x: auto; flex-wrap: nowrap !important; padding-bottom: 4px; }
  .filter-tab { white-space: nowrap; flex-shrink: 0; }

  /* Section header — wrap */
  .section-header { flex-wrap: wrap; gap: 8px; }

  /* Board view — columns stack vertically */
  .board-view { flex-direction: column !important; overflow-x: visible !important; }
  .board-col { width: 100% !important; flex-shrink: unset !important; }

  /* Related content board — same */
  #board-wrap { flex-direction: column !important; overflow-x: visible !important; }
  #board-wrap .board-col { width: 100% !important; }

  /* Contents table — collapse columns */
  .contents-table th:nth-child(3),
  .contents-table td:nth-child(3),
  .contents-table th:nth-child(4),
  .contents-table td:nth-child(4) { display: none; }

  /* Related content table — collapse */
  .rel-table th:nth-child(3),
  .rel-table td:nth-child(3),
  .rel-table th:nth-child(4),
  .rel-table td:nth-child(4),
  .rel-table th:nth-child(5),
  .rel-table td:nth-child(5) { display: none; }

  /* Gallery — 2 columns */
  .gallery-grid { grid-template-columns: 1fr 1fr !important; }

  /* Properties wrap — full width fields */
  .properties-wrap { padding: 8px 12px; }
  .field-row { flex-wrap: wrap; gap: 4px; }
  .field-label { min-width: unset !important; width: 100% !important; }
  .field-value { width: 100% !important; }

  /* Post title */
  .post-title-input { font-size: 22px !important; }

  /* Editor toolbar — wrap */
  .editor-toolbar { flex-wrap: wrap; gap: 2px; padding: 6px; }
  .editor-toolbar button { min-height: 32px; min-width: 32px; }

  /* Modals — full width */
  .modal-box { width: calc(100vw - 32px) !important; max-width: unset !important; margin: 16px; }

  /* Admin panel — desktop only message */
  .admin-mobile-block { display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 16px; padding: 40px 20px; text-align: center; }
  .admin-content-block { display: none !important; }

  /* Calendar table — scroll */
  .cal-table-wrap { overflow-x: auto; }
  .cal-table { min-width: 600px; }
  .cal-filters { flex-wrap: wrap; gap: 8px; }
  .cal-filter-group { flex-wrap: wrap; }

  /* Login / profile — padding */
  .login-box { padding: 12px; }
  .login-card { padding: 20px 16px; }
  .profile-wrap { padding: 0 12px; margin-top: 20px; }
}

/* ============================================================
   PHONE — 480px and below
   ============================================================ */
@media (max-width: 480px) {

  /* Topbar — even more compact */
  .topbar { padding: 6px 10px; }
  .breadcrumb { max-width: calc(100vw - 160px); }

  /* Channel cards — single column */
  .channels-gallery { grid-template-columns: 1fr !important; }

  /* Gallery — single column */
  .gallery-grid { grid-template-columns: 1fr !important; }

  /* Post title — smaller */
  .post-title-input { font-size: 18px !important; }

  /* Publish time picker — stack */
  #publish-time-wrap { flex-wrap: wrap !important; }

  /* Calendar filters — stack */
  .date-nav { flex-wrap: wrap; }
  .cal-wrap { padding: 12px; }

  /* Stats bar — compact */
  .cal-stats { font-size: 11px; gap: 8px; }
}
