/* Portal layout — composes /shared/styles.css. */

/* ─── Sign-in screens ────────────────────────────────────────── */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-6);
  background:
    radial-gradient(60% 50% at 20% 0%,   rgba(85,70,255,0.06), transparent 70%),
    radial-gradient(50% 40% at 100% 80%, rgba(85,70,255,0.04), transparent 70%),
    var(--bg);
}
.auth-card {
  background: var(--bg-elevated);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: var(--s-8) var(--s-8);
  max-width: 420px; width: 100%;
}
.auth-card .brandhead {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: var(--s-6); gap: var(--s-2);
}
.auth-card .brandhead img { width: 44px; height: 44px; }
.auth-card .brandhead h1 { font-size: var(--fs-2xl); margin-top: var(--s-2); }
.auth-card .brandhead p  { color: var(--ink-soft); font-size: var(--fs-sm); margin-top: 2px; }
.auth-card .switch { margin-top: var(--s-5); padding-top: var(--s-5); border-top: 1px solid var(--border-soft); text-align: center; color: var(--ink-soft); font-size: var(--fs-sm); }

/* ─── App shell ──────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 60px;
  display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-5);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: var(--s-2); font-weight: 700; font-size: var(--fs-md); color: var(--ink); }
.topbar .brand img { width: 26px; height: 26px; }
.topbar .crumbs { display: flex; align-items: center; gap: var(--s-2); color: var(--ink-soft); font-size: var(--fs-sm); margin-left: var(--s-3); }
.topbar .crumbs .sep { color: var(--ink-faint); }
.topbar .spacer { flex: 1; }
.topbar .who-block { display: flex; align-items: center; gap: var(--s-3); }
.topbar .who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.topbar .who .name { font-weight: 600; font-size: var(--fs-sm); }
.topbar .who .role { font-size: 11px; color: var(--ink-soft); }

.navtoggle { display: none; }

.layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: calc(100vh - 60px);
}
.side {
  border-right: 1px solid var(--border);
  padding: var(--s-5) var(--s-3);
  background: var(--bg-elevated);
  position: sticky; top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side a {
  display: flex; align-items: center; gap: var(--s-3);
  height: 40px; padding: 0 var(--s-3);
  border-radius: var(--r-md);
  color: var(--ink-soft); text-decoration: none;
  font-weight: 500; font-size: var(--fs-base);
  transition: background 120ms ease, color 120ms ease;
}
.side a:hover  { background: var(--bg-sunken); color: var(--ink); text-decoration: none; }
.side a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.side a .ico   { font-size: 16px; width: 20px; text-align: center; line-height: 1; }

.content {
  padding: var(--s-8) clamp(var(--s-5), 4vw, var(--s-10)) var(--s-12);
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}
.list li { min-width: 0; }
.list li > div { min-width: 0; }
.topbar .who .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; display: inline-block; }
@media (max-width: 920px) {
  .topbar .who .name { max-width: 110px; }
  .content { padding: var(--s-5) var(--s-4) var(--s-10); }
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4);
  margin-bottom: var(--s-6); flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 var(--s-1); }
.page-head .subtitle { color: var(--ink-soft); font-size: var(--fs-sm); margin: 0; max-width: 720px; }
.page-head .actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ─── Stat tiles ─────────────────────────────────────────────── */
.stats { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: var(--s-5); }
.stat  { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-4) var(--s-5); }
.stat .label { font-size: 11px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value { font-size: var(--fs-2xl); font-weight: 700; line-height: 1.1; margin-top: var(--s-1); color: var(--ink); }

/* ─── Two-pane (Users / Groups) ──────────────────────────────── */
.pane { display: grid; grid-template-columns: 264px minmax(0,1fr); gap: var(--s-5); align-items: start; }
@media (max-width: 920px) { .pane { grid-template-columns: 1fr; } }
.pane-list { display: flex; flex-direction: column; gap: var(--s-2); }
.pane-list button {
  display: block; width: 100%; text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4); min-height: 60px;
  cursor: pointer;
  font-family: inherit; color: var(--ink);
  transition: border-color 120ms ease, background 120ms ease;
  box-shadow: var(--shadow-sm);
}
.pane-list button .name { font-weight: 600; font-size: var(--fs-base); }
.pane-list button:hover  { background: var(--bg-sunken); }
.pane-list button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.pane-list button.active .name { color: var(--accent-ink); }
.pane-list .sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.pane-list .empty { padding: var(--s-4); border: 1px dashed var(--border); border-radius: var(--r-md); color: var(--ink-soft); text-align: center; font-size: var(--fs-sm); }

