/* ==========================================================================
   Aeolus Layout — Three-column work view, flat, rounded, cream-blue palette
   ========================================================================== */

/* ---------- Work App Shell ---------- */
.workapp {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto 1fr auto;
  height: 100vh;
  overflow: hidden;
  background: var(--surface-page);
}

/* ==========================================================================
   RWD — Mobile gate (≤ 720px) + Tablet adjustments (721–1100px)
   ========================================================================== */

/* Mobile gate — hidden on desktop/tablet */
#mobile-gate { display: none; }

@media (max-width: 720px) {
  /* Hide app + modal slot on mobile, show gate full-screen */
  #app, #modal-slot, #toast-slot { display: none !important; }
  #mobile-gate {
    display: grid;
    place-items: center;
    position: fixed;
    inset: 0;
    padding: 32px 24px;
    background: linear-gradient(160deg, #1F2A44 0%, #0F1830 100%);
    color: #F2F4F8;
    z-index: 1;
    overflow-y: auto;
  }
}

.mobile-gate__inner {
  max-width: 400px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.mobile-gate__brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0 auto 4px;
}
.mobile-gate__logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: #4A96FF;
  color: #ffffff;
  border-radius: 12px;
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  font-size: 22px;
}
.mobile-gate__wordmark { text-align: left; line-height: 1.1; }
.mobile-gate__name {
  font-family: "Manrope", sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.mobile-gate__sub {
  font-size: 11px;
  color: #A3ABC2;
  letter-spacing: 0.04em;
}
.mobile-gate__title {
  font-family: "Manrope", sans-serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 8px 0 0;
}
.mobile-gate__desc {
  font-size: 15px;
  line-height: 1.6;
  color: #C8CDD9;
  margin: 0;
}
.mobile-gate__stores {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.mobile-gate__store {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 20px;
  background: #ffffff;
  color: #0F1830;
  border-radius: 12px;
  text-decoration: none;
  text-align: left;
  transition: transform 120ms ease;
}
.mobile-gate__store:hover { transform: translateY(-1px); }
.mobile-gate__store-kicker {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5D6A92;
}
.mobile-gate__store-name {
  font-family: "Manrope", sans-serif;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.mobile-gate__hint {
  font-size: 12px;
  color: #7C87A8;
  margin-top: 12px;
}

/* Tablet styles are placed at end-of-file to guarantee cascade precedence over
   base rules. See the @media block at the bottom of this file. */

/* Row 1: Global header */
.workapp__header {
  grid-column: 1 / -1;
  grid-row: 1;
  height: var(--topbar-height);
  background: var(--cream-100);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  z-index: 20;
}
.workapp__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.workapp__logo-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  display: grid;
  place-items: center;
  font-size: 14px;
  color: white;
  font-weight: 800;
}

.topbar__org {
  padding: 6px var(--space-3);
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  box-shadow: var(--shadow-xs);
}

/* Theme toggle — sun/moon button */
.theme-toggle {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--cream-0);
  color: var(--cream-700);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: rotate(15deg);
}
[data-theme="dark"] .theme-toggle {
  color: var(--cream-600);
}
[data-theme="dark"] .theme-toggle:hover {
  color: #FBBF24;   /* sun yellow on hover in dark */
}

/* ---------- Left column (subgrid) ---------- */
.workapp__left {
  grid-column: 1;
  grid-row: 2 / 5;
  width: var(--sidebar-width);
  border-right: 1px solid var(--border-subtle);
  background: var(--cream-100);    /* Cream base, layered on page */
  display: grid;
  grid-template-rows: subgrid;
  transition: width var(--transition-base);
  overflow: hidden;
}
.workapp__left > .left-top {
  grid-row: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-default);  /* clearer divider */
}
/* When ap-row collapsed, fully hide left-top so row 2 truly collapses */
.workapp.is-ap-collapsed > .workapp__left > .left-top {
  display: none;
  border-bottom: none;
}
/* Empty left-top when sidebar is collapsed → don't contribute to grid row height */
.workapp__left.is-collapsed > .left-top {
  padding: 0;
  border-bottom: none;
}

/* Nav block injected into left-body when left is collapsed */
.left-body__nav-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-default);
}
.workapp__left > .left-body {
  grid-row: 2;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
}
.workapp__left > .left-footer {
  grid-row: 3;
  overflow: hidden;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--cream-100);
}
/* When sidebar is collapsed, drop out of subgrid and use flex-column layout.
   This prevents left-top from stretching ap-row height, and lets nav sit at the very top. */
.workapp__left.is-collapsed {
  width: 56px;
  display: flex;
  flex-direction: column;
  grid-template-rows: none;
}
.workapp__left.is-collapsed > .left-top {
  grid-row: auto;
  padding: var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--border-default);
}
.workapp__left.is-collapsed > .left-body {
  grid-row: auto;
  flex: 1;
  padding: var(--space-2) 0;
  overflow-y: auto;
}
.workapp__left.is-collapsed > .left-footer {
  grid-row: auto;
}

/* Hide labels & long text when collapsed */
.workapp__left.is-collapsed .left-nav__label,
.workapp__left.is-collapsed .left-section__title,
.workapp__left.is-collapsed .task-item__meta,
.workapp__left.is-collapsed .task-item__title,
.workapp__left.is-collapsed .btn-new-task__label,
.workapp__left.is-collapsed .workapp__left-footer-text,
.workapp__left.is-collapsed .left-nav__hint {
  display: none;
}

/* Nav: stack in single column with icon-only buttons */
.workapp__left.is-collapsed .left-nav {
  grid-template-columns: 1fr;
  margin: 0 calc(-1 * var(--space-2)) var(--space-2);
  padding: 0 var(--space-2) var(--space-2);
}
.workapp__left.is-collapsed .left-nav__btn {
  padding: 8px;
  min-height: 36px;
}

/* New task button → circular + icon */
.workapp__left.is-collapsed .btn-new-task {
  padding: 0;
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border-radius: 50%;
}

/* Hide initial when sidebar is expanded (shown only in collapsed mode) */
.workapp__left:not(.is-collapsed) .task-item__initial { display: none; }

/* Task items → small rounded boxes with 2-char initial */
.workapp__left.is-collapsed .task-item {
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 4px auto;
  justify-content: center;
  align-items: center;
  border-radius: var(--radius-md);
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  position: relative;
  font-size: 11px;
  font-weight: 700;
}
.workapp__left.is-collapsed .task-item__dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
}
.workapp__left.is-collapsed .task-item__initial {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 11px;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.workapp__left.is-collapsed .task-item.is-active {
  background: var(--primary);
  border-color: var(--primary);
}
.workapp__left.is-collapsed .task-item.is-active .task-item__initial {
  color: var(--cream-0);
}

/* ============================================================
   Collapsed-sidebar tooltips
   - nav & new-task: simple dark pill (::after)
   - task-item: designed rich popover card (below)
   ============================================================ */
.workapp__left.is-collapsed .left-nav__btn,
.workapp__left.is-collapsed .btn-new-task {
  position: relative;
}
.workapp__left.is-collapsed .left-nav__btn::after,
.workapp__left.is-collapsed .btn-new-task::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  box-shadow: var(--shadow-md);
  letter-spacing: -0.005em;
}
.workapp__left.is-collapsed .left-nav__btn::before,
.workapp__left.is-collapsed .btn-new-task::before {
  content: "";
  position: absolute;
  left: calc(100% + 4px);
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: var(--ink);
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  transition: opacity var(--transition-fast);
}
.workapp__left.is-collapsed .left-nav__btn:hover::after,
.workapp__left.is-collapsed .left-nav__btn:hover::before,
.workapp__left.is-collapsed .btn-new-task:hover::after,
.workapp__left.is-collapsed .btn-new-task:hover::before {
  opacity: 1;
}
.workapp__left.is-collapsed .left-nav__btn:hover::after,
.workapp__left.is-collapsed .btn-new-task:hover::after {
  transform: translateY(-50%) translateX(2px);
}

/* ============================================================
   Designed rich popover card for task-item (on hover when collapsed)
   ============================================================ */
.task-popover {
  display: none;
}
.workapp__left.is-collapsed .task-item { position: relative; }
.workapp__left.is-collapsed .task-popover {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  width: 280px;
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: 0 16px 40px rgba(31, 42, 68, 0.20);
  padding: 16px 16px 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 60;
  overflow: hidden;
  text-align: left;
}
.workapp__left.is-collapsed .task-item:hover .task-popover {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}
/* Arrow pointing to task tile */
.workapp__left.is-collapsed .task-popover::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--cream-0);
  border-left: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 0;
}

