/* ==========================================================================
   ClassConnect Online — Brand bridge for the in-app board.
   Loaded LAST. Moves the app's chrome (top bar, dock, modals, buttons,
   inputs, admin console) onto the same lighthouse palette and typography
   as the landing page, so signing in feels like the same product.
   Widgets keep their glass look and per-widget accent colours (--wc).
   ========================================================================== */

:root {
  --brand: #22406A;
  --brand-light: #8DB4E8;
  --brand-dark: #1B3354;
  --brand-text: #1B3354;
  --navy: #1B3354;
  --ink: #1B2A41;
  --text: #1B2A41;
  --muted: #4A5568;
  --panel2: #F2F5FA;
  --border: #D6DFEB;
  --ok: #0F6E63;
  --danger: #B53A26;
  --bar: rgba(27, 51, 84, .86);
  --accent2: #C8452F;
  --glass: rgba(251, 248, 243, .88);
  --glass-strong: rgba(251, 248, 243, .97);
  --shadow: 0 18px 44px rgba(14, 23, 38, .26);
  --shadow-sm: 0 5px 16px rgba(14, 23, 38, .14);
  --cc-font-sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --cc-font-serif: "Newsreader", Georgia, serif;
}
body.dark {
  --brand-text: #8DB4E8;
  --panel: #16223A;
  --panel2: #0E1726;
  --text: #EEF2F7;
  --muted: #A9B6C8;
  --border: #2A3B57;
  --glass: rgba(22, 34, 58, .88);
  --glass-strong: rgba(22, 34, 58, .97);
}

/* One typeface family across landing and app (Inter was never loaded). */
html, body { font-family: var(--cc-font-sans); }

/* Default board background: lighthouse sky → navy, with a sunlight glow. */
#background { background: linear-gradient(140deg, #8DB4E8, #22406A); }
#background::before { background: radial-gradient(circle, #FDF6DC 0%, transparent 65%); }
#background::after { background: radial-gradient(circle, #1B2A41 0%, transparent 65%); }