/* ─── Board editor ───────────────────────────────────────────── */
.editor-toolbar {
  display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap;
  background: var(--accent-soft);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  margin-bottom: var(--s-4);
}
.editor-toolbar .label { color: var(--accent-ink); font-weight: 600; font-size: var(--fs-sm); }
.tile-list { display: flex; flex-direction: column; gap: var(--s-3); }
.tile-card { border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-4); background: var(--bg-elevated); }
.tile-head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.tile-head .swatch {
  width: 52px; height: 52px; border-radius: var(--r-md); flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.tile-head .swatch img { width: 100%; height: 100%; object-fit: cover; }
.tile-head .title { flex: 1; font-weight: 600; font-size: var(--fs-md); color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-head .controls { display: flex; gap: var(--s-1); }
.tile-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-3); align-items: end; }
.tile-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-4); align-items: center; }
.tile-actions .sep { width: 1px; height: 22px; background: var(--border); margin: 0 var(--s-1); }

.swatches { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--s-2); }
.swatches .sw {
  width: 24px; height: 24px; border-radius: 6px;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15);
  cursor: pointer; padding: 0;
}
.swatches .sw:hover { transform: scale(1.12); }

.file-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--ctrl-h-sm); padding: 0 var(--ctrl-px);
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--ink);
  font-weight: 600; font-size: var(--fs-sm); cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.file-btn:hover { background: var(--bg-sunken); }
.file-btn input { display: none; }

.rec-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ─── Library picker ─────────────────────────────────────────── */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: var(--s-3);
  max-height: 56vh; overflow-y: auto;
  padding: 2px;
}
.library-grid button {
  padding: var(--s-3) var(--s-2); text-align: center; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-elevated);
  display: flex; flex-direction: column; align-items: center; gap: var(--s-1);
  transition: border-color 120ms ease, background 120ms ease, transform 80ms ease;
  font-family: inherit;
}
.library-grid button:hover { border-color: var(--accent); background: var(--accent-soft); }
.library-grid button:active { transform: translateY(1px); }
.library-grid .em { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: var(--r-sm); font-size: 22px; box-shadow: var(--shadow-sm); }
.library-grid .ln { font-size: var(--fs-xs); font-weight: 600; }

/* ─── Preview iframe ────────────────────────────────────────── */
.preview-wrap { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: var(--s-5); align-items: start; }
@media (max-width: 1180px) { .preview-wrap { grid-template-columns: 1fr; } }
.preview-iframe {
  width: 100%; aspect-ratio: 9/16;
  border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
  background: #F7F3EC;
  box-shadow: var(--shadow-md);
}
.preview-iframe iframe { width: 100%; height: 100%; border: 0; }
.preview-meta { margin-top: var(--s-3); color: var(--ink-soft); font-size: var(--fs-xs); text-align: center; }

/* ─── QR / modal helpers ─────────────────────────────────────── */
.qr-frame { background: #fff; padding: var(--s-3); border-radius: var(--r-md); display: inline-block; border: 1px solid var(--border); }
.qr-frame svg { display: block; width: 240px; height: 240px; }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg-sunken); border: 1px solid var(--border); padding: 4px 8px; border-radius: var(--r-sm); font-size: var(--fs-sm); }
.kbd.big { font-size: var(--fs-xl); padding: 8px 14px; letter-spacing: 0.15em; font-weight: 600; }
.qr-card { text-align: center; }

/* ─── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: var(--s-5); left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: #fff;
  padding: 10px var(--s-4);
  border-radius: var(--r-md);
  font-weight: 600; font-size: var(--fs-sm);
  opacity: 0; transition: all 220ms ease;
  z-index: 300; pointer-events: none;
  box-shadow: var(--shadow-pop);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad  { background: var(--danger); }

/* Empty state */
.empty-state {
  text-align: center; padding: var(--s-10) var(--s-6);
  color: var(--ink-soft);
}
.empty-state .em { font-size: 36px; margin-bottom: var(--s-3); display: block; }
.empty-state h3 { color: var(--ink); margin-bottom: var(--s-2); }
.empty-state p  { margin: 0 auto; max-width: 360px; font-size: var(--fs-sm); }

/* ─── Mobile nav ─────────────────────────────────────────────── */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .side {
    position: fixed; top: 60px; left: 0; bottom: 0; width: 280px; z-index: 25;
    transform: translateX(-100%); transition: transform 200ms ease;
    border-right: 1px solid var(--border);
  }
  .side.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .navtoggle { display: inline-flex; }
  .topbar .brand span { display: none; }
  .topbar .crumbs { display: none; }
  .topbar .who .role { display: none; }
}
.scrim { position: fixed; inset: 60px 0 0 0; background: rgba(14,21,37,.32); z-index: 24; display: none; }
.scrim.show { display: block; }

/* Make the board-picker pills wrap predictably (one or two per row on phone). */
@media (max-width: 600px) {
  /* Reduce overall padding on cards so content has room. */
  .card, .section { padding: var(--s-4); }
}

/* ─── Phone-friendly action rows ────────────────────────────────────
   On screens narrower than 600px (= iPhone portrait, ~390px), every
   row of action buttons becomes a 2-column grid where each button takes
   exactly half the width. No more ragged wraps. */