.task-popover__accent {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  z-index: 1;
}
.task-popover__head {
  display: flex;
  align-items: center;
  gap: 4px;
}
.task-popover__chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.task-popover__chips .chip {
  padding: 2px 8px;
  font-size: 11px;
}
.task-popover__title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--ink);
}
.task-popover__desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.task-popover__stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}
.tp-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: var(--radius-md);
  background: var(--cream-50);
}
.tp-stat__icon { line-height: 0; }
.tp-stat__num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.tp-stat__lbl {
  font-size: 9px;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
}
.task-popover__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-tertiary);
}
.task-popover__footer strong {
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: 600;
}

.workapp__left.is-collapsed .left-body { padding: var(--space-2) 0; }

/* Footer: hide gear + text, keep toggle prominent */
.workapp__left.is-collapsed .left-footer .agent__avatar,
.workapp__left.is-collapsed .left-footer [data-settings] {
  display: none;
}
.workapp__left.is-collapsed .left-footer {
  justify-content: center;
  padding: 0;
}

/* Expand toggle: visible button with label when collapsed */
.left-expand-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: white;
  cursor: pointer;
  border: none;
  transition: background var(--transition-fast);
}
.left-expand-toggle:hover { background: var(--primary-hover); }
.workapp__left:not(.is-collapsed) .left-expand-toggle { display: none; }

.left-nav {
  display: grid;
  grid-template-columns: 20px repeat(4, 1fr);
  gap: 4px;
  /* Negative margin to extend divider edge-to-edge past parent's padding */
  margin: 0 calc(-1 * var(--space-3)) var(--space-3);
  padding: 0 var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--border-default);
  align-items: center;
}
.left-nav__hint {
  display: grid;
  place-items: center;
  color: var(--cream-500);
  width: 20px;
  height: 100%;
}
.workapp__left.is-collapsed .left-nav {
  grid-template-columns: 1fr;
}
.workapp__left.is-collapsed .left-nav__hint { display: none; }
.left-nav__btn {
  padding: 8px 4px;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink);
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
  text-align: center;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(31, 42, 68, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 40px;
}
.left-nav__btn svg { color: var(--text-secondary); transition: color var(--transition-fast); }
.left-nav__btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}
.left-nav__btn:hover svg { color: var(--primary); }
.left-nav__btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--cream-0);
}
.left-nav__btn.is-active svg { color: var(--cream-0); }

.btn-new-task {
  margin: 0;
  padding: 10px var(--space-3);
  background: var(--primary);
  color: var(--cream-0);
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: var(--text-sm);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--primary);
  box-shadow: 0 2px 6px rgba(42, 127, 255, 0.18);
}
.btn-new-task:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 3px 10px rgba(42, 127, 255, 0.28);
}
.btn-new-task svg { stroke: var(--cream-0); }

.left-section__title {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  letter-spacing: 0.1em;
  font-weight: 700;
  margin-bottom: var(--space-2);
  padding: 0 var(--space-2);
}

.task-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--text-sm);
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 3px;
  border: 1px solid transparent;
}
.task-item:hover {
  background: var(--cream-0);
  border-color: var(--border-subtle);
}
.task-item.is-active {
  background: var(--cream-0);
  color: var(--ink);
  font-weight: 600;
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(42, 127, 255, 0.10);
}
.task-item.is-active .task-item__dot {
  background: var(--primary) !important;
}

.task-item__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.task-item__title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workapp__left-footer-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.3;
}
.workapp__left-footer-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.workapp__left-footer-email {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Left-footer account trigger (Claude-style) + popover
   ========================================================================== */
.account-trigger {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  font: inherit;
  color: inherit;
}
.account-trigger:hover {
  background: var(--cream-200);
  border-color: var(--border-subtle);
}
.account-trigger__avatar {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--cream-0);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.02em;
}
.account-trigger__body {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.account-trigger__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-trigger__sub {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-trigger__caret {
  flex-shrink: 0;
  color: var(--text-tertiary);
  display: inline-flex;
}

/* Popover — rendered into body, positioned above the trigger */
.account-popover {
  position: fixed;
  z-index: 400;
  width: 280px;
  padding: 10px;
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow:
    0 2px 6px rgba(31, 42, 68, 0.08),
    0 18px 40px rgba(31, 42, 68, 0.16);
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transform-origin: bottom left;
  transition: opacity 160ms ease, transform 160ms ease;
}
.account-popover.is-open { opacity: 1; transform: translateY(0) scale(1); }
[data-theme="dark"] .account-popover {
  background: var(--cream-0);     /* dark navy card in dark-mode palette */
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.45),
    0 18px 40px rgba(0, 0, 0, 0.55);
}

/* Pointer arrow tailing down to the trigger */
.account-popover::after {
  content: "";
  position: absolute;
  bottom: -7px;
  left: 24px;
  width: 14px;
  height: 14px;
  background: var(--cream-0);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  transform: rotate(45deg);
}

.account-popover__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 12px;
}
.account-popover__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
}
.account-popover__user-body { min-width: 0; }
.account-popover__name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.account-popover__email {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-popover__divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 6px;
}
.account-popover__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: var(--text-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.account-popover__item:hover { background: var(--cream-100); }
.account-popover__item--muted { color: var(--text-secondary); }
.account-popover__icon {
  display: inline-flex;
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.account-popover__hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono, ui-monospace, monospace);
}
.account-popover__org {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 6px;
  margin-top: 6px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 0;                      /* allow child ellipsis */
}
.account-popover__org-icon {
  color: var(--text-tertiary);
  display: inline-flex;
  flex-shrink: 0;
}
.account-popover__org-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;                /* force single line */
}
.account-popover__org-plan {
  flex-shrink: 0;
  margin-left: auto;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--cream-100);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
[data-org-tooltip] { cursor: help; border-radius: var(--radius-sm); }
[data-org-tooltip]:hover { background: var(--cream-100); }

/* Rich org tooltip card — body-level, positioned above the org row */
.org-tooltip {
  position: fixed;
  z-index: 500;
  min-width: 240px;
  max-width: 300px;
  padding: 12px 14px;
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow:
    0 2px 6px rgba(31, 42, 68, 0.08),
    0 18px 40px rgba(31, 42, 68, 0.22);
  color: var(--ink);
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transform-origin: bottom center;
  transition: opacity 160ms ease, transform 160ms ease;
  visibility: hidden;
  pointer-events: none;
}
.org-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}
[data-theme="dark"] .org-tooltip {
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.50),
    0 18px 40px rgba(0, 0, 0, 0.60);
}

/* Pointer arrow tail pointing down to the org row */
.org-tooltip::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 12px;
  height: 12px;
  background: var(--cream-0);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  transform: translateX(-50%) rotate(45deg);
}

.org-tooltip__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.org-tooltip__avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.org-tooltip__head-body { min-width: 0; flex: 1; }
.org-tooltip__name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.015em;
  line-height: 1.3;
}
.org-tooltip__sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.org-tooltip__divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0 0 10px;
}
.org-tooltip__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.org-tooltip__label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 3px;
}
.org-tooltip__value {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.org-tooltip__foot {
  font-size: 10px;
  color: var(--text-tertiary);
  padding-top: 6px;
  border-top: 1px dashed var(--border-subtle);
}

/* ==========================================================================
   Settings · 組織設定
   ========================================================================== */
.org-profile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}
.org-profile__avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.org-profile__body { flex: 1; min-width: 0; }

/* Permission matrix */
.perm-matrix {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.perm-matrix__head,
.perm-matrix__row {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) repeat(4, 90px);
  align-items: center;
  gap: var(--space-2);
  padding: 10px var(--space-4);
}
.perm-matrix__head {
  background: var(--cream-50);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
}
.perm-matrix__role { text-align: center; }
.perm-matrix__row {
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
}
.perm-matrix__row:last-child { border-bottom: none; }
.perm-matrix__row:hover { background: var(--cream-50); }
.perm-matrix__row > div:nth-child(n+2) { text-align: center; }

.perm-cell {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
}
.perm-cell--on {
  background: var(--success-soft, rgba(74, 222, 128, 0.18));
  color: var(--success);
}
.perm-cell--off { color: var(--cream-400); }

/* Member roster */
.org-member-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: var(--space-2);
}
.org-member-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--cream-0);
  transition: background var(--transition-fast);
}
.org-member-row:hover { background: var(--cream-50); }
.org-member-row__body { flex: 1; min-width: 0; }
.org-member-row__name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
}
.org-member-row__email {
  font-size: 11px;
  color: var(--text-tertiary);
}
.org-member-row__role {
  width: 110px;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--cream-0);
  color: var(--ink);
  cursor: pointer;
  outline: none;
}
.org-member-row__role:disabled { cursor: not-allowed; opacity: 0.6; }

.left-collapse-toggle {
  padding: 4px var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  font-size: 14px;
}
.left-collapse-toggle:hover {
  background: var(--cream-100);
  color: var(--ink);
}

