/* =====================================================================
   Fable5 app skin — authenticated UI, both sites.
   Token-driven (loads after tokens.css + brand.css, before DB ThemeTokens()).
   Re-points the Landkit app theme's compiled palette at brand tokens and
   applies the refined-minimal chrome. Scope: layouts + shared components;
   screen-specific rules stay in each view's cluster pass.
   ===================================================================== */

body {
  font-family: var(--brand-font);
  background: var(--surface-1);
  color: var(--ink-2);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, .header-title { color: var(--ink-1); letter-spacing: var(--tracking-tight); }

/* ---- brand re-pointing (Landkit app bundle compiles #2c7be5) ---- */
a { color: var(--brand-600); }
a:hover { color: var(--brand-700); }
.text-primary { color: var(--brand-600) !important; }
.bg-primary { background-color: var(--brand-600) !important; }
.border-primary { border-color: var(--brand-600) !important; }

.btn-primary {
  background-color: var(--brand-600);
  border-color: var(--brand-600);
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: background-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background-color: var(--brand-700) !important;
  border-color: var(--brand-700) !important;
  box-shadow: var(--shadow-2);
}
.btn-success { background-color: var(--brand-600); border-color: var(--brand-600); border-radius: var(--radius-md); font-weight: 600; }
.btn-success:hover, .btn-success:focus { background-color: var(--brand-700); border-color: var(--brand-700); }
.btn-white, .btn-light { border-radius: var(--radius-md); }
.btn-outline-primary { color: var(--brand-600); border-color: var(--brand-300); border-radius: var(--radius-md); }
.btn-outline-primary:hover { background-color: var(--brand-600); border-color: var(--brand-600); }

/* ---- top nav ---- */
#topnav, .navbar {
  background: var(--surface-0);
  border-bottom: 1px solid var(--line);
}
#topnav .nav-link { color: var(--ink-2); font-weight: 500; }
#topnav .nav-link:hover, #topnav .nav-link.active { color: var(--brand-600); }

/* ---- cards ---- */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.card-header { background: transparent; border-bottom: 1px solid var(--line); }
.card-header-title { color: var(--ink-1); }

/* ---- forms ---- */
.form-control, .form-select {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink-1);
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px var(--brand-100);
}
.form-label { color: var(--ink-2); font-weight: 500; }
.form-check-input:checked { background-color: var(--brand-600); border-color: var(--brand-600); }

/* ---- dropdowns / modals / toasts ---- */
.dropdown-menu {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
}
.dropdown-item:hover { background: var(--brand-50); color: var(--brand-700); }
.modal-content { border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); }
.toast { border-radius: var(--radius-md); box-shadow: var(--shadow-3); }

/* ---- badges / pills ---- */
.badge.bg-primary, .badge.bg-primary-soft { border-radius: var(--radius-full); }
.badge.bg-primary { background-color: var(--brand-600) !important; }
.bg-primary-soft { background-color: var(--brand-50) !important; color: var(--brand-700) !important; }