@media (max-width: 600px) {

  /* Card header: title on its own row, actions below as a grid. */
  .card-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--s-3);
  }
  .card-header .actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s-2);
    width: 100%;
  }
  .card-header .actions > .btn,
  .card-header .actions > a.btn {
    width: 100%;
    justify-content: center;
    padding-left: var(--s-2);
    padding-right: var(--s-2);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Page-head actions: full-width column buttons. */
  .page-head {
    gap: var(--s-3);
  }
  .page-head .actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-2);
    width: 100%;
  }
  .page-head .actions > .btn,
  .page-head .actions > a.btn {
    width: 100%;
    justify-content: center;
  }

  /* Generic in-card action rows: opt-in via .actions-stack class. */
  .actions-stack {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--s-2) !important;
    width: 100%;
  }
  .actions-stack > .btn,
  .actions-stack > a.btn,
  .actions-stack > label.btn {
    width: 100%;
    justify-content: center;
    padding-left: var(--s-2);
    padding-right: var(--s-2);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* …unless the button has the .full class, then it spans the row. */
  .actions-stack > .full {
    grid-column: 1 / -1;
  }

  /* Tile-card head/controls: keep ↑ ↓ ✕ icon buttons on one tight line. */
  .tile-head .controls { gap: 2px; }
  .tile-head .controls .iconbtn { width: 32px; height: 32px; }

  /* Form-grid: stack to single column on phone. */
  .form-grid {
    grid-template-columns: 1fr !important;
  }

  /* Stat tiles: 2-up on phone instead of cramming. */
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Kebab / overflow menu ──────────────────────────────────────
   Compact dropdown for secondary actions, so action rows aren't
   walls of buttons. Built on native <details>/<summary> for free
   keyboard + accessibility support. */
.kebab {
  position: relative;
  display: inline-block;
}
.kebab > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.kebab > summary::-webkit-details-marker { display: none; }
.kebab > summary::marker { display: none; }
.kebab-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 40;
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.kebab-menu > button,
.kebab-menu > a {
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}
.kebab-menu > button:hover,
.kebab-menu > a:hover {
  background: var(--bg-sunken);
}
.kebab-menu > .danger { color: var(--danger); }
.kebab-menu > hr {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 4px 4px;
}

/* ─── Analytics dashboard ────────────────────────────────────── */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
.an-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
}
.an-card .label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.an-card .value { font-size: 28px; font-weight: 700; margin-top: 2px; }
.an-card .delta { font-size: 12px; margin-top: 4px; }
.an-card .delta.up    { color: var(--success, #16A34A); }
.an-card .delta.down  { color: var(--danger,  #DC2626); }
.an-card .delta.flat  { color: var(--ink-soft); }
.an-bar {
  height: 6px;
  background: var(--bg-sunken);
  border-radius: 3px;
  overflow: hidden;
}
.an-bar > span {
  display: block;
  height: 100%;
  background: var(--accent, #5546FF);
  border-radius: 3px;
}
.an-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.an-table th, .an-table td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-soft);
}
.an-table th { font-weight: 600; color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.an-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ─── Board-type picker (Basic vs Advanced) ──────────────────────── */
.bt-card {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  transition: border-color 120ms, transform 120ms, box-shadow 120ms;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.bt-card:hover {
  border-color: var(--accent, #5546FF);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.bt-card .bt-preview {
  background: #F7F3EC;
  border-radius: var(--r-sm);
  padding: 14px;
  margin-bottom: var(--s-2);
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bt-grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 6px;
  width: 100%;
  height: 100%;
}
.bt-grid-2x2 span {
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.08);
}
.bt-adv {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; gap: 6px;
}
.bt-adv-bar {
  display: flex; gap: 4px; align-items: stretch;
  height: 26px;
}
.bt-adv-bar span {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
.bt-adv-bar .bt-act      { background: #16A34A; color: #fff; border-radius: 6px; padding: 0 6px; }
.bt-adv-bar .bt-sentence { flex: 1; background: #fff; border-radius: 6px; padding: 0 8px; color: #888; }
.bt-adv-bar .bt-say      { background: #2B2B2B; color: #fff; border-radius: 6px; padding: 0 8px; }
.bt-adv-cats {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}
.bt-adv-cats span {
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.bt-card .bt-title { font-weight: 700; font-size: 16px; color: var(--ink); }
.bt-card .bt-desc  { color: var(--ink-soft); font-size: 13px; line-height: 1.5; flex: 1; }
.bt-card .bt-foot  { color: var(--ink-faint); font-size: 11px; font-style: italic; margin-top: 4px; }

@media (max-width: 600px) {
  #btPair { grid-template-columns: 1fr !important; }
  .bt-card .bt-preview { height: 110px; }
}

/* ─── Advanced-board tile: variants input ──────────────────────── */
.tile-variants {
  margin-top: var(--s-2);
  padding: var(--s-2) var(--s-3);
  background: var(--bg-sunken);
  border-radius: var(--r-sm);
  border-left: 3px solid var(--accent, #5546FF);
}
.tile-variants input {
  background: var(--bg-elevated);
  margin-top: 4px;
}
