@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

:root{
  --bg:#0B0D10;
  --panel:#14171C;
  --panel-2:#1B1F26;
  --line:#262B33;
  --text:#E8EAED;
  --muted:#8A93A1;
  --dim:#5A626F;
  --live:#FF4B3E;
  --teal:#34D6C4;
  --amber:#F2B84B;

  /* Activity Log Text Sizes */
  --log-font-name: 18px;
  --log-font-time: 14px;
  --log-font-diff: 18px;
}
*{box-sizing:border-box;}
body{
  margin:0;
  background:
    radial-gradient(ellipse at 20% -10%, #1a1d24 0%, transparent 55%),
    var(--bg);
  color:var(--text);
  font-family:'Inter',system-ui,sans-serif;
  min-height:100vh;
  padding-bottom:60px;
  transition: margin-right 0.3s ease;
}
body.panel-open {
  margin-right: 320px;
}

/* Fix Drag and Drop Flicker */
body.is-dragging .card * {
  pointer-events: none !important;
}

.num{font-family:'Space Grotesk',monospace;font-variant-numeric:tabular-nums;}

header{
  padding:28px 32px 20px;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:16px;
}
.brand{display:flex;align-items:center;gap:12px;}
.brand a{ text-decoration:none; }
.live-dot{
  width:9px;height:9px;border-radius:50%;
  background:var(--live);
  box-shadow:0 0 0 0 rgba(255,75,62,0.6);
  animation:pulse 2s infinite;
}
@keyframes pulse{
  0%{box-shadow:0 0 0 0 rgba(255,75,62,0.55);}
  70%{box-shadow:0 0 0 9px rgba(255,75,62,0);}
  100%{box-shadow:0 0 0 0 rgba(255,75,62,0);}
}
@media (prefers-reduced-motion: reduce){
  .live-dot{animation:none;}
}
h1{
  font-family:'Space Grotesk',sans-serif;
  font-size:20px;
  font-weight:600;
  margin:0;
  letter-spacing:0.02em;
  color:var(--text);
}
h1 span{color:var(--dim); font-weight:400;}
.actions{display:flex; gap:10px; align-items:center; flex-wrap:wrap;}

/* Tabs Bar */
.tabs-bar {
  padding: 16px 32px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.tabs-bar button, .tabs-bar a {
  border-radius: 20px;
  padding: 6px 16px;
}
.tabs-bar a{
  font-family:'Inter',sans-serif; font-size:13px; font-weight:600;
  border:1px solid var(--line); background:var(--panel-2); color:var(--text);
  cursor:pointer; text-decoration:none; display:inline-block;
  transition:border-color .15s, background .15s;
}
.tabs-bar a:hover{border-color:var(--teal); background:#20252d;}
.tabs-bar a.primary{background:var(--teal); color:#04211D; border-color:var(--teal);}
.tabs-bar a.primary:hover{background:#4be2d1;}
.tabs-bar a.ghost{background:transparent; border-color:var(--line);}
.tabs-bar a.ghost:hover{border-color:var(--text); background:rgba(255,255,255,0.05);}

button{
  font-family:'Inter',sans-serif;
  font-size:13px;
  font-weight:600;
  border-radius:7px;
  border:1px solid var(--line);
  background:var(--panel-2);
  color:var(--text);
  padding:9px 16px;
  cursor:pointer;
  transition:border-color .15s, background .15s;
}
button:hover{border-color:var(--teal); background:#20252d;}
button:focus-visible{outline:2px solid var(--teal); outline-offset:2px;}
button.primary{background:var(--teal); color:#04211D; border-color:var(--teal);}
button.primary:hover{background:#4be2d1;}
button.ghost{background:transparent; border-color:var(--line);}
button.ghost:hover{border-color:var(--text); background:rgba(255,255,255,0.05);}
button.danger:hover{border-color:var(--live);}

/* Settings button specific */
.settings-btn { font-size: 16px; padding: 7px 12px; }

main{max-width:1180px; margin:0 auto; padding:26px 32px;}

.empty{
  text-align:center;
  padding:80px 20px;
  color:var(--muted);
}
.empty h2{color:var(--text); font-family:'Space Grotesk',sans-serif; font-weight:600; font-size:19px;}

.grid{
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  gap:18px;
}

@media (max-width: 1200px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .grid { grid-template-columns: 1fr; }
}

.card{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:12px;
  padding:20px;
  position:relative;
  cursor: grab;
  transition: outline 0.15s, background 0.15s;
}
.card:active {
  cursor: grabbing;
}

.card.drag-over {
  outline: 2px dashed var(--teal) !important;
  outline-offset: 2px;
  background: rgba(52, 214, 196, 0.05);
}

.card.selected-for-panel {
  outline: 2px solid var(--teal);
}

/* Milestone Glow Animation */
@keyframes milestoneGlow {
  0% { box-shadow: 0 0 10px 0 var(--teal); border-color: var(--teal); }
  50% { box-shadow: 0 0 25px 5px var(--teal); border-color: #fff; }
  100% { box-shadow: 0 0 10px 0 var(--teal); border-color: var(--teal); }
}
.card.milestone {
  animation: milestoneGlow 1.5s infinite;
  z-index: 10;
}

.card-top{display:flex; gap:12px; align-items:center; margin-bottom:14px;}
.avatar{
  width:48px;height:48px;border-radius:50%;
  background:var(--panel-2); border:1px solid var(--line);
  object-fit:cover; flex-shrink:0;
  cursor: pointer;
}
.avatar:hover {
   opacity: 0.8;
}

.card-title{flex:1; min-width:0;}
.card-title .name{
  font-weight:600; font-size:15px; white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis;
  cursor: pointer;
}
.card-title .name a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
}
.card-title .name a:hover {
  color: var(--teal);
}
.card-title .handle{font-size:12px; color:var(--muted);}
.remove-btn{
  background:none; border:none; color:var(--dim);
  font-size:16px; padding:4px 6px; cursor:pointer;
}
.remove-btn:hover{color:var(--live);}

.sub-row{
  display:flex; align-items:baseline; gap:8px;
  margin-bottom:2px;
}
.sub-count{font-size:30px; font-weight:700;}
.sub-label{font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:0.06em;}
.live-tag{
  display:inline-flex; align-items:center; gap:5px;
  font-size:10px; color:var(--live); text-transform:uppercase;
  letter-spacing:0.08em; font-weight:600;
  margin-bottom:14px;
}

.totals{display:flex; gap:18px; margin-bottom:16px; font-size:12px; color:var(--muted);}
.totals b{color:var(--text); font-size:13px; display:block; font-family:'Space Grotesk',monospace;}

table.windows{width:100%; border-collapse:collapse; font-size:12.5px;}
table.windows th{
  text-align:right; color:var(--dim); font-weight:500;
  padding:4px 0 6px; border-bottom:1px solid var(--line);
  font-size:11px; text-transform:uppercase; letter-spacing:0.04em;
}
table.windows th:first-child{text-align:left;}
table.windows td{
  text-align:right; padding:6px 0; border-bottom:1px solid #1d2128;
}
table.windows td:first-child{text-align:left; color:var(--muted);}
table.windows tr:last-child td{border-bottom:none;}

/* Best Video Section */
.best-video {
  margin-top: 14px;
  padding: 10px;
  background: rgba(52, 214, 196, 0.05);
  border: 1px solid rgba(52, 214, 196, 0.2);
  border-radius: 8px;
}
.best-video-header {
  font-size: 10px;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.best-video-title {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.best-video-title a {
  color: var(--text);
  text-decoration: none;
}
.best-video-title a:hover {
  text-decoration: underline;
}
.best-video-stats {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  gap: 12px;
}
.best-video-stats span {
  font-family: 'Space Grotesk', monospace;
}

/* Card Notes */
.card-notes {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.notes-display {
  font-size: 12px; color: var(--text);
  display: flex; justify-content: space-between; align-items: flex-start;
}
.notes-text {
  white-space: pre-wrap; word-break: break-word; flex:1;
  color: var(--teal);
  font-style: italic;
}
.notes-edit-btn {
  padding: 2px 6px; font-size: 11px; margin-left: 8px; color: var(--dim);
}
.notes-edit-btn:hover { color: var(--teal); }
.notes-input-area {
  display: flex; gap: 6px;
}
.notes-input {
  flex: 1; padding: 6px 8px; border-radius: 4px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-size: 12px; font-family: 'Inter', sans-serif;
}
.notes-input:focus { outline: 1px solid var(--teal); }
.notes-save-btn {
  padding: 6px 10px; font-size: 11px;
}

.card-footer{
  display:flex; justify-content:space-between; align-items:center;
  margin-top:14px; padding-top:12px; border-top:1px solid var(--line);
  font-size:11px; color:var(--dim);
}
.refresh-icon-btn{
  background:none; border:none; color:var(--muted); cursor:pointer; font-size:14px;
  padding:2px 6px;
}
.refresh-icon-btn:hover{color:var(--teal);}

.card.loading .sub-count::after{content:"···"; color:var(--dim);}
.card.error{border-color:#5c2b28;}
.error-msg{color:var(--live); font-size:12px; margin-bottom:10px; line-height:1.4;}

/* Competitors View specific styling */
.comp-row-wrapper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}
@media (max-width: 1200px) { .comp-row-wrapper { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) { .comp-row-wrapper { grid-template-columns: 1fr; } }

.comp-separator {
  width: 100%;
  height: 1px;
  border: none;
  border-bottom: 1px solid #1a1e24;
  margin: 0 0 24px 0;
}

.competitor-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.competitor-item .card {
  width: 100%;
  margin-bottom: 0;
}
.competitor-connector {
  color: var(--dim);
  font-size: 18px;
  line-height: 1;
  user-select: none;
  letter-spacing: 2px;
  opacity: 0.7;
}
.competitor-video-panel {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.comp-vid-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.comp-vid-header {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  color: var(--text);
  margin: 0;
  text-align: center;
  flex: 1;
}
.comp-vid-arrow {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}
.comp-vid-arrow:hover { color: var(--teal); }
.comp-vid-arrow.invisible { visibility: hidden; pointer-events: none; }

.comp-vid-thumb {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--panel-2);
  margin-bottom: 16px;
  border: 1px solid var(--line);
  transition: outline 0.15s;
}
.comp-vid-thumb:hover {
  outline: 2px solid var(--teal);
}
.comp-vid-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.comp-vid-title a {
  color: var(--text);
  text-decoration: none;
}
.comp-vid-title a:hover {
  color: var(--teal);
}
.comp-vid-meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-around;
  text-align: center;
  gap: 6px;
}
.comp-vid-meta span {
  font-family: 'Space Grotesk', monospace;
  color: var(--text);
  font-size: 16px;
  display: block;
  margin-top: 4px;
}

/* Graph Controls & Container */
.graph-header-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.graph-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  flex-wrap: wrap;
  gap: 12px;
}
.graph-toggles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.graph-toggles button {
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 11.5px;
}
.graph-container {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  height: 500px;
  width: 100%;
}

/* modal */
.overlay{
  position:fixed; inset:0; background:rgba(5,6,8,0.72);
  display:flex; align-items:center; justify-content:center;
  z-index:50; padding:20px;
}
.modal{
  background:var(--panel); border:1px solid var(--line); border-radius:12px;
  padding:24px; width:100%; max-width:420px;
  max-height: 90vh; overflow-y: auto;
}
.modal h3{margin:0 0 6px; font-family:'Space Grotesk',sans-serif; font-size:16px;}
.modal p{color:var(--muted); font-size:12.5px; line-height:1.5; margin:0 0 16px;}
.modal label{display:block; font-size:12px; color:var(--muted); margin-bottom:6px;}
.modal input[type="text"], .modal input[type="range"]{
  width:100%; margin-bottom:16px;
}
.modal input[type="text"] {
  padding:10px 12px; border-radius:7px; border:1px solid var(--line);
  background:var(--panel-2); color:var(--text); font-size:13px;
  font-family:'Inter',sans-serif;
}
.modal input[type="text"]:focus{outline:2px solid var(--teal); outline-offset:1px;}
.modal-actions{display:flex; justify-content:flex-end; gap:10px;}

.settings-group {
  background: var(--panel-2);
  padding: 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
}
.settings-group h4 {
  margin: 0 0 12px 0; font-size: 13px; color: var(--text); font-family: 'Space Grotesk';
}
.checkbox-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 12px; color: var(--muted);
}
.checkbox-grid label { display: flex; align-items: center; gap: 6px; cursor: pointer; margin:0; }

.slider-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}

/* Shared Custom Range Slider styling for matching UI */
input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}
input[type=range]:focus { outline: none; }

input[type=range]::-webkit-slider-runnable-track {
  width: 100%; height: 6px; cursor: pointer;
  background: var(--track-bg, var(--line));
  border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
  height: 16px; width: 16px; border-radius: 50%;
  background: var(--teal); cursor: pointer;
  -webkit-appearance: none; margin-top: -5px;
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
}

input[type=range]::-moz-range-track {
  width: 100%; height: 6px; cursor: pointer;
  background: var(--track-bg, var(--line));
  border-radius: 3px;
}
input[type=range]::-moz-range-thumb {
  height: 16px; width: 16px; border-radius: 50%;
  background: var(--teal); cursor: pointer;
  border: none;
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
}

.footnote{
  max-width:1180px; margin:26px auto 0; padding:0 32px;
  color:var(--dim); font-size:11.5px; line-height:1.6;
}

/* auto-refresh toggle */
.autorefresh-row{
  display:flex; align-items:center; justify-content:space-between;
  margin-top:10px; padding-top:10px; border-top:1px solid var(--line);
  font-size:11.5px; color:var(--muted);
}
.switch{
  position:relative; width:32px; height:18px; flex-shrink:0;
}
.switch input{opacity:0; width:0; height:0; position:absolute;}
.switch .track{
  position:absolute; inset:0; background:var(--panel-2); border:1px solid var(--line);
  border-radius:20px; transition:background .15s, border-color .15s; cursor:pointer;
}
.switch .track::before{
  content:''; position:absolute; width:12px; height:12px; left:2px; top:2px;
  background:var(--dim); border-radius:50%; transition:transform .15s, background .15s;
}
.switch input:checked + .track{background:rgba(52,214,196,0.15); border-color:var(--teal);}
.switch input:checked + .track::before{transform:translateX(14px); background:var(--teal);}
.switch input:focus-visible + .track{outline:2px solid var(--teal); outline-offset:2px;}

/* Activity Log */
.sub-log-wrapper {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 320px;
  height: 350px;
  background: rgba(20, 23, 28, 0.95);
  border: 1px solid var(--line);
  border-radius: 8px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);

  resize: both;
  overflow: hidden;
  min-width: 240px;
  min-height: 150px;
}
.sub-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: grab;
}
.sub-log-header:active {
  cursor: grabbing;
}
.sub-log-container {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.log-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--panel-2);
  border-radius: 6px;
  font-size: var(--log-font-name);
  flex-shrink: 0;
  gap: 12px;
}
.log-entry > div:first-child {
  flex: 1;
  min-width: 0;
}
.log-entry .log-name {
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}
.log-entry .log-time { color: var(--dim); font-size: var(--log-font-time); margin-top: 4px;}
.log-entry .log-diff {
  font-weight: 600;
  font-family: 'Space Grotesk', monospace;
  font-size: var(--log-font-diff);
  flex-shrink: 0;
}
.log-entry .log-diff.gain { color: var(--teal); }
.log-entry .log-diff.loss { color: var(--live); }

/* Side Panel */
.side-panel {
  position: fixed;
  top: 0;
  right: -320px;
  width: 320px;
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--line);
  z-index: 40;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 15px rgba(0,0,0,0.5);
}
.side-panel.open {
  right: 0;
}
.side-panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.side-panel-header h2 {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  color: var(--text);
}
.side-panel-close {
  background: none; border: none; color: var(--muted);
  font-size: 20px; cursor: pointer; padding: 0;
}
.side-panel-close:hover { color: var(--live); }

.side-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Mini Card for Side Panel */
.mini-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  position: relative;
}
.mini-card .remove-mini {
  position: absolute;
  top: 8px; right: 8px;
  background: none; border: none; color: var(--dim); cursor: pointer;
}
.mini-card .remove-mini:hover { color: var(--live); }
.mini-card-top {
  display: flex; gap: 10px; align-items: center; margin-bottom: 10px;
}
.mini-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
}
.mini-name {
  font-weight: 600; font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px;
}
.mini-name a { color: var(--text); text-decoration: none; transition: color 0.15s; }
.mini-name a:hover { color: var(--teal); }

.mini-subs {
  font-size: 20px; font-weight: 700; color: var(--text); font-family: 'Space Grotesk', monospace;
}
.mini-sub-label {
  font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em;
}

/* API Status Indicator */
.api-status {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: rgba(20, 23, 28, 0.95);
  border: 1px solid var(--teal);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--teal);
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  backdrop-filter: blur(8px);
}