/* ---- tables / lists ---- */
.table thead th { color: var(--ink-3); font-size: var(--text-xs); letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.list-group-item { border-color: var(--line); }

/* ---- auth pages ---- */
.bg-auth { background: var(--surface-1); }
.skin-fsb .bg-auth, .skin-fop .bg-auth {
  background:
    radial-gradient(1000px 480px at 85% -10%, var(--brand-50) 0%, transparent 60%),
    var(--surface-1);
}
.auth-card {
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
}

/* ---- AI accent stays violet on FSB / amber on FOP via tokens ---- */
.ai-accent { color: var(--brand-accent) !important; }
.bg-ai { background-color: color-mix(in srgb, var(--brand-accent) 10%, white) !important; }

/* ---- pagination / progress ---- */
.page-link { color: var(--brand-600); }
.page-item.active .page-link { background-color: var(--brand-600); border-color: var(--brand-600); }
.progress-bar { background-color: var(--brand-500); }

/* ---- auth split-panel (Fable5 auth redesign) ---- */
.auth-split { min-height: 100vh; width: 100%; display: flex; align-items: stretch; }
.auth-brand-panel {
  flex: 1 1 46%;
  display: none;
  position: relative;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(900px 600px at 20% 0%, color-mix(in srgb, var(--brand-500) 65%, var(--brand-700)) 0%, transparent 55%),
    linear-gradient(160deg, var(--brand-700) 0%, var(--brand-900) 90%);
  padding: var(--space-16) var(--space-12);
}
@media (min-width: 992px) { .auth-brand-panel { display: flex; flex-direction: column; justify-content: center; } }
.auth-brand-panel .brand-mark { height: 44px; width: auto; align-self: flex-start; margin-bottom: var(--space-10); color: #fff; }
.auth-home-logo { display: inline-block; margin-bottom: var(--space-6); line-height: 0; }
.auth-home-logo img { height: 28px; width: auto; display: block; }
.auth-brand-panel h2 { color: #fff; font-size: var(--text-2xl); font-weight: 700; letter-spacing: var(--tracking-display); max-width: 18ch; }
.auth-brand-panel h2 .mk-accent { color: var(--brand-300); }
.auth-brand-panel .auth-brand-sub { color: rgba(255,255,255,.75); font-size: var(--text-base); max-width: 42ch; margin-top: var(--space-3); }
.auth-brand-panel ul { list-style: none; padding: 0; margin-top: var(--space-8); }
.auth-brand-panel ul li { display: flex; gap: 10px; align-items: baseline; color: rgba(255,255,255,.85); margin-bottom: var(--space-3); font-size: var(--text-sm); }
.auth-brand-panel ul li::before { content: "✓"; color: rgba(255,255,255,.9); font-weight: 700; }
.auth-form-panel {
  flex: 1 1 54%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-4);
  background: var(--surface-1);
}
.auth-form-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  padding: var(--space-8);
}
.auth-form-card h1 { font-size: var(--text-xl); font-weight: 700; margin-bottom: var(--space-1); }
.auth-form-card .auth-sub { color: var(--ink-3); font-size: var(--text-sm); margin-bottom: var(--space-6); }
.auth-sso-divider { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: var(--text-xs); margin: var(--space-4) 0; }
.auth-sso-divider::before, .auth-sso-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-btn-sso {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface-0); color: var(--ink-1); font-weight: 600; font-size: var(--text-sm);
  padding: 10px 14px; margin-bottom: var(--space-2);
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.auth-btn-sso:hover { border-color: var(--brand-300); background: var(--brand-50); color: var(--ink-1); }

/* =====================================================================
   Fable5 cluster pass — dashboard + listing screens (APPENDED SECTION).
   Components introduced here: .page-head, .page-section, .section-head,
   .stat-row/.stat-card, .activity-feed/.activity-card, .box-card,
   .listing-filter, .empty-state. JS-coupled classes (.box, .activeBox,
   .archived, .boxContainer, .filter*, .timeago, .ai-unlock-trigger,
   .sentiment-locked-card, .dashboard-sentiment-info, .card.box) are kept
   in markup and only visually restyled here.
   ===================================================================== */

/* ---- page header band ---- */
.page-head {
  background: var(--surface-0);
  border-bottom: 1px solid var(--line);
  padding: var(--space-8) 0;
  margin-bottom: var(--space-8);
}
.page-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: var(--tracking-display);
  color: var(--ink-1);
  margin: 0;
}

/* ---- section scaffolding ---- */
.page-section { margin-bottom: var(--space-10); }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.section-title { font-size: var(--text-lg); font-weight: 700; color: var(--ink-1); margin: 0; }
.section-meta { color: var(--ink-3); font-size: var(--text-sm); white-space: nowrap; }

/* ---- stat cards (dashboard sentiment overview) ---- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}
@media (max-width: 767.98px) { .stat-row { grid-template-columns: minmax(0, 1fr); } }
.stat-card {
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: var(--space-5) var(--space-6);
  transition: box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.stat-card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.stat-card .sentiment-stat { padding: 0; }
.stat-card .sentiment-label {
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}
.stat-card .sentiment-number {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: 1.1;
  margin-bottom: 0;
}
/* locked (non-Pro) variant leans on custom.css .sentiment-locked-card
   (position:relative, overflow:hidden, .blurred filter) — hooks preserved */
.sentiment-locked-card .stat-card:hover { box-shadow: var(--shadow-1); transform: none; }