/* ---------- Audience pack row ---------- */
.ap-row {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  min-height: 128px;
  /* Engineering drafting paper: cream base + subtle dot grid */
  background-color: var(--surface-sunken, #F7F7F2);
  background-image: radial-gradient(circle, rgba(31, 42, 68, 0.18) 1px, transparent 1.2px);
  background-size: 14px 14px;
  background-position: 0 0;
  border-bottom: 1px solid var(--border-default);
  border-top: 1px solid var(--border-default);
  overflow-x: auto;
  scrollbar-width: thin;
  position: relative;
  /* Recessed feel — inner shadows on all four sides */
  box-shadow:
    inset 0 14px 18px -12px rgba(31, 42, 68, 0.35),
    inset 0 -14px 18px -12px rgba(31, 42, 68, 0.35),
    inset 14px 0 18px -14px rgba(31, 42, 68, 0.22),
    inset -14px 0 18px -14px rgba(31, 42, 68, 0.22);
}
.ap-divider { background: var(--border-default); }
.ap-add {
  background: var(--cream-0);
  border: 1px dashed var(--border-default);
  color: var(--text-tertiary);
}
.ap-add:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* Dark mode: invert dot color + lighter inset shadows won't help, keep deep */
[data-theme="dark"] .ap-row {
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.08) 1px, transparent 1.2px);
  box-shadow:
    inset 0 14px 18px -12px rgba(0, 0, 0, 0.55),
    inset 0 -14px 18px -12px rgba(0, 0, 0, 0.55),
    inset 14px 0 18px -14px rgba(0, 0, 0, 0.40),
    inset -14px 0 18px -14px rgba(0, 0, 0, 0.40);
}
.ap-row__toggle {
  flex-shrink: 0;
  margin-left: auto;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--cream-100);
  cursor: pointer;
  border: none;
}
.ap-row__toggle:hover { background: var(--cream-200); color: var(--ink); }

.ap-row--collapsed {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px var(--space-5);
  min-height: 0;
  background: var(--cream-0);
  border-bottom: 1px solid var(--border-subtle);
}
.ap-row--collapsed .ap-row__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--cream-700);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--cream-100);
}
.ap-row--collapsed .ap-row__label svg { color: var(--primary); }

.ap-add {
  flex-shrink: 0;
  width: 88px;
  height: 88px;
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--cream-0);
}
.ap-add:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.ap-divider {
  flex-shrink: 0;
  width: 1px;
  height: 56px;
  background: var(--border-default);
}

.ap-tile {
  flex-shrink: 0;
  width: 180px;
  height: 88px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  background-size: cover;
  background-position: center;
}
.ap-tile::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50%;
  background: rgba(31, 42, 68, 0.50);
}
.ap-tile:hover { transform: translateY(-1px); }
.ap-tile.is-active {
  box-shadow: 0 0 0 3px var(--primary);
}
.ap-tile__body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-2);
  color: white;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 4px;
}
.ap-tile__name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  letter-spacing: -0.01em;
}
.ap-tile__reach {
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.96);
  color: #1F2A44;  /* always dark navy (bg is always white) */
  padding: 2px 7px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  letter-spacing: -0.01em;
  font-family: var(--font-display);
}
.ap-tile__source-icon {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 14px;
  color: white;
  z-index: 1;
}

/* Edit/view action button — top-right of ap-tile */
.ap-tile__action {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.30);
  cursor: pointer;
  z-index: 2;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast);
  backdrop-filter: blur(6px);
}
.ap-tile:hover .ap-tile__action,
.ap-tile.is-active .ap-tile__action { opacity: 1; }
.ap-tile__action:hover {
  background: rgba(255, 255, 255, 0.32);
  border-color: rgba(255, 255, 255, 0.55);
}

/* ---------- Center workspace ---------- */
.workapp__main {
  grid-column: 2;
  grid-row: 3;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--cream-50);   /* Subtle warm bg, layered on page */
}
.workapp__bottom-bar {
  grid-column: 2;
  grid-row: 4;
  height: 64px;              /* fixed so subgrid row 4 stays stable (doesn't affect left-footer) */
  min-height: 64px;
  border-top: 1px solid var(--border-subtle);
  background: var(--cream-0);
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ==========================================================================
   投放快捷 — the "ending" of the whole flow. Deep-blue gradient + pulsing so
   it stands out as the primary send-out CTA.
   ========================================================================== */
.quick-placement-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: -0.01em;
  cursor: pointer;
  color: #ffffff;
  background: linear-gradient(100deg, #0F3F8A 0%, #1F6FEA 40%, #4A96FF 60%, #0F3F8A 100%);
  background-size: 220% 100%;
  box-shadow: 0 2px 8px rgba(15, 63, 138, 0.40), 0 0 0 0 rgba(21, 88, 194, 0.55);
  animation: cta-shimmer 3s linear infinite, cta-pulse 2.2s ease-in-out infinite;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.quick-placement-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(15, 63, 138, 0.60), 0 0 0 4px rgba(74, 150, 255, 0.25);
  animation-play-state: paused;  /* hold the highlight on hover so user can read it */
}
.quick-placement-cta:active {
  transform: translateY(0);
}
.quick-placement-cta svg {
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.6));
}

@keyframes cta-shimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: -220% 50%; }
}
@keyframes cta-pulse {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(15, 63, 138, 0.40), 0 0 0 0 rgba(21, 88, 194, 0.55);
  }
  50% {
    box-shadow: 0 4px 14px rgba(15, 63, 138, 0.55), 0 0 0 8px rgba(21, 88, 194, 0);
  }
}

.task-header {
  padding: var(--space-4) var(--space-6) var(--space-2);
  background: var(--cream-50);
  border-bottom: 1px solid var(--border-subtle);
}
.task-header__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.task-header__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--ink);
  line-height: 1.25;
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-header__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.task-header__chips {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.task-header__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  /* Strong visual separation from chips cluster */
  padding-left: var(--space-3);
  border-left: 1px solid var(--border-subtle);
}
/* Equal-sized pill buttons for header actions */
.hd-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  min-width: 78px;
  background: var(--cream-0);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.hd-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}
.hd-pill svg {
  color: var(--text-tertiary);
  transition: color var(--transition-fast);
  flex-shrink: 0;
}
.hd-pill:hover svg { color: var(--primary); }

/* Orange accent variant — for special functions like 受眾包 toggle */
.hd-pill--accent {
  background: var(--tertiary);
  border-color: var(--tertiary);
  color: var(--cream-0);
}
.hd-pill--accent svg { color: var(--cream-0); }
.hd-pill--accent:hover {
  background: var(--tertiary-hover);
  border-color: var(--tertiary-hover);
  color: var(--cream-0);
}
.hd-pill--accent:hover svg { color: var(--cream-0); }
.task-header__desc {
  margin-top: 4px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-header__actions { display: flex; gap: 4px; margin-left: auto; }
.task-edit-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  border: none;
}
.task-edit-btn:hover { background: var(--cream-100); color: var(--ink); }

/* Inline pack-toggle pill (used in task-header right cluster when ap-row is collapsed) */
.pack-toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px 5px 10px;
  background: var(--cream-0);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.pack-toggle-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}
.pack-toggle-pill svg { color: var(--text-tertiary); }
.pack-toggle-pill:hover svg { color: var(--primary); }

/* Pull-tab hanging from top of main content (collapsed ap-row state) — legacy, kept for fallback */
.pack-hanger {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: var(--cream-0);
  padding: 6px 16px 7px;
  border-radius: 0 0 14px 14px;
  box-shadow: 0 3px 10px rgba(31, 42, 68, 0.10);
  border: 1px solid var(--border-subtle);
  border-top: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  z-index: 8;
  transition: all var(--transition-base);
  white-space: nowrap;
}
.pack-hanger:hover {
  color: var(--primary);
  box-shadow: 0 5px 16px rgba(42, 127, 255, 0.20);
  padding-top: 9px;
  padding-bottom: 10px;
}
.pack-hanger:hover svg { stroke: var(--primary); }
.pack-hanger svg { color: var(--text-tertiary); transition: transform var(--transition-fast); }
.pack-hanger:hover svg { transform: translateY(1px); }

/* The main center column needs position:relative for the hanger */
.workapp__main { position: relative; }

.subtabs {
  display: flex;
  gap: 2px;
  padding: 6px var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--cream-0);
}
.subtab {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--cream-700);      /* Readable on cream bg */
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  background: transparent;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.subtab svg { width: 15px; height: 15px; }
.subtab:hover {
  color: var(--ink);
  background: var(--cream-100);
}
.subtab.is-active {
  color: var(--cream-0);
  background: var(--ink);
}
.subtab.is-active svg { stroke: var(--cream-0); }