/* ============================================================
   Search page
   ============================================================ */

.search-panel{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:14px;
  padding:18px;
  margin-bottom:18px;
}
.search-row{
  display:flex;
  gap:10px;
  align-items:flex-start;
  margin-bottom:10px;
}
.search-row:last-of-type{margin-bottom:0;}

.search-field{
  flex:1;
  width:100%;
  padding:11px 14px;
  border-radius:9px;
  border:1px solid var(--line);
  background:var(--panel-2);
  color:var(--text);
  font-family:'Inter',sans-serif;
  font-size:14px;
  outline:none;
}
.search-field::placeholder{color:var(--dim);}
.search-field:focus{outline:2px solid var(--teal); outline-offset:1px;}

.search-go{
  padding:11px 22px;
  white-space:nowrap;
  align-self:flex-start;
}
#searchBtn.needs-rerun{
  animation:searchPulse 1.6s ease-in-out infinite;
}
@keyframes searchPulse{
  0%,100%{box-shadow:0 0 0 0 rgba(52,214,196,0.5);}
  50%{box-shadow:0 0 0 6px rgba(52,214,196,0);}
}
@media (prefers-reduced-motion: reduce){
  #searchBtn.needs-rerun{animation:none;}
}

/* Tag chips */
.tag-field{
  flex:1;
  min-width:0;
  border:1px solid var(--line);
  background:var(--panel-2);
  border-radius:9px;
  padding:6px;
}
.tag-field .tag-input{
  border:none;
  background:transparent;
  padding:5px 8px;
  font-size:13px;
}
.tag-field .tag-input:focus{outline:none;}
.tag-field:focus-within{outline:2px solid var(--teal); outline-offset:1px;}
.tag-chips{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  padding:2px 2px 6px;
}
.tag-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  background:rgba(52,214,196,0.12);
  border:1px solid rgba(52,214,196,0.4);
  color:var(--teal);
  border-radius:20px;
  padding:3px 6px 3px 11px;
  font-size:12px;
  font-weight:600;
  max-width:100%;
}
.tag-chip > span{overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.tag-chip.exclude{
  background:rgba(255,75,62,0.12);
  border-color:rgba(255,75,62,0.4);
  color:var(--live);
}
.tag-chip-x{
  background:none;
  border:none;
  color:inherit;
  font-size:11px;
  padding:0 4px;
  cursor:pointer;
  opacity:0.7;
  line-height:1;
}
.tag-chip-x:hover{opacity:1; background:none; border:none;}

/* Filters */
.filters-panel{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:14px;
  margin-top:16px;
  padding-top:16px;
  border-top:1px solid var(--line);
}
.filter-cell{display:flex; flex-direction:column; gap:6px;}
.filter-cell-wide{grid-column:1 / -1;}
.filter-cell label{
  font-size:11px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:0.06em;
  font-weight:600;
}
.filter-cell select{
  width:100%;
  padding:9px 12px;
  border-radius:7px;
  border:1px solid var(--line);
  background:var(--panel-2);
  color:var(--text);
  font-family:'Inter',sans-serif;
  font-size:13px;
  outline:none;
  cursor:pointer;
}
.filter-cell select:focus{outline:2px solid var(--teal); outline-offset:1px;}
.filter-cell.filter-cell-wide{
  flex-direction:row;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.filter-check{
  display:flex !important;
  align-items:center;
  gap:8px;
  cursor:pointer;
  font-size:12.5px;
  color:var(--text);
  text-transform:none !important;
  letter-spacing:normal !important;
  font-weight:500 !important;
}
.filter-note{
  font-size:11.5px;
  color:var(--dim);
  line-height:1.6;
  border-top:1px solid var(--line);
  padding-top:12px;
}
.filters-dirty{
  margin-top:14px;
  padding:9px 12px;
  border-radius:8px;
  background:rgba(242,184,75,0.1);
  border:1px solid rgba(242,184,75,0.35);
  color:var(--amber);
  font-size:12.5px;
}

/* Quota meter */
.quota-meter{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:12px;
  padding:14px 16px;
  margin-bottom:18px;
}
.quota-meter-top{
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-size:12px;
  color:var(--muted);
  margin-bottom:8px;
  font-weight:600;
}
.quota-bar{
  height:6px;
  border-radius:3px;
  background:var(--line);
  overflow:hidden;
}
.quota-bar-fill{
  height:100%;
  border-radius:3px;
  transition:width .3s ease;
}
.quota-meter-note{
  margin-top:9px;
  font-size:11px;
  color:var(--dim);
  line-height:1.55;
}

/* Status line */
.search-status{
  padding:10px 14px;
  border-radius:9px;
  font-size:12.5px;
  margin-bottom:16px;
  border:1px solid var(--line);
  background:var(--panel-2);
  color:var(--muted);
  line-height:1.5;
}
.search-status.ok{border-color:rgba(52,214,196,0.35); color:var(--text);}
.search-status.busy{border-color:rgba(242,184,75,0.35); color:var(--amber);}
.search-status.error{border-color:#5c2b28; color:var(--live);}

/* Results */
#searchResults{display:flex; flex-direction:column; gap:12px;}
.search-result{
  display:flex;
  align-items:flex-start;
  gap:14px;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px;
  transition:border-color .15s;
}
.search-result:hover{border-color:#37404d;}
.search-rank{
  font-size:13px;
  color:var(--dim);
  font-weight:700;
  min-width:22px;
  text-align:right;
  padding-top:4px;
  flex-shrink:0;
}
.search-thumb{
  position:relative;
  flex-shrink:0;
  width:168px;
  aspect-ratio:16/9;
  border-radius:8px;
  overflow:hidden;
  background:var(--panel-2);
  display:block;
}
.search-thumb img{width:100%; height:100%; object-fit:cover; display:block;}
.search-thumb:hover img{opacity:0.85;}
.search-dur{
  position:absolute;
  right:5px;
  bottom:5px;
  background:rgba(0,0,0,0.82);
  color:#fff;
  font-size:11px;
  font-weight:600;
  padding:1px 5px;
  border-radius:4px;
}
.search-body{flex:1; min-width:0;}
.search-title{
  font-size:14px;
  font-weight:600;
  line-height:1.4;
  margin-bottom:5px;
}
.search-title a{color:var(--text); text-decoration:none;}
.search-title a:hover{color:var(--teal);}
.search-channel{font-size:12.5px; margin-bottom:9px;}
.search-channel a{color:var(--muted); text-decoration:none;}
.search-channel a:hover{color:var(--teal);}
.search-meta{
  display:flex;
  flex-wrap:wrap;
  gap:6px 14px;
  align-items:center;
  font-size:11.5px;
  color:var(--muted);
}
.search-meta .badge{
  font-size:10px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.05em;
  padding:2px 7px;
  border-radius:20px;
  border:1px solid var(--line);
}
.search-meta .badge.short{color:var(--amber); border-color:rgba(242,184,75,0.4);}
.search-meta .badge.long{color:var(--teal); border-color:rgba(52,214,196,0.4);}
.search-meta .badge.live{color:var(--live); border-color:rgba(255,75,62,0.4);}
/* Classified by duration alone because orientation wasn't available. */
.search-meta .badge.guessed{border-style:dashed; opacity:0.75;}
.search-actions{flex-shrink:0; align-self:center;}
.search-track-btn{padding:7px 12px; font-size:12px; white-space:nowrap;}
.search-track-btn:disabled{opacity:0.45; cursor:default;}
.search-track-btn:disabled:hover{border-color:var(--line); background:transparent;}

/* Show more */
.show-more-wrap{text-align:center; padding:22px 0 8px;}
.show-more-wrap button{padding:11px 28px;}
.show-more-note{
  margin-top:9px;
  font-size:11.5px;
  color:var(--dim);
}

@media (max-width: 860px){
  .filters-panel{grid-template-columns:repeat(2, 1fr);}
}
@media (max-width: 640px){
  .filters-panel{grid-template-columns:1fr;}
  .filter-cell.filter-cell-wide{flex-direction:column; align-items:flex-start;}
  .search-row{flex-wrap:wrap;}
  .search-go{width:100%;}
  .search-result{flex-wrap:wrap;}
  .search-rank{display:none;}
  .search-thumb{width:100%;}
  .search-actions{width:100%;}
  .search-track-btn{width:100%;}
}


/* ============================================================
   Shared quota bar (all four Channel Deck tabs)
   ============================================================ */

.quota-key-chips{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-top:10px;
}
.quota-key-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:11px;
  color:var(--muted);
  background:var(--panel-2);
  border:1px solid var(--line);
  border-radius:20px;
  padding:3px 10px;
}
.quota-key-chip.active{
  border-color:rgba(52,214,196,0.45);
  color:var(--text);
}
.quota-key-dot{
  width:6px;
  height:6px;
  border-radius:50%;
  flex-shrink:0;
}
.quota-key-chip b{font-weight:700;}

/* Per-key percentage in the API keys modal */
.api-key-pct{
  font-size:12px;
  font-weight:700;
  min-width:38px;
  text-align:right;
  flex-shrink:0;
}

/* Per-tab API key assignment in Settings */
.page-key-grid{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.page-key-row{
  display:flex;
  align-items:center;
  gap:10px;
}
.page-key-label{
  font-size:12.5px;
  color:var(--text);
  width:110px;
  flex-shrink:0;
}
.page-key-select{
  flex:1;
  min-width:0;
  padding:7px 10px;
  border-radius:7px;
  border:1px solid var(--line);
  background:var(--panel-2);
  color:var(--text);
  font-family:'Inter',sans-serif;
  font-size:12.5px;
  outline:none;
  cursor:pointer;
}
.page-key-select:focus{outline:2px solid var(--teal); outline-offset:1px;}
.settings-hint{
  margin-top:10px;
  font-size:11px;
  color:var(--dim);
  line-height:1.6;
}

/* ============================================================
   Search: Tags / Creators mode switch
   ============================================================ */

.mode-switch{
  display:inline-flex;
  background:var(--panel-2);
  border:1px solid var(--line);
  border-radius:9px;
  padding:3px;
  gap:3px;
}
.mode-opt{
  border:none;
  background:transparent;
  color:var(--muted);
  font-size:12.5px;
  font-weight:600;
  padding:6px 16px;
  border-radius:7px;
  cursor:pointer;
}
.mode-opt:hover{background:rgba(255,255,255,0.05); border:none; color:var(--text);}
.mode-opt.active{background:var(--teal); color:#04211D;}
.mode-opt.active:hover{background:#4be2d1;}

.mode-hint{
  margin-top:10px;
  font-size:11.5px;
  color:var(--dim);
  line-height:1.6;
}
.mode-hint b{color:var(--muted);}

.tag-field.creators-mode{border-color:rgba(155,89,182,0.45);}
.tag-field.creators-mode:focus-within{outline-color:#9b59b6;}

.tag-chip.creator{
  background:rgba(155,89,182,0.14);
  border-color:rgba(155,89,182,0.45);
  color:#c48ede;
}
/* A bare name has no cheap lookup, so it costs ~100 units to resolve. */
.tag-chip.creator.pricey{
  border-style:dashed;
  background:rgba(242,184,75,0.12);
  border-color:rgba(242,184,75,0.45);
  color:var(--amber);
}

/* Derived style profile */
.creator-profile{
  margin-top:14px;
  padding:12px 14px;
  border-radius:10px;
  background:rgba(155,89,182,0.07);
  border:1px solid rgba(155,89,182,0.3);
}
.creator-profile-head{
  font-size:12.5px;
  font-weight:600;
  color:var(--text);
  margin-bottom:9px;
}
.creator-profile-sub{
  font-weight:400;
  color:var(--dim);
  font-size:11px;
  margin-left:8px;
}
.creator-profile-terms{display:flex; flex-wrap:wrap; gap:6px;}
.profile-term{
  font-size:11.5px;
  font-weight:600;
  color:#c48ede;
  background:rgba(155,89,182,0.15);
  border:1px solid rgba(155,89,182,0.35);
  border-radius:20px;
  padding:3px 11px;
}
.creator-profile-note{
  margin-top:10px;
  font-size:11px;
  color:var(--dim);
  line-height:1.55;
}
.creator-profile-warn{
  margin-top:10px;
  padding:8px 11px;
  border-radius:7px;
  background:rgba(242,184,75,0.1);
  border:1px solid rgba(242,184,75,0.35);
  color:var(--amber);
  font-size:11.5px;
  line-height:1.55;
}

/* Four-way mode switch wraps on narrow screens */
.mode-switch{flex-wrap:wrap;}
.mode-opt{padding:6px 13px;}
.search-action-row{justify-content:flex-end;}
.search-action-row .search-go{min-width:130px;}
.profile-term.related{
  color:var(--teal);
  background:rgba(52,214,196,0.13);
  border-color:rgba(52,214,196,0.38);
}
#relatedTags{
  background:rgba(52,214,196,0.06);
  border-color:rgba(52,214,196,0.28);
}
@media (max-width: 640px){
  .mode-switch{width:100%;}
  .mode-opt{flex:1; min-width:calc(50% - 3px); padding:7px 8px; font-size:12px;}
  .search-action-row .search-go{width:100%;}
}