/* ---------- Chrome buttons: flat brand, like the landing ---------- */
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #FFFFFF;
  text-shadow: none;
}
.btn.primary:hover { background: var(--brand-dark); filter: none; box-shadow: var(--shadow-sm); }
body.dark .btn.primary { background: #8DB4E8; border-color: #8DB4E8; color: #0E1726; }
/* Inside widgets the primary button keeps its widget colour. */
.widget .btn.primary {
  background: var(--wc);
  border-color: color-mix(in srgb, var(--wc) 80%, #000);
  color: var(--wc-fg, #fff);
}
.widget .btn.primary:hover { background: color-mix(in srgb, var(--wc) 88%, #000); }

.btn.small { min-height: 34px; }
.inp { min-height: 38px; }
.inp:focus { outline-color: var(--brand); }
.widget .inp:focus { outline-color: var(--wc); }

/* ---------- Modals: same paper card + serif heading as onboarding ---------- */
.modal-back { background: rgba(14, 23, 38, .55); }
.modal { border-radius: 16px; }
.modal-head h3 {
  font-family: var(--cc-font-serif);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--brand);
}
body.dark .modal-head h3 { color: var(--text); }

/* ---------- Widgets: bigger hit areas for interactive whiteboards ---------- */
.w-btn { position: relative; width: 34px; height: 34px; }
.w-btn::after { content: ""; position: absolute; inset: -5px; }   /* ≈44px touch target */
.w-btn svg { width: 16px; height: 16px; }
.w-title { font-size: 12.5px; }
.w-resize { width: 30px; height: 30px; }
@media (hover: none) {
  .w-btn:active { background: color-mix(in srgb, var(--brand) 20%, transparent); }
}

/* ---------- Plan / demo status strip ---------- */
.cc-plan-banner {
  position: fixed; z-index: 60; left: 12px; bottom: 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  max-width: min(300px, calc(100vw - 24px)); justify-content: flex-start;
  padding: 10px 12px; border-radius: 14px;
  font: 500 13px/1.3 var(--cc-font-sans);
  background: rgba(251, 248, 243, .96); color: #1B2A41;
  border: 1px solid rgba(34, 64, 106, .18);
  box-shadow: 0 8px 22px rgba(14, 23, 38, .18);
}
.cc-plan-banner b { font-weight: 700; }
.cc-plan-banner.is-demo { border-color: #F5C242; }
.cc-plan-banner.is-soon { border-color: #C8452F; }
.cc-plan-banner.is-expired { background: #FDE8E3; border-color: #C8452F; }
.cc-plan-cta {
  min-height: 32px; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(34, 64, 106, .22); background: transparent; color: #22406A;
  font: 600 12.5px/1 var(--cc-font-sans);
}
.cc-plan-cta.is-primary { background: #22406A; border-color: #22406A; color: #fff; }
.cc-plan-cta:focus-visible { outline: 2px solid #C8452F; outline-offset: 2px; }

@media (max-width: 1360px) {
  .cc-plan-banner { left: 50%; bottom: auto; top: 58px; transform: translateX(-50%); max-width: calc(100vw - 24px); border-radius: 999px; padding: 6px 6px 6px 14px; }
}
/* Phones/tablets: sit just under the top bar (never over the dock or widget buttons) */
@media (max-width: 820px) {
  .cc-plan-banner {
    top: calc(env(safe-area-inset-top, 0px) + 62px); bottom: auto;
    width: max-content; max-width: calc(100vw - 24px);
    border-radius: 14px; padding: 6px 8px 6px 12px;
  }
  .cc-plan-cta { min-height: 44px; padding: 6px 14px; }
}
/* Collapse (×) button and collapsed pill (markup from app.js renderPlanBanner) */
.cc-plan-banner .cc-plan-min {
  min-width: 32px; min-height: 32px; padding: 4px 6px !important;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px !important; opacity: .7;
}
.cc-plan-banner .cc-plan-min:hover { opacity: 1 !important; background: rgba(34, 64, 106, .1) !important; }
.cc-plan-banner .cc-plan-min:focus-visible { outline: 2px solid #C8452F; outline-offset: 2px; opacity: 1 !important; }
.cc-plan-banner.is-compact {
  width: max-content; padding: 4px; gap: 0;
  border-radius: 999px;
}
.cc-plan-banner.is-compact .cc-plan-cta { min-height: 32px; border: 0; font-weight: 700; }
@media (any-pointer: coarse) {
  .cc-plan-banner .cc-plan-min { min-width: 44px; min-height: 44px; }
  .cc-plan-banner.is-compact .cc-plan-cta { min-height: 44px; }
}
/* Demo boards have no cloud — hide the sync pill instead of showing "Offline". */
body.cc-demo #cloudStatusWrap { display: none; }

/* ---------- Website widget: Link Card & Smart Fallback Hint ---------- */
.cc-link-card {
  position: relative;
  height: 100%;
  width: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  background: var(--panel);
  overflow: auto;
}
.cc-link-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-right: 34px;
}
.cc-link-card-ico {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--panel2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.cc-link-card-fav {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 4px;
}
.cc-link-card-globe { font-size: 20px; line-height: 1; }
.cc-link-card-meta { min-width: 0; }
.cc-link-card-host {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cc-link-card-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}
.cc-link-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.cc-link-card-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  flex: 1 1 180px;
  min-width: 0;
}
.cc-link-card-open {
  min-height: 44px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
  max-width: 260px;
}
.cc-link-card-try {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--muted);
  font: 500 12.5px/1.3 var(--cc-font-sans);
  text-decoration: underline;
  cursor: pointer;
}
.cc-link-card-try:hover { color: var(--text); }
.cc-link-card-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.cc-link-card-qr { display: block; width: 108px; height: 108px; }
.cc-link-card-qr-cap {
  font-size: 11px;
  font-weight: 600;
  color: #334155;
}

.emb-fallback-hint {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 10px;
  border-radius: 8px;
  background: rgba(14, 23, 38, 0.84);
  color: #ffffff;
  font-size: 12px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}
.emb-fallback-hint .emb-to-card {
  min-height: 26px;
  padding: 2px 9px;
  font-size: 11.5px;
}
.emb-hint-close {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
  line-height: 1;
  padding: 2px 5px;
  cursor: pointer;
  border-radius: 4px;
}
.emb-hint-close:hover { color: #ffffff; background: rgba(255, 255, 255, 0.14); }

/* Google Docs/Slides/Sheets/Forms/Drive: always-on sharing hint (wraps on narrow widgets) */
.emb-google-hint { right: 8px; flex-wrap: wrap; line-height: 1.35; }
.emb-google-hint > span { flex: 1 1 200px; min-width: 0; }
.emb-google-hint .emb-hint-open { min-height: 28px; padding: 2px 10px; font-size: 11.5px; }

/* Public beta marker (landing nav + app top bar). */
.cc-beta-tag {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  padding: 2px 7px; border-radius: 999px;
  font: 700 10px/1.2 var(--cc-font-sans); letter-spacing: .06em; text-transform: uppercase;
  background: #F5C242; color: #1B2A41;
}
#brand .cc-beta-tag { margin-left: 4px; flex: none; }

/* ==========================================================================
   WEB-4: scale the board chrome on big boards (2560 / 4K).
   applyScale() sets --ui-scale (1 on laptops). Only chrome is zoomed — the
   canvas has its own zoom, so widget drag/resize maths are unchanged.
   Viewport-unit sizes are divided by the scale so zoomed bars never overflow.
   ========================================================================== */
#topBar,
#toolbar,
#toastRoot,
.cc-plan-banner,
#modalRoot .modal { zoom: var(--ui-scale, 1); }
#toolbar { max-width: calc(97vw / var(--ui-scale, 1)); }
#modalRoot .modal {
  width: calc(92vw / var(--ui-scale, 1));
  max-height: calc(86vh / var(--ui-scale, 1));
}
/* The admin console sizes itself to the viewport (portal.css) — never zoom it. */
#modalRoot .modal:has(.cc-admin-shell) { zoom: 1; }

/* ---------- WEB-3: "⋯" overflow for low-priority board controls ---------- */
#quickBar .q-more { display: none; }
.q-more-menu {
  position: fixed; z-index: 8600;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 200px; padding: 6px;
  background: var(--glass-strong); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow);
}
.q-more-menu button {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 8px 12px;
  background: none; border: 0; border-radius: 10px;
  color: inherit; font: 600 14px/1.2 var(--cc-font-sans); text-align: left; cursor: pointer;
}
.q-more-menu button:hover,
.q-more-menu button:focus-visible { background: color-mix(in srgb, var(--brand) 12%, transparent); outline: none; }
.q-more-menu button span { width: 20px; text-align: center; }

/* ---------- WEB-3: tablets & small laptops (≤ 900px) ---------- */
@media (max-width: 900px) {
  #quickBar .q-low { display: none; }
  #quickBar .q-more { display: flex; }
  #brand .brand-txt { display: none; }   /* keep logo + Beta tag */
  #brand { padding-right: 9px; }
  #toolbar { max-width: calc((100vw - 24px) / var(--ui-scale, 1)); overflow-x: auto; }
}
@media (min-width: 601px) and (max-width: 900px) {
  /* one row: brand · scrollable screens · controls (overrides portal.css wrap) */
  #topBar { flex-wrap: nowrap; }
  #topLeft { flex: 1 1 auto; max-width: none; min-width: 0; }
  #quickBar { flex: 0 0 auto; flex-wrap: nowrap; }
  #screensBar { min-width: 0; }
  .scr-folder-btn b { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------- WEB-5: phones (≤ 600px): controls on row 1, screens on row 2 ---------- */
@media (max-width: 600px) {
  #topBar { flex-wrap: wrap; row-gap: 8px; top: calc(env(safe-area-inset-top, 0px) + 10px); left: 10px; right: 10px; }
  #cloudStatusWrap { order: 1; }
  #quickBar {
    order: 1; margin-left: auto; flex: 0 1 auto;
    flex-wrap: nowrap; overflow-x: auto; max-width: 100%;
    scrollbar-width: none;
  }
  #topLeft { order: 2; flex: 1 1 100%; max-width: 100%; min-width: 0; }
  #screensBar { flex: 1 1 auto; min-width: 0; }
  .screens-nav { overflow: hidden; }
  .screens-tabs { overflow-x: auto; }
  .scr-folder-btn b { max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
  .cc-plan-banner { top: calc(env(safe-area-inset-top, 0px) + 116px); }
}