/* ==========================================================================
   Dashboard head — restores the original inline hstack layout
   (chips / title / desc on the left, actions on the right) but with
   breathable line-heights so rows don't feel cramped.
   ========================================================================== */
.dash-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.dash-head__chips {
  margin-bottom: 10px;
  line-height: 1.8;
}
.dash-head__title {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.5;
  color: var(--cream-700);
  margin: 0;
}
.dash-head__desc {
  margin-top: 8px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.8;
}
.dash-head__actions {
  margin-top: 4px;
  line-height: 1.8;
}

.tab-content {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
}

/* ---------- Right column (Agent chat) ---------- */
.workapp__right {
  grid-column: 3;
  grid-row: 2 / 5;
  width: 300px;
  border-left: 1px solid var(--border-subtle);
  background: var(--cream-0);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-base);
  position: relative;                /* anchor for floating .chat-composer */
}
.workapp__right.is-collapsed { width: 48px; }
.workapp__right.is-collapsed .chat-head__title,
.workapp__right.is-collapsed .chat-head .agent__avatar,
.workapp__right.is-collapsed .chat-body,
.workapp__right.is-collapsed .chat-composer {
  display: none;
}
.workapp__right.is-collapsed .chat-head {
  padding: 10px 8px;
  justify-content: center;
}
.workapp__right.is-collapsed .collapse-btn {
  margin: 0 !important;
  width: 32px;
  height: 32px;
  background: var(--cream-100);
}
.workapp__right.is-collapsed .collapse-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.chat-head {
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.chat-head__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: -0.015em;
}

.chat-body {
  flex: 1;
  padding: var(--space-4);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-2xl);
  max-width: 85%;
  line-height: 1.5;
  font-size: var(--text-sm);
  animation: agent-pop 280ms ease;
}
.chat-bubble--agent {
  background: var(--cream-100);
  color: var(--ink);
  border-bottom-left-radius: var(--radius-xs);
  align-self: flex-start;
}
.chat-bubble--user {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: var(--radius-xs);
  align-self: flex-end;
}

.chat-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: var(--space-2);
}
.chat-choice {
  padding: 4px var(--space-3);
  background: var(--cream-0);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.chat-choice:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* Floating glass-morphism composer — not aligned with bottom line */
.chat-composer {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  z-index: 5;
  padding: 6px 6px 6px 14px;
  display: flex;
  gap: 6px;
  align-items: center;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border: 1px solid rgba(31, 42, 68, 0.08);
  box-shadow:
    0 10px 28px rgba(31, 42, 68, 0.12),
    0 2px 6px rgba(31, 42, 68, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
[data-theme="dark"] .chat-composer {
  background: rgba(42, 53, 82, 0.55);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.chat-composer input {
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  border: none;
  outline: none;
  font-size: var(--text-sm);
  background: transparent;
  color: var(--ink);
}
.chat-composer input::placeholder { color: var(--text-tertiary); }

/* Round send button — icon only */
.chat-send {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.chat-send:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}
.chat-send:active { transform: translateY(0); }
.chat-send svg { stroke-width: 2.5; }

/* Give chat body room so last messages don't sit behind the floating composer */
.chat-body {
  padding-bottom: calc(var(--space-4) + 58px);
}

/* ---------- Placement bottom bar ---------- */
.placement-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
}
.placement-bar__label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  letter-spacing: -0.01em;
}
.placement-bar__divider {
  flex-shrink: 0;
  width: 1px;
  height: 20px;
  background: var(--border-default);
}
/* Sunken "drafting paper" panel (starts AFTER the 投放至 label + divider).
   Deep-blue base + light-blue dot grid + left-to-right shimmer sweep.
   Pills inside get a lift shadow so they look like floating cards. */
.placement-bar__channels {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: visible;
  min-width: 0;
  padding: 0 12px;
  height: 44px;
  align-self: center;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(100deg,
      transparent 0%,
      transparent 40%,
      rgba(217, 242, 255, 0.28) 50%,
      transparent 60%,
      transparent 100%) 0 0 / 260% 100% no-repeat,
    radial-gradient(circle, rgba(217, 242, 255, 0.55) 1px, transparent 1.2px) 0 0 / 12px 12px,
    linear-gradient(180deg, #1F6FEA 0%, #2A7FFF 100%);
  border: 1px solid rgba(217, 242, 255, 0.30);
  box-shadow:
    inset 0 10px 14px -10px rgba(21, 88, 194, 0.45),
    inset 0 -10px 14px -10px rgba(21, 88, 194, 0.45),
    inset 10px 0 14px -12px rgba(21, 88, 194, 0.35),
    inset -10px 0 14px -12px rgba(21, 88, 194, 0.35);
  animation: channels-shimmer 4.5s linear infinite;
  scrollbar-width: none;
}
.placement-bar__channels::-webkit-scrollbar { display: none; }

/* Animate only the first background layer (shimmer sweep, left → right) */
@keyframes channels-shimmer {
  0% {
    background-position: 160% 0, 0 0, 0 0;
  }
  100% {
    background-position: -60% 0, 0 0, 0 0;
  }
}

/* Dark mode: brighter dots + stronger shimmer on already-dark base */
[data-theme="dark"] .placement-bar__channels {
  background:
    linear-gradient(100deg,
      transparent 0%,
      transparent 40%,
      rgba(217, 242, 255, 0.32) 50%,
      transparent 60%,
      transparent 100%) 0 0 / 260% 100% no-repeat,
    radial-gradient(circle, rgba(217, 242, 255, 0.60) 1px, transparent 1.2px) 0 0 / 12px 12px,
    linear-gradient(180deg, #1558C2 0%, #1F6FEA 100%);
  border-color: rgba(217, 242, 255, 0.35);
}
.ch-wrap {
  display: inline-flex;
  align-items: center;
  position: relative;
}

/* Small $ indicator inside the right edge of the ch-toggle pill (no overflow) */
.boost-badge {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--danger);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: boost-badge-pulse 1.6s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}
.boost-badge svg { stroke-width: 3; }

@keyframes boost-badge-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(204, 41, 68, 0.55);
    transform: translateY(-50%) scale(1);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(204, 41, 68, 0);
    transform: translateY(-50%) scale(1.10);
  }
}

/* Global boost tooltip (rendered as body-level element) */
.boost-tooltip {
  position: fixed;
  z-index: 1000;
  min-width: 260px;
  max-width: 320px;
  padding: 10px 12px;
  background: #1F2A44;
  color: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  font-size: 11px;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
  visibility: hidden;
}
.boost-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.boost-tooltip__head {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 12px;
}
.boost-tooltip__head strong {
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.boost-tooltip__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.boost-tooltip__foot {
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 11px;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
}
.boost-tooltip__foot strong {
  color: #FDBA74;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-left: 4px;
}

/* Legacy .boost-alert rules — kept in case rendered elsewhere, but no longer
   used on bottom bar channel row. */
.boost-alert {
  display: none;
}

/* Tooltip popover */
.boost-alert__tip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  min-width: 260px;
  max-width: 320px;
  padding: 10px 12px;
  background: var(--ink);
  color: white;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(31, 42, 68, 0.35);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  z-index: 30;
  white-space: normal;
}
.boost-alert:hover .boost-alert__tip,
.boost-alert:focus-visible .boost-alert__tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
/* Arrow pointing down to the $ */
.boost-alert__tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ink);
}
.boost-alert__tip-head {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 12px;
}
.boost-alert__tip-head strong {
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.boost-alert__tip-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.boost-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  font-size: 11px;
}
.boost-row__ctr {
  color: #86EFAC;  /* Light green for positive trend */
  font-family: var(--font-mono);
  font-size: 10px;
}
.boost-row__amt {
  color: #FDBA74;  /* Light orange (accent) */
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
}
.boost-alert__tip-foot {
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 11px;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
}
.boost-alert__tip-foot strong {
  color: #FDBA74;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-left: 4px;
}

/* When a channel needs boost, its toggle also pulses red */
.ch-toggle.has-boost {
  border-color: var(--danger);
  animation: channel-boost-pulse 1.6s ease-in-out infinite;
}
@keyframes channel-boost-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(204, 41, 68, 0.40);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(204, 41, 68, 0);
  }
}

.ch-toggle {
  position: relative;
  padding: 6px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--cream-0);
  white-space: nowrap;
  flex-shrink: 0;
  /* Lift above the sunken channels panel */
  box-shadow: 0 1px 2px rgba(31, 42, 68, 0.08), 0 2px 6px rgba(31, 42, 68, 0.10);
}
.ch-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(31, 42, 68, 0.12), 0 4px 10px rgba(31, 42, 68, 0.14);
}
[data-theme="dark"] .ch-toggle {
  background: var(--cream-0);
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.40), 0 2px 6px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .ch-toggle:hover {
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.50), 0 6px 12px rgba(0, 0, 0, 0.45);
}
.ch-toggle.has-boost { padding-right: 26px; }   /* room for inside badge */
.ch-toggle:hover { border-color: var(--ink); }
.ch-toggle.is-active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

