/* Channel Hub styles. Colours live in these variables: use them instead of hard-coded colours. */
:root {
  --bg: #14161B;
  --card: #1C1F26;
  --card-2: #23272F;
  --line: #2E333D;
  --text: #ECEDEF;
  --muted: #9AA0AB;
  --accent: #C2412D;
  --accent-hover: #D4523D;
  --danger: #E5675A;
  --radius: 16px;
  --radius-sm: 10px;
  --tap: 44px;
  --font-head: "Space Grotesk", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); }

/* Building blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  font: 500 15px var(--font-body); cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.field {
  width: 100%; min-height: var(--tap); padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: 16px var(--font-body);
}
.field:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.label { display: block; margin: 14px 0 6px; font-weight: 500; color: var(--muted); font-size: 14px; }
.error { color: var(--danger); min-height: 1.5em; margin: 12px 0 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); padding: 28px; }
.login-card h1 { font-size: 28px; }
.login-card .btn { width: 100%; margin-top: 22px; }

/* App frame: sidebar + main */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--line); padding: 24px 16px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 700; font-size: 20px; padding: 0 8px 18px; }
.brand img { width: 28px; height: 28px; }
.side-heading { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 14px 8px 6px; }
.channel-btn {
  display: flex; align-items: center; min-height: var(--tap); padding: 0 12px; border-radius: var(--radius-sm);
  border: 0; background: none; color: var(--text); font: 500 15px var(--font-body); text-align: left; cursor: pointer; width: 100%;
}
.channel-btn:hover { background: var(--card); }
.channel-btn[aria-current="true"] { background: var(--card-2); box-shadow: inset 3px 0 0 var(--accent); }
.channel-btn.in-group { padding-left: 22px; }
.sidebar-foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 2px; }
a.side-action { text-decoration: none; }
.main { padding: 28px 32px 64px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

/* ---------- Main page ---------- */
.page-title { font-size: 30px; line-height: 1.2; }
.status { padding: 40px; text-align: center; }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chip {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px;
  background: rgba(194, 65, 45, 0.16); color: #F0A090; font-size: 12px; font-weight: 500; line-height: 1.6;
}
.chip-soft { background: var(--card-2); color: var(--muted); }
.btn-small { min-height: var(--tap); padding: 0 14px; font-size: 14px; white-space: nowrap; flex: none; }

/* Header */
.hub-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.title-block { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search { position: relative; display: block; width: 280px; }
.search .field { padding-right: 40px; background: var(--card); }
.search kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font: 500 12px var(--font-body); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px;
}

.search-results {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; width: min(440px, calc(100vw - 32px));
  max-height: min(460px, 70vh); overflow-y: auto; padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.search-item { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 10px; border-radius: var(--radius-sm); text-decoration: none; }
.search-item[aria-selected="true"] { background: var(--card-2); }
.search-empty { margin: 0; padding: 14px; color: var(--muted); }

/* Sidebar channel actions */
.sidebar-actions { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.side-action {
  display: flex; align-items: center; min-height: var(--tap); padding: 0 12px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--muted); font: 500 14px var(--font-body); text-align: left; cursor: pointer; white-space: nowrap;
}
.side-action:hover { background: var(--card); color: var(--text); }

/* App icon tiles */
.app-icon {
  flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: var(--card-2); color: var(--muted);
}
.app-icon svg, .app-icon img { width: 24px; height: 24px; display: block; }
.app-icon.lg { width: 48px; height: 48px; border-radius: 12px; }
.app-icon.lg svg, .app-icon.lg img { width: 28px; height: 28px; }
.app-icon.xl { width: 64px; height: 64px; border-radius: 16px; }
.app-icon.xl svg, .app-icon.xl img { width: 38px; height: 38px; }

/* Pinned row */
.pinned { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.pin-card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px; min-height: 132px; text-decoration: none;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .15s, transform .15s;
}
.pin-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.pin-card .app-icon { margin-bottom: 6px; }
.pin-name { font-family: var(--font-head); font-weight: 600; font-size: 16px; line-height: 1.3; }
.pinned-empty { grid-column: 1 / -1; padding: 18px 20px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* Main pipeline (Trello) */
.pipeline { padding: 0; overflow: hidden; }
.pipeline-link {
  display: flex; align-items: center; gap: 20px; padding: 26px 28px; text-decoration: none;
  background: linear-gradient(120deg, rgba(12, 102, 228, 0.12), transparent 60%);
}
.pipeline-link:hover .pipeline-name { text-decoration: underline; text-underline-offset: 3px; }
.pipeline-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.pipeline-name { font-family: var(--font-head); font-weight: 600; font-size: 24px; line-height: 1.25; overflow-wrap: anywhere; }
.pipeline-empty { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 28px; flex-wrap: wrap; }
.pipeline-empty p { margin: 4px 0 0; }

/* Workflow bar + filter (stick to the top while scrolling) */
.sticky-bar {
  position: sticky; top: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; margin: -4px 0; background: var(--bg);
}
.workflow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.workflow-steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.workflow-steps li { display: flex; align-items: center; gap: 6px; }
.workflow-steps li + li::before { content: "\2192"; color: var(--muted); font-size: 14px; }
.step-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 14px 0 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: 500 14px var(--font-body); cursor: pointer; white-space: nowrap;
}
.step-btn:hover { border-color: var(--accent); }
.payments-btn { padding: 0 16px; margin-left: 8px; border-style: dashed; }
.step-num {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font: 700 13px var(--font-head); flex: none;
}
.filter { display: inline-flex; padding: 4px; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.filter-btn {
  min-height: 36px; min-width: 44px; padding: 0 14px; border: 0; border-radius: 8px; background: none; color: var(--muted);
  font: 500 14px var(--font-body); cursor: pointer;
}
.filter-btn[aria-pressed="true"] { background: var(--card-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

/* Stage cards */
.stage { padding: 22px 24px 24px; scroll-margin-top: 84px; }
.stage.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(194, 65, 45, 0.25); } }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.stage-head h2 { display: flex; align-items: center; gap: 12px; font-size: 20px; }
.stage-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.stage.single .stage-cols { grid-template-columns: 1fr; }
.col-title { font: 600 12px var(--font-body); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 8px; }
.col-manage { border-left: 1px solid var(--line); padding-left: 24px; }
.stage.single .col-manage { border-left: 0; padding-left: 0; }
.payments { border-style: dashed; }
.link-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.link-list:empty { margin-bottom: 0; }
.link-row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 10px; margin: 0 -10px;
  border-radius: var(--radius-sm); text-decoration: none;
}
.link-row:hover { background: var(--card-2); }
.link-text { display: flex; flex-direction: column; min-width: 0; }
.link-name { font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.link-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.add-btn {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: var(--tap); padding: 0 14px;
  border: 1px dashed var(--line); border-radius: var(--radius-sm); background: none; color: var(--muted);
  font: 500 14px var(--font-body); cursor: pointer;
}
.add-btn:hover { border-color: var(--accent); color: var(--text); }
.add-btn-quiet { border-color: transparent; justify-content: flex-start; padding: 0 10px; margin: 0 -10px; width: calc(100% + 20px); }
.add-btn-lg { width: auto; min-height: 52px; padding: 0 22px; font-size: 15px; }

/* Add / Edit link panel: slides in from the right (from the bottom on phones) */
.panel-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.45); }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 31; width: min(440px, 100vw); overflow-y: auto;
  background: var(--card); border-left: 1px solid var(--line); box-shadow: -20px 0 40px rgba(0, 0, 0, 0.35);
  animation: slide-in .18s ease-out;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
.panel-form { padding: 22px 24px 28px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.panel-head h2 { font-size: 22px; }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); flex: none; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--muted); font-size: 18px; cursor: pointer;
}
.icon-btn:hover { background: var(--card-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.url-field { position: relative; }
.url-field .field { padding-left: 50px; }
.url-icon { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); }
.url-icon .app-icon { width: 34px; height: 34px; background: none; }
.url-icon .app-icon svg, .url-icon .app-icon img { width: 22px; height: 22px; }
.hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); min-height: 1.4em; }
select.field { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.toggle { display: flex; padding: 4px; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.toggle label { flex: 1; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span {
  display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 8px; color: var(--muted); font-weight: 500; cursor: pointer;
}
.toggle input:checked + span { background: var(--card-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); margin-top: 8px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.saved { color: #7FD3A0; margin: 0; min-height: 1.5em; font-size: 14px; }
.panel-form .error { margin-top: 8px; }
.panel-foot {
  display: flex; gap: 10px; margin: 8px -24px -28px; padding: 14px 24px 20px;
  position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
}
.panel-foot .btn-accent { flex: 1; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }

/* Edit mode */
.btn[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.link-tools { display: none; margin-left: auto; gap: 2px; flex: none; }
.editing .link-tools { display: flex; }
.drag-handle { display: none; cursor: grab; touch-action: none; color: var(--muted); }
.editing .drag-handle { display: inline-grid; }
.editing .link-row { padding-left: 0; cursor: pointer; }
.editing .link-row:hover { background: var(--card-2); }
.editing .link-list { min-height: 12px; }
.editing .pin-card, .editing .pipeline-link { outline: 1px dashed var(--line); outline-offset: -1px; }
.link-row.dragging { background: var(--card-2); box-shadow: 0 0 0 2px var(--accent); opacity: 0.95; }
body.drag-active, body.drag-active * { cursor: grabbing !important; user-select: none; }
.link-list.drop-target { background: rgba(194, 65, 45, 0.06); border-radius: var(--radius-sm); }
.edit-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border: 1px solid var(--accent); border-radius: var(--radius); background: rgba(194, 65, 45, 0.08); font-size: 14px;
}

.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Phone Review queue (only shown below 700px) */
.review-queue { display: none; border-color: var(--accent); padding: 16px; }
.review-title { display: flex; align-items: baseline; gap: 8px; font-size: 18px; margin-bottom: 6px; }
.review-empty { margin: 0; }
.review-queue .link-list { margin-bottom: 0; }

/* Toast message */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: min(560px, calc(100vw - 32px));
  padding: 14px 18px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

@media (max-width: 700px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; flex-direction: row; overflow-x: auto; gap: 6px;
    height: auto; position: static;
  }
  #channel-list { display: flex; gap: 6px; }
  .brand, .side-heading { display: none; }
  .sidebar-actions, .sidebar-foot { flex-direction: row; margin: 0; padding: 0 0 0 6px; border-top: 0; border-left: 1px solid var(--line); gap: 6px; }
  .sidebar-foot { display: flex; }
  .sidebar-foot .btn { border: 0; background: none; color: var(--muted); white-space: nowrap; }
  .search-results { left: 0; right: 0; width: auto; }
  .review-queue { display: block; order: -1; }
  .channel-btn { white-space: nowrap; width: auto; }
  .channel-btn.in-group { padding-left: 12px; }
  .main { padding: 20px 16px 48px; gap: 16px; }
  .page-title { font-size: 24px; }
  .header-actions { width: 100%; }
  .search { width: auto; flex: 1 1 100%; }
  .header-actions .btn { flex: 1; }
  .pinned { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pin-card { min-height: 112px; padding: 14px; }
  .pipeline-link { flex-wrap: wrap; padding: 20px; gap: 14px; }
  .pipeline-open { width: 100%; }
  .pipeline-name { font-size: 20px; }
  .pipeline-empty { padding: 20px; }
  .add-btn-lg { width: 100%; }
  .sticky-bar { flex-direction: column; align-items: stretch; padding: 8px 0; }
  .workflow { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
  .workflow-steps { flex-wrap: nowrap; }
  .filter { display: flex; }
  .filter-btn { flex: 1; min-height: 40px; }
  .stage { padding: 18px 16px; scroll-margin-top: 124px; }
  .stage-cols { grid-template-columns: 1fr; gap: 18px; }
  .col-manage { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 16px; }
  .stage.single .col-manage { border-top: 0; padding-top: 0; }
  .panel { top: auto; width: 100vw; max-height: 92vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; }
  @keyframes slide-in { from { transform: translateY(24px); opacity: 0; } }
  .panel-form { padding: 18px 16px 24px; }
  .panel-foot { margin: 8px -16px -24px; padding: 12px 16px 16px; }
}

/* PC app links look faded on devices where they can't open (phone, Chromebook) */
.no-pc-apps [data-app] { opacity: 0.55; }