/* ---- activity feed ---- */
.activity-feed { display: flex; flex-direction: column; gap: var(--space-3); }
.activity-card {
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: var(--space-5) var(--space-6);
  transition: box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.activity-card:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
  border-color: var(--brand-200);
}
.activity-card-head { display: flex; align-items: flex-start; gap: var(--space-3); }
.activity-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--brand-50);
  color: var(--brand-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
}
.activity-main { flex: 1 1 auto; min-width: 0; }
.activity-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.activity-title { font-size: var(--text-base); font-weight: 600; margin: 0; }
.activity-title a { color: var(--ink-1); }
.activity-title a:hover { color: var(--brand-600); }
.activity-time { color: var(--ink-3); font-size: var(--text-xs); margin-top: 2px; }
.activity-quote {
  margin-top: var(--space-3);
  background: var(--surface-2);
  border-left: 3px solid var(--brand-200);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
}
.activity-quote + .activity-quote { margin-top: var(--space-2); }
.activity-quote pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--ink-2);
}
.activity-vote { margin-top: var(--space-2); color: var(--ink-2); font-size: var(--text-sm); }
.activity-card:hover .sentiment-locked { transform: scale(1.05); }
.cursor-pointer { cursor: pointer; }

/* ---- box/poll list cards ---- */
.boxContainer .box-card { margin-bottom: var(--space-4); }
.box-card {
  transition: box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.box-card:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
  border-color: var(--brand-200);
}
.box-card .card-body { padding: var(--space-5) var(--space-6); }
.box-card-row { display: flex; align-items: center; gap: var(--space-4); }
.box-card-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--brand-50);
  color: var(--brand-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
}
.box-card-main { flex: 1 1 auto; min-width: 0; }
.box-card-action { flex: 0 0 auto; }
.box-card-title { font-size: var(--text-base); font-weight: 600; margin: 0 0 2px; }
.box-card-title a { color: var(--ink-1); }
.box-card-title a:hover { color: var(--brand-600); }
.box-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  color: var(--ink-3);
  font-size: var(--text-sm);
}
.box-card-url {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.box-card-url a { color: var(--ink-3); }
.box-card-url a:hover { color: var(--brand-600); }
.box-chip {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 2px 10px;
  vertical-align: middle;
}
.box-card.archived { background: var(--surface-2); }
.box-card.archived .box-card-title a { color: var(--ink-3); }
.box-card.archived .box-chip { background: var(--surface-0); }

/* ---- listing filter (segmented control; nav/nav-link classes untouched) ---- */
.listing-filter { margin-bottom: var(--space-6); }
.listing-filter .nav-tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 4px;
}
.listing-filter .nav-tabs .nav-item { margin: 0; }
.listing-filter .nav-tabs .nav-link {
  border: 0;
  border-radius: var(--radius-full);
  padding: 6px 16px;
  color: var(--ink-3);
  font-weight: 600;
  font-size: var(--text-sm);
}
.listing-filter .nav-tabs .nav-link:hover { color: var(--ink-1); }
.listing-filter .nav-tabs .nav-link.active {
  background: var(--surface-0);
  color: var(--ink-1);
  box-shadow: var(--shadow-1);
  border: 0;
}
.listing-filter .nav-tabs .nav-link .badge {
  background: var(--brand-50) !important;
  color: var(--brand-700) !important;
  font-weight: 600;
  margin-left: 4px;
}

/* ---- empty states ---- */
.empty-state {
  background: var(--surface-0);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  text-align: center;
  padding: var(--space-16) var(--space-6);
}
.empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--brand-50);
  color: var(--brand-600);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: var(--space-4);
}
.empty-state h2 { font-size: var(--text-xl); margin-bottom: var(--space-2); }
.empty-state p { color: var(--ink-3); max-width: 46ch; margin: 0 auto var(--space-6); }
.empty-state .btn:last-child { margin-bottom: 0; }
.empty-state-sm { padding: var(--space-10) var(--space-5); }
.empty-state-sm .empty-state-icon { width: 44px; height: 44px; font-size: 18px; }
.empty-state-sm h2 { font-size: var(--text-lg); }
.empty-state-sm p { margin-bottom: 0; }