/* ---------- Collapse toggle button ---------- */
.collapse-btn {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
}
.collapse-btn:hover { background: var(--cream-100); color: var(--ink); }

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  display: grid;
  place-items: center;
  z-index: 100;
  animation: fade-in 200ms ease;
  padding: var(--space-4);
}
.modal {
  background: var(--cream-0);
  border-radius: var(--radius-2xl);
  width: min(640px, 92vw);
  max-height: 88vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: modal-pop 240ms cubic-bezier(.16, 1, .3, 1);
}
.modal--wide { width: min(820px, 94vw); }
.modal--xwide { width: min(1280px, 96vw); }

.modal__header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.modal__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.modal__close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  color: var(--text-tertiary);
  font-size: 18px;
  cursor: pointer;
}
.modal__close:hover { background: var(--cream-100); color: var(--ink); }

.modal__body {
  padding: var(--space-6);
  overflow-y: auto;
}
.modal__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--cream-50);
}

.step-dots {
  display: flex;
  gap: var(--space-1);
  align-items: center;
}
.step-dot {
  width: 24px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--cream-200);
}
.step-dot.is-done { background: var(--primary); }
.step-dot.is-active { background: var(--primary); }

/* ---------- Forms ---------- */
.form-field {
  margin-bottom: var(--space-5);
}
.form-field__label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--ink);
  letter-spacing: -0.01em;
}
.form-field__hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}
.form-field input[type="text"],
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 10px var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: inherit;
  outline: none;
  background: var(--cream-0);
  color: var(--ink);
}
.form-field input[type="text"]:focus,
.form-field textarea:focus,
.form-field select:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

.tag-input-box {
  padding: 6px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 44px;
  align-items: center;
  background: var(--cream-0);
}
.tag-input-box input {
  border: none;
  outline: none;
  flex: 1;
  min-width: 80px;
  padding: 4px 8px;
  background: transparent;
}
.tag-pill {
  padding: 3px var(--space-3);
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.tag-pill__x { cursor: pointer; opacity: 0.7; }
.tag-pill__x:hover { opacity: 1; }

.color-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-2);
}
.color-swatch {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 3px solid transparent;
  transition: all var(--transition-fast);
}
.color-swatch.is-active { border-color: var(--ink); transform: scale(1.04); }

/* Compact variant — smaller chips so they don't dominate the modal */
.color-grid--sm {
  grid-template-columns: repeat(10, 28px);
  gap: 6px;
}
.color-grid--sm .color-swatch {
  width: 28px;
  height: 28px;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border-width: 2px;
}
.color-grid--sm .color-swatch.is-active {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px var(--cream-0), 0 0 0 4px var(--primary);
  border-color: transparent;
}

/* ==========================================================================
   Create-audience-pack modal — 2-col layout + dynamic demographic blocks
   ========================================================================== */
.create-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}
.create-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.create-col .form-field { margin-bottom: var(--space-4); }
.create-col .form-field:last-child { margin-bottom: 0; }

@media (max-width: 720px) {
  .create-grid { grid-template-columns: 1fr; }
}

.form-field__label--sm {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* "Right column" group: demo / keyword block */
.demo-group {
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--cream-50);
  margin-bottom: var(--space-3);
}
.demo-group:last-of-type { margin-bottom: var(--space-3); }
.demo-group__label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

/* Empty-state hint when no data source is selected yet */
.demo-hint {
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--cream-50);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

/* Pill-group: togglable chips for gender / freq / categories / regions */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pill-option {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--cream-0);
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.pill-option:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.pill-option.is-active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Dark-mode pill-option: keep active pill legible */
[data-theme="dark"] .pill-option {
  background: transparent;
  color: var(--cream-700);
}
[data-theme="dark"] .pill-option:hover {
  color: var(--primary-hover);
  border-color: var(--primary-hover);
}
[data-theme="dark"] .pill-option.is-active {
  background: var(--primary);
  color: #0B1220;
  border-color: var(--primary);
}

/* Custom tab — big checkbox cards for the 3 data source groups */
.custom-source-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}
@media (max-width: 640px) {
  .custom-source-grid { grid-template-columns: 1fr; }
}
.custom-source-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--cream-0);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
  font: inherit;
  color: inherit;
}
.custom-source-card:hover {
  border-color: var(--primary);
  background: var(--primary-tint, var(--cream-50));
}
.custom-source-card.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.custom-source-card__check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-default);
  display: grid;
  place-items: center;
  margin-top: 2px;
  color: #ffffff;
  background: transparent;
  transition: all var(--transition-fast);
}
.custom-source-card.is-active .custom-source-card__check {
  background: var(--primary);
  border-color: var(--primary);
}
.custom-source-card__body { min-width: 0; flex: 1; }
.custom-source-card__label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}
.custom-source-card__meta {
  font-size: 11px;
  color: var(--text-tertiary);
}
[data-theme="dark"] .custom-source-card.is-active {
  background: rgba(74, 150, 255, 0.14);
}

/* ==========================================================================
   AdSet modal — audience pack picker grid
   ========================================================================== */
.ap-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.ap-picker-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 12px;
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--cream-0);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
  font: inherit;
  color: inherit;
}
.ap-picker-card:hover:not(.is-disabled) {
  border-color: var(--primary);
  background: var(--primary-tint, var(--cream-50));
}
.ap-picker-card.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.ap-picker-card.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.ap-picker-card__cover {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.ap-picker-card__body { min-width: 0; flex: 1; }
.ap-picker-card__name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ap-picker-card__meta {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ==========================================================================
   Ad modal — 2-col (settings / preview + placements)
   ========================================================================== */
.ad-modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--space-5);
  align-items: start;
}
.ad-modal-col--settings .form-field:last-child { margin-bottom: 0; }
.ad-modal-col--preview {
  padding: var(--space-4);
  background: var(--cream-50);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
}
@media (max-width: 1000px) {
  .ad-modal-grid { grid-template-columns: 1fr; }
  .ad-modal-col--preview { position: static; max-height: none; }
}

/* Preview card — Facebook-style mockup */
.ad-preview__label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}
.ad-preview {
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
}
.ad-preview__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}
.ad-preview__brand-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}
.ad-preview__brand-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}
.ad-preview__sponsored {
  font-size: 11px;
  color: var(--text-tertiary);
}
.ad-preview__primary {
  padding: 0 12px 10px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}
.ad-preview__image {
  aspect-ratio: 1.91 / 1;
  background: var(--cream-100);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.ad-preview__image img { width: 100%; height: 100%; object-fit: cover; }
.ad-preview__image-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-tertiary);
  font-size: 12px;
}
.ad-preview__link-card {
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  background: var(--cream-50);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ad-preview__domain {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
}
.ad-preview__headline {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.ad-preview__cta {
  align-self: flex-start;
  margin-top: 4px;
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: var(--cream-200);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
[data-theme="dark"] .ad-preview__cta {
  background: var(--cream-300);
  color: var(--ink);
}

/* Placement grouped picker */
.placement-groups {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.placement-group__channel {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}
.placement-group__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.placement-pill {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--cream-0);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.placement-pill:hover { border-color: var(--primary); color: var(--primary); }
.placement-pill.is-active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}
[data-theme="dark"] .placement-pill.is-active {
  color: #0B1220;
  font-weight: 700;
}

/* ==========================================================================
   Per-channel config cards (Ad modal)
   Each active channel gets its own card with spec'd fields so different
   channels (FB / IG / LINE / Google / …) can be tuned independently.
   ========================================================================== */
.channel-configs {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.channel-configs__empty {
  padding: var(--space-4);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  text-align: center;
}
.channel-config {
  position: relative;
  padding: var(--space-3) var(--space-4) var(--space-4);
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--ch-color, var(--primary));
  transition: box-shadow 180ms ease, border-color 180ms ease;
}
.channel-config.is-previewing {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ch-color, var(--primary)) 18%, transparent);
}
.channel-config__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--space-3);
}
.channel-config__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ch-color, var(--primary));
}
.channel-config__name {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.channel-config__badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--ch-color, var(--primary));
  background: color-mix(in srgb, var(--ch-color, var(--primary)) 12%, transparent);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.channel-config__fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.channel-config__fields .form-field { margin-bottom: 0; }
