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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --text: #f0f0f0;
  --muted: #888;
  --accent: #e1306c;
  --green: #38d9a9;
  --red: #ff6b6b;
  --yellow: #ffd43b;
  --blue: #74c0fc;
  --radius: 14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---- Header ---- */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px 0;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
h1 { font-size: 1.3rem; font-weight: 700; }
.stats { display: flex; gap: 16px; font-size: 0.85rem; color: var(--muted); }
.stats span b { color: var(--text); }

/* ---- Brand tabs ---- */
.brand-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 0 8px;
  flex-wrap: nowrap;
}
.brand-tab {
  padding: 7px 12px;
  border-radius: 20px;
  border: 2px solid #666;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  min-height: 36px;
  flex: 1;
  text-align: center;
}
.brand-tab:hover { color: var(--text); border-color: var(--muted); }
/* Active brand tabs — tydelig farve + fed kant */
.brand-tab.active[data-account="lastobject"]     { background: #1a3a2a; color: #6fcf97; border-color: #6fcf97; border-width: 2px; box-shadow: 0 0 8px rgba(111,207,151,0.3); }
.brand-tab.active[data-account="better-objects"] { background: #3a1a1a; color: #f87171; border-color: #f87171; border-width: 2px; box-shadow: 0 0 8px rgba(248,113,113,0.3); }
.brand-tab.active[data-account="linkedin"]       { background: #1a2535; color: #60a5fa; border-color: #60a5fa; border-width: 2px; box-shadow: 0 0 8px rgba(96,165,250,0.3); }

.tabs {
  display: flex;
  gap: 6px;
  padding: 8px 0 4px;
}
.tab {
  flex: 1;
  padding: 7px 10px;
  border: 2px solid #666;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
  border-radius: 20px;
  transition: all 0.15s;
  white-space: nowrap;
  min-height: 36px;
  text-align: center;
  font-weight: 600;
}
.tab:hover { color: var(--text); border-color: var(--muted); }
.tab.active { color: var(--text); background: var(--surface2); border-color: var(--text); font-weight: 600; }
.tab-add { color: var(--accent) !important; font-weight: 600; margin-left: auto; }

/* ---- Feed ---- */
main { padding: 24px; }
.feed {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 20px;
  align-items: start;
}

/* ---- Card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, box-shadow 0.15s;
  width: 100%;
  min-width: 0;
}

.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }

.card-image {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--muted);
  overflow: hidden;
  border-radius: 8px;
}
/* Format-aware aspect ratios */
.card-image[data-format="feed-square"]   { aspect-ratio: 1/1; }
.card-image[data-format="carousel"]      { aspect-ratio: 1/1; }
.card-image[data-format="feed-portrait"] { aspect-ratio: 4/5; }
.card-image[data-format="reel"]          { aspect-ratio: 9/16; }
.card-image[data-format="story"]         { aspect-ratio: 9/16; }

.card-image img, .card-image video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-blacklist {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.6);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 14px;
  cursor: pointer;
  display: none;
  z-index: 10;
  line-height: 28px;
  text-align: center;
  padding: 0;
}
.card-image:hover .btn-blacklist { display: block; }

.card-body { padding: 16px; flex: 1; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-instagram { background: linear-gradient(135deg, #833ab4, #e1306c); color: #fff; }
.badge-linkedin { background: #0A66C2; color: #fff; }
.badge-tiktok { background: #010101; color: #fff; border: 1px solid #444; }
.badge-facebook { background: #1877F2; color: #fff; }
.badge-account { background: var(--surface2); color: var(--muted); }

/* Format badges */
.badge-format { font-size: 0.68rem; padding: 2px 7px; }
.badge-fmt-reel         { background: #3a1a2a; color: #f48fb1; border: 1px solid #7b2d4a; }
.badge-fmt-story        { background: #3a1a2a; color: #f48fb1; border: 1px solid #7b2d4a; }
.badge-fmt-feed-portrait { background: #1a2a3a; color: #81d4fa; border: 1px solid #1565c0; }
.badge-fmt-feed-square  { background: #2a2a1a; color: #fff59d; border: 1px solid #7b7b1a; }
.badge-fmt-carousel     { background: #1a3a2a; color: #a5d6a7; border: 1px solid #2e7d32; }

/* Brand badges */
.badge-brand-lastobject     { background: #1a3a2a; color: #6fcf97; font-size: 0.75rem; padding: 2px 5px; }
.badge-brand-better-objects { background: #1a1a3a; color: #74c0fc; font-size: 0.75rem; padding: 2px 5px; }

/* Stats brand label */
.stats-brand { color: var(--accent); font-weight: 600; margin-right: 4px; }

.card-schedule {
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: auto;
}

.card-caption {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}
.card-hashtags {
  font-size: 0.78rem;
  color: var(--blue);
  margin-bottom: 8px;
  word-break: break-word;
}
.card-notes {
  font-size: 0.75rem;
  color: var(--yellow);
  margin-top: 6px;
}

/* Stats row */
.card-stats-row {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.card-stats-row span { white-space: nowrap; }

.card-actions {
  display: flex;
  gap: 6px;
  padding: 10px 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}
.card-actions button {
  flex: 1;
  padding: 8px 2px;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.btn-approve { border-color: var(--green) !important; color: var(--green) !important; }
.btn-approve:hover { background: var(--green) !important; color: #000 !important; }
.btn-reject { border-color: var(--red) !important; color: var(--red) !important; }
.btn-reject:hover { background: var(--red) !important; color: #fff !important; }
.btn-edit:hover { background: var(--surface2); }
.btn-delete:hover { background: var(--red); color: #fff; border-color: var(--red) !important; }
.btn-posted { border-color: var(--muted) !important; color: var(--muted) !important; }
.btn-posted:hover { background: var(--surface2) !important; }
.btn-publish { border-color: #E1306C !important; color: #E1306C !important; font-weight: 600 !important; }
.btn-publish:hover { background: #E1306C !important; color: #fff !important; }
.btn-reschedule { border-color: var(--yellow) !important; color: var(--yellow) !important; }
.btn-reschedule:hover { background: var(--yellow) !important; color: #000 !important; }
.btn-stats { border-color: var(--blue) !important; color: var(--blue) !important; }
.btn-stats:hover { background: var(--blue) !important; color: #000 !important; }

/* Status indicators on cards */
.card[data-status="approved"] { border-top: 3px solid var(--green); }
.card[data-status="rejected"] { border-top: 3px solid var(--red); opacity: 0.7; }
.card[data-status="posted"] { border-top: 3px solid var(--muted); opacity: 0.6; }

.empty { grid-column: 1/-1; text-align: center; color: var(--muted); padding: 60px 0; font-size: 1.1rem; }

/* ---- Comments ---- */
.card-comments-section {
  border-top: 1px solid var(--border);
}
.comments-toggle {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 8px 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
}
.comments-toggle:hover { color: var(--text); background: var(--surface2); }
.comment-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
}
.comments-body {
  padding: 8px 16px 12px;
  background: var(--surface2);
}
.comments-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.comment-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.8rem;
  padding: 4px 0;
}
.comment-text { flex: 1; color: var(--text); word-break: break-word; }
.comment-meta { font-size: 0.7rem; color: var(--muted); white-space: nowrap; }
.comment-del {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px 4px;
  border-radius: 4px;
}
.comment-del:hover { color: var(--red); }
.no-comments { color: var(--muted); font-size: 0.78rem; padding: 4px 0; }
.comment-input-row {
  display: flex;
  gap: 6px;
}
.comment-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 0.82rem;
  outline: none;
  min-height: 36px;
}
.comment-input:focus { border-color: var(--accent); }
.btn-comment-add {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.82rem;
  min-height: 36px;
}

/* ---- Modal ---- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box h2 { margin-bottom: 20px; font-size: 1.1rem; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 14px;
}
input, textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }

.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

#img-preview { margin-top: 8px; }
#img-preview img { max-width: 100%; max-height: 200px; border-radius: 8px; object-fit: cover; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.form-actions button {
  padding: 10px 22px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 10px 22px;
  border: none;
  min-height: 44px;
}
.btn-primary:hover { filter: brightness(1.1); }

/* ---- Calendar ---- */
#calendar-view { padding: 0; }
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px 24px 12px;
}
.calendar-nav button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  cursor: pointer;
}
.calendar-nav h2 { font-size: 1.1rem; min-width: 180px; text-align: center; }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 0 24px;
  margin-bottom: 4px;
}
.calendar-weekdays > div {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  padding: 4px 0;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 0 24px 24px;
}
.cal-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.12s;
}
.cal-cell:not(.cal-empty):hover { background: var(--surface2); }
.cal-empty { background: transparent; border-color: transparent; }
.cal-today { border-color: var(--accent); }
.cal-today .cal-day-num { color: var(--accent); font-weight: 700; }
.cal-day-num { font-size: 0.82rem; color: var(--muted); }
.cal-dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.cal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.cal-dot-pending  { background: var(--yellow); }
.cal-dot-approved { background: var(--green); }
.cal-dot-rejected { background: var(--red); }
.cal-dot-posted   { background: var(--muted); }
.cal-more { font-size: 0.65rem; color: var(--muted); }

/* Calendar day posts panel */
.cal-day-posts {
  margin: 0 24px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-day-posts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.cal-day-posts-header h3 { font-size: 0.95rem; }
.cal-day-posts-header button {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
}
#cal-day-feed {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ---- Media library ---- */
#media-view { padding: 24px; }
.media-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.media-toolbar h2 { font-size: 1.1rem; }
.media-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  min-height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  margin-bottom: 0;
}
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.12s;
}
.media-card:hover { transform: translateY(-2px); }
.media-thumb-wrap {
  aspect-ratio: 1/1;
  background: var(--surface2);
  overflow: hidden;
}
.media-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-info {
  padding: 8px 10px 4px;
}
.media-filename {
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-size { font-size: 0.68rem; color: var(--muted); }
.media-actions {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}
.media-actions button {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  padding: 6px 4px;
  cursor: pointer;
  min-height: 36px;
}
.media-actions button:hover { color: var(--text); background: var(--surface2); }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.88rem;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 999;
  pointer-events: none;
}
.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Hidden utility ---- */
.hidden { display: none !important; }

/* ---- Crop modal ---- */
.crop-modal-box {
  max-width: 880px;
  width: 100%;
}
.crop-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 16px;
}
.crop-panel-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 8px;
  text-align: center;
}
.crop-left, .crop-right {
  display: flex;
  flex-direction: column;
  align-items: center;
}
/* Editor (left side) */
.crop-container {
  position: relative;
  width: 100%;
  height: 400px;
  background: #111;
  overflow: hidden;
  cursor: grab;
  border-radius: 8px;
  border: 1px solid var(--border);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.crop-container.dragging { cursor: grabbing; }
.crop-img {
  position: absolute;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  will-change: transform;
}
.crop-frame {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 2;
}
/* Preview (right side) */
.crop-preview-box {
  width: 100%;
  max-height: 400px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #111;
}
.crop-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Footer */
.crop-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}
.crop-coords {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 120px;
}
.crop-footer-btns {
  display: flex;
  gap: 10px;
}
.crop-footer-btns button {
  padding: 9px 18px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.88rem;
}
.crop-footer-btns button:hover { background: var(--surface2); }
@media (max-width: 600px) {
  .crop-layout { grid-template-columns: 1fr; }
  .crop-container { height: 280px; }
  .crop-preview-box { max-height: 260px; }
  .crop-modal-box { padding: 16px; }
}

/* ============================
   MOBILE RESPONSIVE (< 600px)
   ============================ */
@media (max-width: 600px) {
  header { padding: 12px 16px 0; }
  .header-inner { flex-wrap: wrap; gap: 8px; }
  h1 { font-size: 1.1rem; }
  .stats { font-size: 0.78rem; gap: 10px; flex-wrap: wrap; }

  main { padding: 16px; }

  /* Single column feed */
  .feed {
    grid-template-columns: 1fr;
  }

  /* Calendar */
  .calendar-grid, .calendar-weekdays {
    padding: 0 8px;
  }
  .cal-cell { min-height: 50px; padding: 4px; }
  .cal-day-num { font-size: 0.7rem; }
  .calendar-nav { padding: 12px 8px 8px; }
  #cal-day-feed {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  /* Media grid */
  #media-view { padding: 16px; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

  /* Modals: full screen on mobile */
  .modal { padding: 0; align-items: flex-end; }
  .modal-box {
    max-width: 100%;
    width: 100%;
    max-height: 95vh;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 20px 16px;
  }

  /* Larger touch targets */
  .tab { min-height: 44px; padding: 8px 14px; font-size: 0.82rem; }
  .card-actions button { min-height: 44px; }
  .form-actions button { min-height: 44px; }
  .btn-primary { min-height: 44px; }
  .comment-input { min-height: 44px; }
  .btn-comment-add { min-height: 44px; }

  /* Two-col forms collapse on mobile */
  .form-row.two-col { grid-template-columns: 1fr; }

  /* Calendar dots smaller */
  .cal-dot { width: 6px; height: 6px; }
}

/* ---- AI Generate Section ---- */
.ai-generate-section {
  margin-bottom: 24px;
}
.ai-generate-box {
  background: linear-gradient(135deg, var(--surface) 0%, #1e1a2e 100%);
  border: 1px solid #4a3f6b;
  border-radius: var(--radius);
  padding: 20px;
}
.ai-generate-box h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: #c084fc;
}
.ai-generate-form {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr 1fr auto;
  gap: 10px;
  align-items: end;
}
.ai-generate-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}
.ai-generate-form select,
.ai-generate-form input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.85rem;
}
.btn-ai {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.btn-ai:hover { opacity: 0.85; }
.btn-ai:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Card top: meta + tools + image grouped with border ---- */
.card-top {
  border: 2px solid #4a3f6b;
  border-radius: 8px;
  margin: 10px 10px 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.card-top .card-meta {
  padding: 8px 10px 4px;
  border-bottom: 1px solid #4a3f6b;
  background: #1a1528;
}
.card-top .card-image {
  margin: 0;
}

/* ---- AI inline card buttons ---- */
.card-ai-actions {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  background: #1a1528;
  border-bottom: 1px solid #4a3f6b;
}
.btn-ai-inline {
  background: #2a2040;
  border: 1px solid #4a3f6b;
  color: #c084fc;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-ai-inline:hover { background: #3a2f5c; }
.btn-ai-inline:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-apply-note {
  background: #1a2a20;
  border: 1px solid #2d5a3d;
  color: #6fcf97;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-apply-note:hover { background: #223a2d; }

.apply-note-row {
  padding: 8px 0 0;
}
.apply-note-row .btn-ai-inline {
  width: 100%;
}

@media (max-width: 700px) {
  .ai-generate-form {
    grid-template-columns: 1fr 1fr;
  }
  .ai-generate-form label:nth-child(3) {
    grid-column: span 2;
  }
  .ai-generate-form label:nth-child(4) {
    grid-column: span 2;
  }
  .btn-ai {
    grid-column: span 2;
    width: 100%;
  }
}

/* ---- Platform checkboxes in generate form ---- */
.ai-platform-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.ai-platform-label {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}
.gen-platform-check {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  margin-bottom: 0;
}
.gen-platform-check input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ---- Per-platform loading status ---- */
.gen-platform-status {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.gen-platform-loading {
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
}

/* ---- Concept group (multi-platform posts) ---- */
/* ---- Carousel thumbnail strip ---- */
.carousel-strip {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: #0f0d1a;
  overflow-x: auto;
  border-top: 1px solid #4a3f6b;
}
.carousel-thumb {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
}
.carousel-thumb {
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s, border-color 0.15s;
}
.carousel-thumb.active {
  opacity: 1;
}
.carousel-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 4px;
  border: 2px solid transparent;
}
.carousel-thumb.active img {
  border-color: #c084fc;
}
.carousel-thumb:hover { opacity: 0.85; }

/* Concept group colours — top border on cards that share a concept */
.concept-color-0 { border-top: 3px solid #c084fc; }
.concept-color-1 { border-top: 3px solid #60a5fa; }
.concept-color-2 { border-top: 3px solid #34d399; }
.concept-color-3 { border-top: 3px solid #fb923c; }
.concept-color-4 { border-top: 3px solid #f472b6; }
.concept-color-5 { border-top: 3px solid #facc15; }

.concept-group {
  /* grid-column set via JS (span N) */
  background: var(--surface);
  border: 1px solid #4a3f6b;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 4px;
}
.concept-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #c084fc;
  background: linear-gradient(135deg, var(--surface) 0%, #1e1a2e 100%);
  border-bottom: 1px solid #4a3f6b;
  flex-wrap: wrap;
}
.btn-approve-all {
  margin-left: auto;
  padding: 6px 14px;
  background: var(--green);
  color: #000;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-approve-all:hover { opacity: 0.85; }
.btn-approve-all:disabled { opacity: 0.5; cursor: default; }

.concept-platform-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}
.concept-group-cards {
  display: flex;
  flex-direction: row;
  gap: 0;
  padding: 0;
  background: var(--bg);
  align-items: flex-start;
}
/* Cards inside a group fill their share of the span */
.concept-group-cards .card {
  border-radius: 8px;
  flex: 1;
  min-width: 0;
  width: auto;
}

/* ============================
   WEEK CALENDAR VIEW
   ============================ */

/* Navigation bar */
.week-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px 10px;
  flex-wrap: wrap;
}
.week-nav button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 0.88rem;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
  transition: background 0.12s;
}
.week-nav button:hover { background: var(--border); }
#cal-today {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
#cal-today:hover { background: var(--accent); color: #fff; }
#cal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-left: 8px;
  white-space: nowrap;
}

/* Volume bar chart */
.week-volume {
  display: flex;
  padding: 6px 24px 0;
  height: 52px;
  align-items: flex-end;
  gap: 0;
}
.week-vol-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 2px;
}
.week-vol-label {
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1;
  min-height: 12px;
}
.week-vol-bar {
  width: 55%;
  max-width: 32px;
  min-height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  opacity: 0.55;
  transition: height 0.25s ease;
}
.vol-today .week-vol-bar {
  background: var(--green);
  opacity: 0.85;
}
.vol-today .week-vol-label { color: var(--green); font-weight: 600; }

/* Week grid container */
.week-grid {
  display: flex;
  gap: 0;
  padding: 0 24px 24px;
  min-height: 600px;
  overflow-x: auto;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  -webkit-overflow-scrolling: touch;
}

/* Day column */
.week-col {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}
.week-col:last-child { border-right: none; }
.week-col-today {
  background: rgba(225, 48, 108, 0.04);
}

/* Column header */
.week-col-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px 6px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  gap: 3px;
}
.week-col-today .week-col-header {
  background: #130a0d;
}
.week-col-dayname {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.week-col-datenum {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.week-date-today {
  color: #fff;
  background: var(--accent);
}

/* Posts scroll area */
.week-col-posts {
  flex: 1;
  padding: 6px 5px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}
.week-empty-day { min-height: 40px; }

/* Mini post card */
.week-post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 6px;
  padding: 6px 7px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  overflow: hidden;
}
.week-post:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.week-post.status-pending  { border-left-color: var(--yellow); }
.week-post.status-approved { border-left-color: var(--green); }
.week-post.status-rejected { border-left-color: var(--red); opacity: 0.7; }
.week-post.status-posted   { border-left-color: var(--muted); opacity: 0.6; }

.week-post-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 4px;
}
.week-post-time {
  font-size: 0.68rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.week-badge {
  font-size: 0.58rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.wp-instagram { background: linear-gradient(135deg, #833ab4, #e1306c); color: #fff; }
.wp-tiktok    { background: #010101; color: #fff; border: 1px solid #555; }
.wp-linkedin  { background: #0A66C2; color: #fff; }
.wp-facebook  { background: #1877F2; color: #fff; }

.week-post-thumb {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 4px;
  display: block;
}
.week-post-caption {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.35;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Day posts panel when opened from week view */
#calendar-view .cal-day-posts {
  margin: 0 24px 24px;
}

/* Mobile adjustments for week view */
@media (max-width: 700px) {
  .week-nav { padding: 10px 8px 8px; gap: 6px; }
  .week-nav button { padding: 6px 10px; font-size: 0.82rem; }
  #cal-title { font-size: 0.88rem; }
  .week-volume { padding: 4px 8px 0; }
  .week-grid { padding: 0 8px 16px; }
  .week-col { min-width: 96px; }
}

/* ---- TikTok script label and formatting ---- */
.card-caption-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.card-caption-script {
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'SF Mono', 'Fira Mono', 'Consolas', monospace;
  color: #e2e8f0;
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  max-height: 200px;
  overflow-y: auto;
}

/* ---- Mobil lodret (portrait) ---- */
@media (max-width: 1024px) {
  .feed {
    grid-template-columns: 1fr;
  }
  .concept-group {
    grid-column: 1 / -1;
  }
  .brand-tab {
    font-size: 0.72rem;
    padding: 6px 8px;
  }
  .tab {
    font-size: 0.72rem;
    padding: 8px 4px;
  }
}

/* ---- Danish language warning ---- */
.danish-warning {
  background: #3a1a1a;
  border: 2px solid #f87171;
  color: #f87171;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
}

/* ---- Carousel drag-to-reorder ---- */
.carousel-thumb { position: relative; cursor: grab; }
.carousel-thumb:active { cursor: grabbing; }
.carousel-thumb.dragging-thumb { opacity: 0.4; transform: scale(0.95); }
.carousel-thumb.drag-over { outline: 2px solid var(--accent); transform: scale(1.05); }
.carousel-order-num {
  position: absolute;
  bottom: 2px;
  right: 4px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  pointer-events: none;
}

/* ---- Crop zoom controls ---- */
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 0 4px;
}
.zoom-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.zoom-btn:hover { border-color: var(--accent); color: var(--accent); }
#zoom-slider {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}