/* ---- listing toolbar: status tabs (left) + sort (right) ---- */
.listing-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}
.listing-toolbar .listing-filter { margin-bottom: 0; }
.listing-sort {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}
.listing-sort-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.listing-sort-select {
  border: 1px solid var(--line);
  background: var(--surface-0);
  color: var(--ink-1);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  padding: 6px 30px 6px 12px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.listing-sort-select:hover { border-color: var(--brand-300); }
.listing-sort-select:focus { outline: 2px solid var(--brand-400); outline-offset: 1px; }

/* ---- airy listing table ---- */
.listing-table-wrap { overflow-x: auto; }
.listing-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
}
.listing-table thead th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 var(--space-4) var(--space-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.listing-table tbody td {
  padding: var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.listing-table thead th { padding-left: var(--space-3); padding-right: var(--space-3); }
.listing-table tbody tr.box:hover { background: var(--surface-1); }
.listing-table .col-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-1); font-weight: 600; }
.listing-table thead .col-num { text-align: right; }
.listing-table .col-share { text-align: right; white-space: nowrap; }
.listing-table .col-activity { white-space: nowrap; color: var(--ink-3); }
.listing-table .col-sentiment { white-space: nowrap; }

.listing-name-link { font-weight: 600; color: var(--ink-1); }
.listing-name-link:hover { color: var(--brand-600); }
tr.box.archived .listing-name-link { color: var(--ink-3); }

/* ---- sentiment badge (readable; replaces the invisible .bg-ai on rows) ---- */
.sentiment-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  padding: 3px 10px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.sentiment-badge .fe-zap { font-size: 12px; }
.sentiment-positive {
  color: #0F7A47;
  background: color-mix(in srgb, var(--success) 14%, white);
  border-color: color-mix(in srgb, var(--success) 30%, white);
}
.sentiment-negative {
  color: #B42318;
  background: color-mix(in srgb, var(--danger) 12%, white);
  border-color: color-mix(in srgb, var(--danger) 28%, white);
}
.sentiment-neutral {
  color: #B54708;
  background: color-mix(in srgb, var(--warning) 14%, white);
  border-color: color-mix(in srgb, var(--warning) 30%, white);
}
.sentiment-none { color: var(--ink-3); background: transparent; }
.sentiment-locked {
  color: var(--brand-accent);
  background: color-mix(in srgb, var(--brand-accent) 8%, white);
  border-color: color-mix(in srgb, var(--brand-accent) 30%, white);
  cursor: pointer;
}
.sentiment-locked:hover {
  color: var(--brand-accent);
  background: color-mix(in srgb, var(--brand-accent) 14%, white);
}

/* ---- per-row share button + popover ---- */
.row-share-btn {
  border: 1px solid var(--line);
  background: var(--surface-0);
  color: var(--ink-2);
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.row-share-btn:hover { border-color: var(--brand-300); background: var(--brand-50); color: var(--brand-700); }

.list-share-pop { width: 340px; }
.list-share-title {
  font-weight: 700;
  color: var(--ink-1);
  margin-bottom: var(--space-3);
  padding-right: 16px;
}
.list-share-hint {
  font-size: var(--text-xs);
  color: var(--ink-3);
  margin: var(--space-2) 0 var(--space-4);
}
/* two columns so labels like "E-mail" never wrap or overflow at this width */
.list-share-pop .confirm-share-grid {
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: var(--space-4);
}
.list-share-pop .confirm-share-btn {
  justify-content: flex-start;
  padding: var(--space-2) var(--space-3);
}
.list-share-pop .confirm-share-btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-share-pop .confirm-qr { padding: var(--space-3); margin-bottom: 0; }
.list-share-pop .confirm-qr-img { width: 120px; height: 120px; }
.list-share-pop .confirm-qr-caption { font-size: var(--text-xs); }

/* colorful AI logo for the sentiment upsell (override the flat feature-upsell fill) */
.feature-upsell .hover-dialog-header .ai-icon.ai-icon-gradient {
  background: linear-gradient(135deg, #8B5CF6, #6b5eae);
}

@media (max-width: 576px) {
  .ai-upgrade-hover-dialog.list-share-pop.as-sheet,
  .ai-upgrade-hover-dialog.list-share-pop.as-sheet.show {
    position: fixed;
    left: 16px;
    right: 16px;
    top: 50%;
    width: auto;
    max-width: 360px;
    margin: 0 auto;
    transform: translateY(-50%);
  }
  .list-share-pop.as-sheet .hover-dialog-arrow { display: none; }
}

/* Mobile listing: sort defaults to Latest activity (no dropdown), drop the
   Last activity column; keep Name / Suggestions / Sentiment / Share visible. */
@media (max-width: 767px) {
  .listing-sort { display: none; }
  .listing-table .col-activity { display: none; }
}