.channel-field__counter {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* Preview channel tabs */
.preview-channel-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: var(--space-3);
  background: var(--cream-100);
  border-radius: var(--radius-md);
  overflow-x: auto;
  scrollbar-width: none;
}
.preview-channel-tabs::-webkit-scrollbar { display: none; }
.preview-channel-tab {
  flex-shrink: 0;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.preview-channel-tab:hover { color: var(--ink); }
.preview-channel-tab.is-active {
  background: var(--cream-0);
  color: var(--ch-color, var(--primary));
  box-shadow: 0 1px 3px rgba(31, 42, 68, 0.08);
}

/* Official pack read-only view modal */
.official-pack-view__cover {
  height: 96px;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  display: flex;
  align-items: flex-start;
}
.official-pack-view__section {
  margin-bottom: var(--space-4);
}
.official-pack-view__label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.official-pack-view__text {
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--ink);
}
.official-pack-view__reach {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-family: var(--font-display);
}
.official-pack-view__reach strong {
  font-size: var(--text-2xl);
  color: var(--primary);
  letter-spacing: -0.02em;
}
.official-pack-view__meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--cream-50);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
}
.official-pack-view__kws {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ==========================================================================
   Copy format picker (4 radio-style cards)
   ========================================================================== */
.copy-format-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
@media (max-width: 600px) {
  .copy-format-group { grid-template-columns: repeat(2, 1fr); }
}
.copy-format-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 10px;
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--cream-0);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  user-select: none;
}
.copy-format-option input { display: none; }
.copy-format-option:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.copy-format-option.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

/* ==========================================================================
   Copy list (expand/collapse + edit)
   ========================================================================== */
.copy-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--cream-0);
  overflow: hidden;
}
.copy-list__item {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}
.copy-list__item:last-child { border-bottom: none; }
.copy-list__item.is-expanded { background: var(--cream-50); }

.copy-list__head {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 140px auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
}
.copy-list__head:hover { background: var(--cream-50); }

.copy-list__format { display: flex; }
.copy-list__format .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
}
.copy-list__format .chip svg { flex-shrink: 0; }

.copy-list__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.copy-list__preview {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy-list__time {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.copy-list__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.copy-list__chevron {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--text-tertiary);
  transition: transform var(--transition-fast);
}
.copy-list__item.is-expanded .copy-list__chevron { transform: rotate(180deg); }

.copy-list__body {
  display: none;
  padding: 0 var(--space-4) var(--space-4) var(--space-4);
  gap: var(--space-3);
  flex-direction: column;
}
.copy-list__item.is-expanded .copy-list__body { display: flex; }

.copy-channel-block,
.copy-section-block,
.copy-body-block {
  padding: var(--space-3) var(--space-4);
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--ink);
  line-height: 1.6;
  white-space: pre-wrap;
}
.copy-channel-block__label,
.copy-section-block__heading {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: none;
}
.copy-section-block__heading {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.copy-body-block { white-space: pre-wrap; }

@media (max-width: 720px) {
  .copy-list__head { grid-template-columns: 90px minmax(0, 1fr) auto; }
  .copy-list__time { display: none; }
}

/* ==========================================================================
   Settings · 付款方式 (payment methods)
   ========================================================================== */
.payment-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.payment-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--cream-0);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.payment-card:hover { border-color: var(--border-default); }
.payment-card.is-default {
  border-color: var(--primary);
  background: var(--primary-tint, var(--primary-soft));
}
.payment-card__icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--cream-100);
  color: var(--primary);
  flex-shrink: 0;
}
.payment-card.is-default .payment-card__icon {
  background: var(--primary);
  color: #ffffff;
}
.payment-card__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 4px;
}
.payment-card__type {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.payment-card__detail {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.45;
  font-family: var(--font-mono, inherit);
}
.payment-card__holder {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: 4px;
}
.payment-card__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ==========================================================================
   Settings · 帳單 (invoices list)
   ========================================================================== */
.invoice-list {
  display: flex;
  flex-direction: column;
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.invoice-list__head,
.invoice-list__row {
  display: grid;
  grid-template-columns: 90px 120px 120px 90px minmax(0, 1fr) 100px 180px;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}
.invoice-list__head {
  background: var(--cream-50);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
}
.invoice-list__row {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  font-size: var(--text-sm);
}
.invoice-list__row:last-child { border-bottom: none; }
.invoice-list__row:hover { background: var(--cream-50); }
.invoice-list__cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.invoice-list__actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .invoice-list__head,
  .invoice-list__row {
    grid-template-columns: 80px 100px 100px 80px minmax(0, 1fr);
  }
  .invoice-list__head > div:nth-child(n+6),
  .invoice-list__row > div:nth-child(n+6) { display: none; }
}

.ap-picklist {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
  max-height: 360px;
  overflow-y: auto;
}
.ap-pick {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.ap-pick:hover { border-color: var(--border-default); background: var(--cream-50); }
.ap-pick.is-picked {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.ap-pick.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}
.ap-pick__cover {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.ap-pick__body { flex: 1; overflow: hidden; }
.ap-pick__name { font-weight: 600; font-size: var(--text-sm); }
.ap-pick__meta { font-size: var(--text-xs); color: var(--text-tertiary); }
.ap-pick__check {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-default);
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
}
.ap-pick.is-picked .ap-pick__check {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ==========================================================================
   Welcome state
   ========================================================================== */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-16) var(--space-6);
  max-width: 640px;
  margin: 0 auto;
}
.welcome__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-xl);
  background: var(--primary);
  display: grid;
  place-items: center;
  font-size: 30px;
  color: white;
  margin-bottom: var(--space-5);
}
.welcome__title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  letter-spacing: -0.035em;
}
.welcome__desc {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  margin-top: var(--space-3);
}

/* ==========================================================================
   Credit pill (header)
   ========================================================================== */
.credit-pill {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px var(--space-3);
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  text-decoration: none;
  color: var(--ink);
  transition: all var(--transition-fast);
  box-shadow: 0 1px 2px rgba(31, 42, 68, 0.04);
}
.credit-pill:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(42, 127, 255, 0.12);
}
.credit-pill__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.credit-pill__num { font-size: var(--text-xs); line-height: 1; }
.credit-pill__num strong {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 800;
  letter-spacing: -0.015em;
}
.credit-pill__bar {
  width: 80px;
  height: 4px;
  background: var(--cream-300);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.credit-pill__bar > div {
  height: 100%;
  transition: width var(--transition-base);
}

/* ==========================================================================
   Placement performance dashboard
   ========================================================================== */
.inv-row {
  display: grid;
  grid-template-columns: 1fr 90px 90px 100px 100px 100px 140px;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
}
.inv-row__title { font-weight: 600; font-size: var(--text-sm); }
.inv-row__meta  { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 2px; }
.inv-row__num   {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.inv-row__num-small { font-size: var(--text-xs); color: var(--text-tertiary); text-align: right; }
.inv-row__action { display: flex; gap: 4px; justify-content: flex-end; }

.trend-arrow { font-weight: 700; }
.trend-arrow--up   { color: var(--success); }
.trend-arrow--down { color: var(--danger); }
.trend-arrow--flat { color: var(--text-tertiary); }

.reco-hint {
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.reco-hint--boost     { background: var(--success-soft); color: #1F7A4A; }
.reco-hint--reduce    { background: var(--danger-soft); color: #8B1E34; }
.reco-hint--watch     { background: var(--warning-soft); color: var(--tertiary-hover); }
.reco-hint--scheduled { background: var(--cream-100); color: var(--text-secondary); }
.reco-hint--boosted   { background: var(--primary-soft); color: var(--primary); }

/* ==========================================================================
   Browse mode controls (search + sort)
   ========================================================================== */
.browse-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

.browse-search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}
.browse-search {
  width: 100%;
  padding: 9px 36px 9px 38px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  outline: none;
  background: var(--cream-0);
  color: var(--ink);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.browse-search::placeholder { color: var(--text-tertiary); }
.browse-search:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}
.browse-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  display: inline-flex;
}
.browse-search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cream-200);
  color: var(--cream-700);
  display: grid;
  place-items: center;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}
.browse-search-clear:hover { background: var(--cream-300); color: var(--ink); }

.browse-sort-group {
  display: inline-flex;
  background: var(--cream-100);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}
.sort-btn {
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.sort-btn:hover { color: var(--ink); }
.sort-btn.is-active {
  background: var(--cream-0);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.sort-btn.is-active svg { color: var(--primary); }
.sort-btn svg { color: var(--text-tertiary); transition: color var(--transition-fast); }

/* Material-kind dropdown */
.browse-kind-select {
  padding: 8px 32px 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--cream-0);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237C87A8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.browse-kind-select:hover { border-color: var(--primary); }
.browse-kind-select:focus { border-color: var(--primary); box-shadow: var(--shadow-focus); }

/* ==========================================================================
   Material browse — sectioned layout per kind
   ========================================================================== */
.material-section {
  margin-bottom: var(--space-8);
}
.material-section:last-child { margin-bottom: 0; }
.material-section__header {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}
.material-section__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin: 0;
}
.material-section__count {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* ==========================================================================
   Audience packs list (table-like grid)
   ========================================================================== */
.ap-list {
  display: flex;
  flex-direction: column;
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ap-list__head,
.ap-list__row {
  display: grid;
  grid-template-columns: 56px 64px minmax(240px, 1fr) 120px 160px 160px 96px;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}
.ap-list__head {
  background: var(--cream-50);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  text-transform: none;
}
.ap-list__row {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}
.ap-list__row:last-child { border-bottom: none; }
.ap-list__row:hover { background: var(--cream-50); }

.ap-list__cell--idx { color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.ap-list__cell--reach { font-variant-numeric: tabular-nums; }
.ap-list__cell--reach strong { color: var(--primary); font-family: var(--font-display); font-size: var(--text-base); }
.ap-list__cell--time { color: var(--text-secondary); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.ap-list__cell--actions { display: flex; gap: 4px; justify-content: flex-end; }

.ap-list__cover {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.ap-list__name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}
.ap-list__desc {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Inline icon button used in list actions */
.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.icon-btn:hover {
  background: var(--cream-100);
  color: var(--ink);
  border-color: var(--border-default);
}
.icon-btn--danger:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

@media (max-width: 900px) {
  .ap-list__head,
  .ap-list__row {
    grid-template-columns: 40px 48px minmax(180px, 1fr) 80px 80px;
  }
  .ap-list__cell--time:nth-child(6) { display: none; }   /* hide 建立時間 */
  .ap-list__cell--actions { grid-column: 5 / 6; }
  .ap-list__head .ap-list__cell--actions { display: none; }
}

/* ==========================================================================
   Browse mode unified list (square thumb + metadata)
   ========================================================================== */
.browse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-5);
}

.browse-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  color: inherit;
  text-decoration: none;
  transition: transform var(--transition-fast);
}
.browse-item:hover { transform: translateY(-2px); }

.browse-item__thumb {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--cream-200);
  position: relative;
  transition: box-shadow var(--transition-fast);
}
.browse-item:hover .browse-item__thumb { box-shadow: var(--shadow-md); }
.browse-item__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.browse-item__thumb-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: var(--text-sm);
  padding: var(--space-3);
  text-align: center;
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-family: var(--font-display);
}
.browse-item__kind-pill {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: #1F2A44;     /* always dark navy text (pill bg is always near-white) */
  letter-spacing: -0.005em;
}
/* Dark-mode: dark pill with light text instead */
[data-theme="dark"] .browse-item__kind-pill {
  background: rgba(31, 42, 68, 0.90);
  color: #F2F4F8;
  backdrop-filter: blur(6px);
}

.browse-item__label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
  min-height: 2.6em;
  letter-spacing: -0.01em;
}

.browse-item__meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: 1.4;
}
.browse-item__meta-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
}
.browse-item__project {
  font-weight: 500;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

/* ==========================================================================
   Multi-select combobox (data source picker + pack picker)
   ========================================================================== */
.multi-select { position: relative; }
.multi-select__trigger {
  min-height: 44px;
  padding: 6px 8px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--cream-0);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
.multi-select__trigger:hover { border-color: var(--primary); }
.multi-select.is-open .multi-select__trigger {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}
.multi-select__chips {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 80px;
}
.multi-select__chips .chip {
  padding: 3px 6px 3px 10px;
}
.multi-select__chips .chip button {
  margin-left: 4px;
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  opacity: 0.7;
}
.multi-select__chips .chip button:hover { opacity: 1; background: rgba(0,0,0,0.08); }
.multi-select__placeholder {
  color: var(--text-tertiary);
  padding: 4px 6px;
  font-size: 13px;
}
.multi-select__caret {
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
}

.multi-select__panel {
  position: absolute;
  z-index: 50;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 320px;
  background: var(--cream-0);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.multi-select__search-wrap {
  padding: 8px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  position: relative;
}
.multi-select__search {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 13px;
  outline: none;
  background: var(--cream-50);
}
.multi-select__search:focus { border-color: var(--primary); background: var(--cream-0); }
.multi-select__search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}
.multi-select__list {
  overflow-y: auto;
  flex: 1;
}
.ms-group { border-bottom: 1px solid var(--border-subtle); }
.ms-group:last-child { border-bottom: none; }
.ms-group__header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--cream-50);
  font-size: 11px;
  font-weight: 700;
  color: var(--cream-700);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
  z-index: 1;
}
.ms-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  position: relative;
}
.ms-info:hover .ms-info__popover { display: block; }
.ms-info__popover {
  display: none;
  position: absolute;
  top: 120%;
  left: 0;
  z-index: 10;
  background: var(--ink);
  color: white;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 400;
  width: 260px;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.5;
  box-shadow: var(--shadow-md);
}
.ms-info__popover strong { color: white; display: block; margin-bottom: 6px; }
.ms-info__popover ul { margin: 0; padding-left: 18px; }
.ms-info__popover li { margin-bottom: 2px; }

.ms-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition-fast);
  border: none;
  width: 100%;
  text-align: left;
  background: transparent;
}
.ms-option:hover { background: var(--cream-50); }
.ms-option input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
}
.ms-option__label {
  flex: 1;
  color: var(--ink);
}
.ms-option__meta {
  font-size: 11px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}
.ms-option__party {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ms-option__party--1st { background: var(--primary-soft); color: var(--primary); }
.ms-option__party--3rd { background: var(--cream-200); color: var(--cream-700); }

.ms-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* Segmented control for modal tabs */
.seg-control {
  display: inline-flex;
  background: var(--cream-100);
  border-radius: var(--radius-full);
  padding: 3px;
  margin-bottom: var(--space-5);
}
.seg-control__btn {
  padding: 7px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--cream-700);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background: transparent;
}
.seg-control__btn.is-active {
  background: var(--cream-0);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Skip / caution notice in wizard step 3 */
.skip-warning {
  margin-top: var(--space-4);
  padding: 12px 14px;
  background: var(--warning-soft);
  border: 1px solid var(--tertiary);
  border-radius: var(--radius-md);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink);
}
.skip-warning svg {
  color: var(--tertiary);
  flex-shrink: 0;
  margin-top: 2px;
}
.skip-warning strong { color: var(--ink); }

/* Credit warning notice (used in modal footer area) */
.cost-notice {
  padding: 10px 14px;
  background: var(--primary-soft);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink);
  margin-top: var(--space-3);
}
.cost-notice svg { color: var(--primary); flex-shrink: 0; }
.cost-notice strong {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--primary);
}

/* ==========================================================================
   Dropzone / Image Composer / Variant Grid
   ========================================================================== */
.dropzone {
  padding: var(--space-6);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--cream-50);
  text-align: center;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 160px;
  justify-content: center;
}
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dropzone.has-source {
  padding: var(--space-4);
  background: var(--cream-0);
  border-style: solid;
  border-color: var(--border-subtle);
}

/* Banner-ratio dropzone (1200 × 628 = 1.91 : 1) */
.dropzone-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.banner-frame {
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1200 / 628;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--cream-50);
  box-shadow: 0 2px 8px rgba(31, 42, 68, 0.06);
  position: relative;
  transition: all var(--transition-fast);
}
.banner-frame--empty {
  border-style: dashed;
  border-color: var(--border-default);
  background: var(--cream-50);
}
.dropzone-banner.dragover .banner-frame {
  border-color: var(--primary);
  border-style: solid;
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.banner-frame__hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
}
.banner-frame__label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0;
}
.banner-frame__change {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 5px 10px;
  background: rgba(31, 42, 68, 0.88);
  color: white;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background var(--transition-fast);
}
.banner-frame__change:hover { background: var(--ink); }

/* Bento-style fluid grid: 12 cols, each variant spans cols/rows by aspect-ratio */
.variant-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 56px;
  gap: 10px;
  grid-auto-flow: dense;
}

.variant-cell {
  position: relative;
  background: var(--cream-100);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  cursor: grab;
  display: block;
  min-width: 0;
}
.variant-cell:hover { border-color: var(--border-default); }
.variant-cell.dragover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.variant-cell[data-overridden="1"] {
  border-color: var(--tertiary);
  box-shadow: 0 0 0 2px var(--tertiary-soft);
}

/* Image fills entire cell */
.variant-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Meta overlay badge: size (bold) + platform label, bottom-left, small */
.variant-cell__badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  line-height: 1.2;
  max-width: calc(100% - 16px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.variant-cell__badge strong {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: #1F2A44;
  letter-spacing: 0;
}
.variant-cell__badge span {
  color: #5E5E58;
  font-size: 10px;
}
/* Dark-mode: use dark pill with light text */
[data-theme="dark"] .variant-cell__badge {
  background: rgba(31, 42, 68, 0.90);
}
[data-theme="dark"] .variant-cell__badge strong { color: #F2F4F8; }
[data-theme="dark"] .variant-cell__badge span { color: #C8CDD9; }

/* Swap button: top-right, shows on hover */
.variant-cell__swap {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 4px 8px;
  background: rgba(31, 42, 68, 0.88);
  color: white;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  cursor: pointer;
  border: none;
}
.variant-cell:hover .variant-cell__swap { opacity: 1; }

/* Small cells (ultra-short banners): hide badge on hover to clean up */
.variant-cell--thin .variant-cell__badge {
  font-size: 10px;
  padding: 2px 8px;
}
.variant-cell--thin .variant-cell__badge span { display: none; }

@media (max-width: 900px) {
  .variant-grid { grid-template-columns: repeat(6, 1fr); }
  .variant-cell { /* spans still apply but clamp to 6 */ }
}

/* Design picker */
.design-pick {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform var(--transition-fast);
}
.design-pick:hover { transform: translateY(-2px); }
.design-pick__img {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--cream-200);
  border: 1px solid var(--border-subtle);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.design-pick:hover .design-pick__img {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.design-pick__img img { width: 100%; height: 100%; object-fit: cover; }
.design-pick__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
}

/* Media library item */
.media-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: transform var(--transition-fast);
}
.media-item:hover { transform: translateY(-2px); }
.media-item__thumb {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--cream-200);
  border: 1px solid var(--border-subtle);
  position: relative;
}
.media-item__thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-item__count {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 3px 8px;
  background: rgba(31, 42, 68, 0.85);
  color: white;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}
.media-item__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-item__meta {
  font-size: 11px;
  color: var(--text-tertiary);
}
.media-item.is-selected .media-item__thumb {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

/* ==========================================================================
   KPI Card (big-screen data viz style)
   ========================================================================== */
.kpi-card {
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
  transition: border-color var(--transition-base);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  /* Subtle blue accent bar on the left edge */
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  opacity: 0.9;
}
.kpi-card:hover { border-color: var(--primary); }
.kpi-card .stat__label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cream-600);
  font-weight: 700;
}
.kpi-card .stat__value {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--primary);       /* Primary blue (米色版藍字) */
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Home / Dashboard
   ========================================================================== */
.home-kpi {
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all var(--transition-fast);
}
.home-kpi:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(42, 127, 255, 0.10);
  transform: translateY(-1px);
}
.home-kpi--bonus {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.home-kpi__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.home-kpi__value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.home-kpi__delta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.home-kpi__bar {
  height: 4px;
  background: var(--cream-200);
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 8px;
}
.home-kpi__bar > div { height: 100%; }
.home-kpi__pill {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  background: var(--warning-soft);
  color: var(--tertiary-hover);
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 700;
}

.home-steps {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}
@media (max-width: 800px) {
  .home-steps { grid-template-columns: 1fr; }
}
.home-step {
  display: grid;
  grid-template-columns: 28px 32px 1fr;
  gap: 12px;
  align-items: flex-start;
}
.home-step__n {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}
.home-step__icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--cream-50);
  border-radius: var(--radius-md);
}
.home-step__body strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--ink);
}
.home-step__body p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.home-usage__num {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
  line-height: 1;
}
.home-usage__num span {
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 14px;
}
.home-usage__label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-top: 2px;
}

.home-task-card {
  background: var(--cream-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
}
.home-task-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(42, 127, 255, 0.08);
}

/* ==========================================================================
   Plan Grid & Pack Grid (upgrade / buy credits)
   ========================================================================== */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.plan-grid--6 {
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
@media (max-width: 1200px) {
  .plan-grid--6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .plan-grid { grid-template-columns: repeat(2, 1fr); }
  .plan-grid--6 { grid-template-columns: repeat(2, 1fr); }
}

.plan-card {
  background: var(--cream-0);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-fast);
}
.plan-grid--6 .plan-card { padding: 14px 10px 10px; gap: 8px; }
.plan-grid--6 .plan-card__name { font-size: 15px; }
.plan-grid--6 .plan-card__name-en { font-size: 10px; }
.plan-grid--6 .plan-card__price-num { font-size: 18px; }
.plan-grid--6 .plan-card__price-original { font-size: 11px; }
.plan-grid--6 .plan-card__allowance strong { font-size: 14px; }
.plan-grid--6 .plan-card__allowance { padding: 8px; font-size: 11px; }
.plan-grid--6 .plan-card__adcredit strong { font-size: 14px; }
.plan-grid--6 .plan-card__adcredit { padding: 6px 8px; }
.plan-grid--6 .plan-card__features { font-size: 11px; gap: 4px; }
.plan-grid--6 .plan-card__ribbon { font-size: 9px; padding: 3px 7px; }
.plan-card:hover { border-color: var(--primary); }

.plan-card--popular {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(42, 127, 255, 0.12);
}
.plan-card--current {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.plan-card__ribbon {
  position: absolute;
  top: 0;
  right: 0;
  padding: 4px 10px;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-bottom-left-radius: var(--radius-md);
}
.plan-card__ribbon--current { background: var(--ink); }
.plan-card__ribbon--discount { background: var(--tertiary); }
.plan-card--discount { border-color: var(--tertiary); }

.plan-card__head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.plan-card__name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.plan-card__name-en {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.plan-card__price {
  padding: 10px 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.plan-card__price-num {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.plan-card__price-unit {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.plan-card__price-original {
  font-size: 12px;
  color: var(--text-tertiary);
  text-decoration: line-through;
  font-family: var(--font-display);
  margin-bottom: 2px;
}

.plan-card__allowance {
  padding: 10px 12px;
  background: var(--cream-50);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--ink);
  text-align: center;
}
.plan-card__allowance strong {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.plan-card--current .plan-card__allowance { background: var(--cream-0); }

/* Ad credit pill inside a plan card */
.plan-card__adcredit {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--warning-soft);
  border: 1px solid var(--tertiary);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.plan-card__adcredit-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.plan-card__adcredit strong {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: var(--tertiary-hover);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.plan-card__adcredit-hint {
  font-size: 10px;
  color: var(--cream-700);
}

.plan-card__features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--cream-700);
  line-height: 1.4;
}
.plan-card__features li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.plan-card__features li svg { flex-shrink: 0; margin-top: 2px; }

/* Pack Grid */
.pack-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 900px) {
  .pack-grid { grid-template-columns: repeat(2, 1fr); }
}

.pack-card {
  background: var(--cream-0);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 20px 16px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.pack-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(42, 127, 255, 0.14);
}
.pack-card--recommended {
  border-color: var(--tertiary);
}

.pack-card__badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 8px;
  background: var(--tertiary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
}

.pack-card__credits {
  font-family: var(--font-display);
  color: var(--primary);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-top: 6px;
}
.pack-card__credits strong {
  font-size: 38px;
  font-weight: 800;
}
.pack-card__credits span {
  font-size: 14px;
  font-weight: 600;
  margin-left: 4px;
  color: var(--ink);
}

.pack-card__price {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-top: 4px;
}

.pack-card__unit {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 6px 0;
  border-top: 1px solid var(--border-subtle);
  margin-top: 10px;
}
.pack-card__unit strong {
  font-family: var(--font-display);
  color: var(--ink);
  font-size: 14px;
  margin: 0 2px;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes agent-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ==========================================================================
   RWD — Tablet + narrow overrides (placed at end for cascade precedence)
   ========================================================================== */
@media (max-width: 1100px) {
  .workapp__right { display: none; }          /* Hide right chat on tablet */
  .workapp { grid-template-columns: auto 1fr; }
  .workapp__header { grid-column: 1 / -1; }
  .workapp__main { grid-column: 2; }
  .workapp__bottom-bar { grid-column: 2; }

  /* Audience list: drop # and 建立時間 to fit tablet width */
  .ap-list__head,
  .ap-list__row {
    grid-template-columns: 56px minmax(220px, 1fr) 110px 150px 96px;
  }
  .ap-list__head > .ap-list__cell--idx,
  .ap-list__row > .ap-list__cell--idx { display: none; }
  .ap-list__head > .ap-list__cell--time:first-of-type,
  .ap-list__row > .ap-list__cell--time:first-of-type { display: none; }

  /* Invoice list: drop 付款方式 + 付款日 */
  .invoice-list__head,
  .invoice-list__row {
    grid-template-columns: 90px 120px 120px 90px minmax(0, 1fr);
  }
  .invoice-list__head > div:nth-child(n+5),
  .invoice-list__row > div:nth-child(n+5) { display: none; }
  .invoice-list__head > div:nth-child(7),
  .invoice-list__row > div:nth-child(7) { display: flex; justify-content: flex-end; }

  .task-header__row { flex-wrap: wrap; }
  .browse-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* Narrow tablet — shrink sidebar */
@media (max-width: 900px) {
  :root { --sidebar-width: 220px; }
}
