:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #66716a;
  --line: #d7ddd8;
  --surface: #ffffff;
  --band: #f3f6f2;
  --field: #ffffff;
  --topbar: rgba(255, 255, 255, 0.94);
  --danger-bg: #fff2f0;
  --danger-line: #f0b4aa;
  --danger-text: #8d2417;
  --accent: #176b5f;
  --accent-dark: #0f4a43;
  --gold: #c8902f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eff5f1;
  --muted: #a9b7ad;
  --line: #2e3b34;
  --surface: #121a16;
  --band: #0b100d;
  --field: #0e1511;
  --topbar: rgba(14, 21, 17, 0.94);
  --danger-bg: #321613;
  --danger-line: #7f3227;
  --danger-text: #ffd0c8;
  --accent: #4fb9a6;
  --accent-dark: #8be0d1;
  --gold: #e0b25c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--band);
  color: var(--ink);
}

a { color: inherit; text-decoration: none; }

input, textarea, button {
  font: inherit;
}

.topbar {
  align-items: center;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 64px;
  justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 48px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-size: 1.08rem;
  font-weight: 800;
}

.nav {
  align-items: center;
  display: flex;
  gap: 18px;
}

.nav form { margin: 0; }

.link-button {
  background: none;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}

.theme-toggle {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.button {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 750;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
}

.button:hover { background: var(--accent-dark); }

.button.secondary {
  background: transparent;
  color: var(--accent-dark);
}

.button.small {
  min-height: 36px;
  padding-inline: 14px;
}

.hero-home {
  align-items: center;
  background:
    linear-gradient(90deg, rgba(15, 24, 20, 0.78), rgba(15, 24, 20, 0.22)),
    url("default-banner.svg") center/cover;
  color: #fff;
  display: flex;
  min-height: calc(100vh - 160px);
  padding: clamp(38px, 8vw, 86px);
}

.hero-copy {
  max-width: 660px;
}

h1, h2 {
  letter-spacing: 0;
  line-height: 1.03;
  margin: 0;
}

.hero-copy h1 {
  font-size: clamp(3rem, 9vw, 7rem);
}

.hero-copy p {
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  line-height: 1.55;
  max-width: 560px;
}

.actions, .card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.section, .dashboard, .customizer {
  margin: 0 auto;
  max-width: 1180px;
  padding: clamp(24px, 5vw, 56px);
}

.section.narrow { max-width: 820px; }

.dashboard {
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
}

.muted {
  color: var(--muted);
  line-height: 1.6;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.panel.compact { align-self: start; }

.auth-shell {
  display: grid;
  min-height: calc(100vh - 64px);
  padding: 32px;
  place-items: center;
}

.auth-shell .panel {
  max-width: 440px;
  width: 100%;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.92rem;
  font-weight: 700;
  gap: 8px;
  margin: 18px 0;
}

input, textarea {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

textarea { resize: vertical; }

.error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  border-radius: 8px;
  color: var(--danger-text);
  padding: 12px;
}

.portal-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.portal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 20px;
}

.portal-card span {
  font-size: 1.1rem;
  font-weight: 800;
}

.portal-card small {
  color: var(--muted);
}

.card-title {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.card-title img {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 36px;
  object-fit: contain;
  padding: 5px;
  width: 36px;
}

.card-title span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-actions {
  margin-top: auto;
}

.card-actions a {
  color: var(--accent-dark);
  font-weight: 800;
}

.preview-wrap {
  margin-bottom: 24px;
}

.portal-hero {
  background-image:
    linear-gradient(90deg, rgba(15, 24, 20, var(--overlay)), rgba(15, 24, 20, calc(var(--overlay) * 0.55))),
    var(--desktop-banner);
  background-position: center, var(--focal-x) var(--focal-y);
  background-size: cover;
  color: #fff;
  min-height: min(620px, calc(100vh - 96px));
  position: relative;
}

.portal-hero.public {
  align-items: end;
  display: flex;
  padding: clamp(32px, 8vw, 80px);
}

.editable-hero {
  align-items: end;
  border-radius: 8px;
  cursor: crosshair;
  display: flex;
  min-height: 440px;
  overflow: hidden;
  padding: clamp(22px, 5vw, 52px);
}

.portal-hero-content {
  max-width: 780px;
}

.portal-hero-content p {
  font-weight: 850;
  margin: 0;
  text-transform: uppercase;
}

.portal-mark {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-bottom: 12px;
}

.portal-mark img {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  height: clamp(44px, 7vw, 72px);
  object-fit: contain;
  padding: 8px;
  width: clamp(44px, 7vw, 72px);
}

.portal-hero-content h1 {
  font-size: clamp(2.6rem, 8vw, 6.4rem);
  overflow-wrap: anywhere;
}

.portal-hero-content span {
  display: block;
  font-size: clamp(1rem, 2vw, 1.32rem);
  line-height: 1.5;
  margin-top: 18px;
  max-width: 640px;
}

.editor-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 460px);
}

.dropzone {
  align-items: center;
  border: 1px dashed #9aa8a0;
  border-radius: 8px;
  color: var(--accent-dark);
  cursor: pointer;
  justify-content: center;
  min-height: 92px;
  padding: 18px;
}

.dropzone input {
  border: 0;
  min-height: auto;
  padding: 8px 0 0;
}

.range-grid {
  display: grid;
  gap: 10px;
}

input[type="range"] {
  accent-color: var(--gold);
  padding: 0;
}

@media (max-width: 760px) {
  .dashboard, .editor-grid {
    grid-template-columns: 1fr;
  }

  .portal-hero {
    background-image:
      linear-gradient(0deg, rgba(15, 24, 20, var(--overlay)), rgba(15, 24, 20, calc(var(--overlay) * 0.45))),
      var(--mobile-banner);
    background-position: center, var(--mobile-focal-x) var(--mobile-focal-y);
    min-height: 500px;
  }

  .topbar {
    height: auto;
    min-height: 64px;
  }
}

.usage {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.pill {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 10px;
}

.crumbs {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 20px;
}

.crumbs a {
  color: var(--accent-dark);
  font-weight: 800;
}

.file-list {
  display: grid;
  gap: 12px;
  list-style: none;
  margin: 20px 0;
  padding: 0;
}

.file-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 16px;
}

.file-meta {
  align-items: baseline;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.file-meta a, .file-row > a {
  font-weight: 800;
}

.inline-form {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-form label {
  flex: 1 1 180px;
  margin: 0;
}

select {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

.share-box {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.grant-list, .plain-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.grant-list li, .plain-list li {
  align-items: center;
  display: flex;
  gap: 12px;
}

details summary {
  cursor: pointer;
  font-weight: 800;
}

.section .panel + .panel {
  margin-top: 16px;
}

.check {
  align-items: center;
  display: flex;
  gap: 8px;
  margin: 0;
}

.check input {
  min-height: auto;
  width: auto;
}

/* Premium branding */
.brand-header { display: flex; align-items: center; gap: 14px; min-height: 96px; padding: 18px 24px;
  background-color: var(--brand, #1f2937); background-size: cover; background-position: center; color: #fff; }
.brand-header .brand-logo { max-height: 56px; max-width: 200px; object-fit: contain; }
.brand-header .brand-name { font-size: 20px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
[style*="--accent"] .button { background: var(--accent); border-color: var(--accent); }

/* ---- Security level picker (Figma "Set Up Your First Portal": #193038 card, gold) ---- */
.level-picker {
  background: #193038;
  border: 1px solid #707070;
  border-radius: 8px;
  color: #f9fafa;
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 16px 18px 18px;
}
.level-picker legend {
  background: #193038;
  border-radius: 4px;
  font-weight: 700;
  padding: 2px 8px;
}
.level-option { color: #f9fafa; cursor: pointer; display: block; margin: 0; position: relative; }
.level-option input { height: 1px; left: 0; opacity: 0; pointer-events: none; position: absolute; top: 0; width: 1px; }
.level-card {
  align-items: center;
  border: 1.5px solid transparent;
  border-radius: 6px;
  display: flex;
  gap: 14px;
  padding: 8px 10px;
}
.level-card .shield { fill: #e7c36a; flex: 0 0 34px; height: 43px; opacity: 0.4; width: 34px; }
.level-text { color: #f9fafa; display: grid; font-weight: 400; gap: 2px; font-size: 0.86rem; line-height: 1.3; }
.level-text strong { font-size: 0.95rem; }
.level-option input:checked + .level-card { border-color: #e7c36a; }
.level-option input:checked + .level-card .shield { opacity: 1; }
.level-option input:focus-visible + .level-card { outline: 2px solid #f5d891; outline-offset: 2px; }
.level-option:hover .level-card .shield { opacity: 0.75; }
.level-password { color: #f9fafa; display: none; }
.level-password input { background: #fff; color: #0d0d0d; }
.level-note { color: #f5d891; display: none; font-size: 0.85rem; margin: 0; }
.level-picker:has(input[value="1"]:checked) .level-password { display: grid; }
.level-picker:has(input[value="3"]:checked) .level-note { display: block; }
.button.gold {
  background: linear-gradient(160deg, #e3c477 0%, #ffde8b 39%, #e9a86e 73%, #e3c477 100%);
  border: 1px solid #f5d891;
  color: #193038;
  font-weight: 700;
}
.level-badge {
  align-items: center;
  background: #193038;
  border-radius: 999px;
  color: #f9fafa;
  display: inline-flex;
  font-size: 0.8rem;
  gap: 6px;
  padding: 3px 10px 3px 6px;
}
.level-badge .shield { fill: #e7c36a; height: 18px; width: 14px; }
.portal-gate {
  background: #193038;
  border: 1px solid #707070;
  border-radius: 8px;
  color: #f9fafa;
  margin: 0 auto;
  max-width: 420px;
  padding: 22px;
}
.portal-gate .shield { fill: #e7c36a; height: 54px; width: 43px; }
.portal-gate input { background: #fff; color: #0d0d0d; }
.recovery-codes { columns: 2; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ==== Portal page file manager (Figma FigJam "Features": see-thru folders, dark teal + gold) ==== */
.sr-only {
  border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden;
  padding: 0; position: absolute; white-space: nowrap; width: 1px;
}
html:has(body.portal-page) { background: #172a30; }
body.portal-page {
  background: radial-gradient(120% 90% at 30% 40%, #2c434a 0%, #1f343a 45%, #172a30 100%);
  color: #f9fafa;
  min-height: 100vh;
}
body.portal-page .topbar { background: rgba(20, 36, 41, 0.92); border-bottom-color: rgba(255, 255, 255, 0.08); }
body.portal-page .topbar a, body.portal-page .topbar .link-button,
body.portal-page .brand { color: #f9fafa; }
body.portal-page .topbar .button.small { background: linear-gradient(160deg, #e3c477, #ffde8b 45%, #e9a86e); color: #193038; }
.portal-hero.compact { min-height: clamp(150px, 24vh, 240px); padding: clamp(20px, 4vw, 40px); }
.portal-hero.compact .portal-hero-content h1 { font-size: clamp(1.8rem, 4.5vw, 3rem); margin: 0; }
.portal-hero.compact .portal-hero-content span { margin-top: 6px; font-size: 1rem; }
.portal-door { color: #f9fafa; }
.portal-door .muted { color: #b8c6c9; }
.portal-door a:not(.button) { color: #f5d891; }

.fm {
  --fm-gold: #e7c36a;
  --fm-gold-hi: #f5d891;
  --fm-card: rgba(255, 255, 255, 0.055);
  --fm-card-hi: rgba(255, 255, 255, 0.1);
  --fm-line: rgba(255, 255, 255, 0.22);
  --fm-text: #f9fafa;
  --fm-muted: #a9bcc0;
  --fm-sel: rgba(231, 195, 106, 0.18);
  color: var(--fm-text);
  font-weight: 400;
  margin: 0 auto;
  max-width: 1180px;
  padding: 26px clamp(14px, 3vw, 36px) 120px;
  position: relative;
}
.fm button { font: inherit; }
.fm h2, .fm h3 { color: var(--fm-text); }
.fm-header { align-items: center; display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; }
.fm-title { align-items: center; display: flex; flex-wrap: wrap; gap: 12px; min-width: 0; }
.fm-portal-name { font-size: clamp(1.4rem, 3vw, 1.85rem); font-weight: 700; margin: 0; overflow-wrap: anywhere; }
.fm-level {
  align-items: center; border: 1px solid rgba(255, 255, 255, 0.55); border-radius: 3px;
  display: inline-flex; font-size: 0.78rem; gap: 5px; line-height: 1; padding: 3px 6px 3px 4px;
}
.fm-level .shield { fill: var(--fm-gold); height: 14px; width: 11px; }
.fm-level-wrap { display: inline-block; position: relative; }
.fm .fm-level-btn, .fm-level-btn { background: transparent; color: var(--fm-text); cursor: help; font-family: inherit; font-size: 0.78rem; }
.fm-level-btn:hover, .fm-level-btn[aria-expanded="true"] { border-color: var(--fm-gold); }
.fm-level-btn:focus-visible { outline: 2px solid var(--fm-gold-hi); outline-offset: 2px; }
.fm-level-help {
  background: #f9fafa; border-radius: 10px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45); color: #193038; font-size: 0.88rem;
  left: 0; padding: 14px 16px; position: absolute; top: calc(100% + 8px); width: min(340px, 86vw); z-index: 50;
}
.fm-level-help[hidden] { display: none; }
.fm-level-help-title { align-items: center; display: flex; gap: 8px; margin: 0 0 6px; }
.fm-level-help-title .shield { fill: #b98b2a; height: 20px; width: 16px; }
.fm-level-help ul { margin: 0; padding-left: 18px; }
.fm-level-help li { margin: 4px 0; }
.fm-level-you { border-top: 1px solid #e3e8e9; margin: 10px 0 0; padding-top: 8px; }
.fm-toolbar { align-items: center; display: flex; flex-wrap: wrap; gap: 6px; }
.fm-view { border: 1px solid var(--fm-line); border-radius: 6px; display: inline-flex; overflow: hidden; }
.fm-view .fm-tool { border: 0; border-radius: 0; }
.fm-view .fm-tool[aria-pressed="true"] { background: var(--fm-card-hi); color: var(--fm-gold-hi); }
.fm-tool, .fm-link, .fm-icon-btn {
  align-items: center; background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--fm-text); cursor: pointer; display: inline-flex; gap: 6px; min-height: 36px;
  padding: 6px 10px; text-decoration: none;
}
.fm-tool:hover, .fm-icon-btn:hover, .fm-link:hover { background: var(--fm-card-hi); }
.fm-tool:focus-visible, .fm-icon-btn:focus-visible, .fm-gold:focus-visible, .fm-plain:focus-visible,
.fm-outline:focus-visible, .fm-item-focus:focus-visible { outline: 2px solid var(--fm-gold-hi); outline-offset: 2px; }
.ui-icon { flex: none; height: 18px; width: 18px; }
.fm-gold {
  background: linear-gradient(160deg, #e3c477 0%, #ffde8b 39%, #e9a86e 73%, #e3c477 100%);
  border: 1px solid #f5d891; border-radius: 6px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  color: #1d3238; cursor: pointer; font-weight: 700; min-height: 38px; padding: 8px 18px;
  text-decoration: none;
}
.fm-gold:hover { filter: brightness(1.05); }
.fm-plain { background: transparent; border: 0; color: inherit; cursor: pointer; min-height: 38px; padding: 8px 14px; }
.fm-outline {
  background: transparent; border: 1px solid var(--fm-gold); border-radius: 5px; color: var(--fm-text);
  cursor: pointer; min-height: 34px; padding: 5px 12px;
}
.fm-outline.fm-danger, .fm-danger-btn { border-color: #e2545a; }
.fm-danger-btn { background: linear-gradient(180deg, #d63a3f, #a71e23); border-radius: 6px; color: #fff; cursor: pointer; font-weight: 700; min-height: 38px; padding: 8px 18px; }
.fm-danger { color: #ff9a9e; }
.fm-addnew { position: relative; }
.fm-menu {
  background: #20363d; border: 1px solid var(--fm-line); border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); display: grid; min-width: 200px; padding: 6px; z-index: 40;
}
.fm-addnew .fm-menu { position: absolute; right: 0; top: calc(100% + 6px); }
.fm-menu[hidden] { display: none; }
.fm-menu button {
  align-items: center; background: transparent; border: 0; border-radius: 5px; color: var(--fm-text);
  cursor: pointer; display: flex; gap: 10px; padding: 9px 10px; text-align: left; width: 100%;
}
.fm-menu button[hidden] { display: none; }
.fm-menu button:hover, .fm-menu button:focus-visible { background: var(--fm-card-hi); outline: none; }
.fm-menu kbd, .fm-keys kbd {
  border: 1px solid var(--fm-line); border-radius: 3px; color: var(--fm-muted); font-size: 0.72rem;
  margin-left: auto; padding: 1px 5px;
}
.fm-context { position: fixed; }
.fm-selbar {
  align-items: center; background: #20363d; border: 1px solid var(--fm-gold); border-radius: 8px;
  bottom: 20px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); display: flex; flex-wrap: wrap; gap: 4px;
  left: 50%; max-width: calc(100vw - 24px); padding: 4px 8px; position: fixed; transform: translateX(-50%);
  z-index: 45; /* floats, so selecting never shifts the listing under the pointer */
}
.fm-selbar[hidden] { display: none; }
.fm-selbar [data-selcount] { font-weight: 600; margin-right: 8px; }
.fm-tool[hidden] { display: none; }

.fm-crumbs { margin: 18px 0 4px; }
.fm-crumbs.is-root { height: 0; margin: 6px 0 0; overflow: hidden; }
.fm-crumbs ol { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
.fm-crumbs li { align-items: center; display: inline-flex; gap: 4px; }
.fm-crumbs li + li::before { color: var(--fm-muted); content: "/"; margin-right: 2px; }
.fm-crumbs a { border-radius: 4px; color: var(--fm-gold-hi); padding: 2px 4px; text-decoration: none; }
.fm-crumbs a, .fm-crumbs [aria-current] { display: inline-block; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; white-space: nowrap; }
.fm-crumbs a:focus-visible, .fm-crumb-expand:focus-visible { outline: 2px solid var(--fm-gold-hi); outline-offset: 1px; }
.fm-crumbs .fm-crumb-hidden { display: none; }
.fm-crumbs.is-expanded .fm-crumb-hidden { display: inline-flex; }
.fm-crumb-expand { background: var(--fm-card); border: 1px solid var(--fm-line); border-radius: 4px; color: var(--fm-text);
  cursor: pointer; font: inherit; line-height: 1; min-height: 24px; padding: 2px 8px; }
.fm-crumb-expand:hover { background: var(--fm-card-hi); }
.fm-crumbs a:hover { text-decoration: underline; }
.fm-crumbs [aria-current] { color: var(--fm-text); font-weight: 600; padding: 2px 4px; }
.fm-items { outline: none; }
.fm-section { margin-top: 18px; }
.fm-heading {
  border-bottom: 1px solid var(--fm-line); font-size: 1.15rem; font-weight: 700; margin: 0 0 18px; padding: 0 14px 6px;
}

/* see-thru folders: a translucent folder shape that shows the first few items inside */
.fm-folders { display: grid; gap: 22px 26px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.fm-folder {
  /* Figma folder silhouette: full-height label side, stepped-down notch at top right */
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.045));
  border-radius: 10px; clip-path: polygon(0 0, 74% 0, 80% 20px, 100% 20px, 100% 100%, 0 100%);
  cursor: default; min-height: 158px; outline: none; padding: 12px 16px 14px; position: relative;
  user-select: none;
}
.fm-folder-tab { display: none; }
.fm-folder-head { align-items: center; display: flex; gap: 6px; justify-content: space-between; padding-right: 22%; position: relative; }
.fm-folder .fm-kebab { position: absolute; right: -10px; top: 14px; }
.fm-folder-name { color: var(--fm-text); font-weight: 700; overflow: hidden; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.fm-folder-name:hover { text-decoration: underline; }
.fm-peek {
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
  color: #cfdcde; font-size: 0.86rem; list-style: none; margin: 10px 0 0; mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
  max-height: 96px; overflow: hidden; padding: 0;
}
.fm-peek li { align-items: center; display: flex; gap: 6px; line-height: 1.55; overflow: hidden; white-space: nowrap; }
.fm-peek li span { overflow: hidden; text-overflow: ellipsis; }
.fm-peek-empty { color: var(--fm-muted); font-style: italic; }
.fm-peek-more { bottom: 8px; color: var(--fm-muted); font-size: 0.75rem; position: absolute; right: 14px; }
.fm-folder:hover { background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.07)); }
.fm-folder.is-selected { background: linear-gradient(180deg, rgba(231, 195, 106, 0.3), rgba(231, 195, 106, 0.16)); }
.fm-folder:focus-visible { background: linear-gradient(180deg, rgba(245, 216, 145, 0.26), rgba(245, 216, 145, 0.12)); box-shadow: inset 0 0 0 2px var(--fm-gold-hi); }
.is-drop-target { box-shadow: 0 0 0 2px var(--fm-gold-hi) !important; background: rgba(231, 195, 106, 0.22) !important; }

/* file icons, Figma colours */
.fi { flex: none; }
.fi-sm { height: 16px; width: 14px; }
.fi-md { height: 22px; width: 19px; }
.fi-lg { height: 46px; width: 40px; }
.fi-folder { color: var(--fm-gold); height: 18px; width: 22px; }
.fi-lg.fi-folder { height: 40px; width: 48px; }
.fi-word, .fi-text { color: #5ec4cf; }
.fi-sheet { color: #4fd18b; }
.fi-pdf { color: #f0626a; }
.fi-ae { color: #c674ee; }
.fi-ps { color: #4ab1ff; }
.fi-ai { color: #ff9a3c; }
.fi-slides { color: #f2894e; }
.fi-image { color: #8fd3ff; }
.fi-video { color: #b39dff; }
.fi-audio { color: #ffd166; }
.fi-archive { color: #d9c08a; }
.fi-code { color: #9be7c4; }
.fi-file, .fi-lock { color: #c9d6d8; }

/* files: list view (Figma) */
.fm-files { display: grid; }
.fm-file {
  align-items: center; border: 1px solid transparent; border-radius: 6px; cursor: default; display: grid;
  gap: 12px; grid-template-columns: 22px minmax(0, 1fr) 90px 120px 36px; min-height: 46px; outline: none;
  padding: 4px 8px 4px 14px; user-select: none;
}
.fm-file:hover { background: var(--fm-card); }
.fm-file.is-selected { background: var(--fm-sel); border-color: rgba(231, 195, 106, 0.6); }
.fm-file:focus-visible { box-shadow: inset 0 0 0 2px var(--fm-gold-hi); }
.fm-check {
  border: 1.5px solid var(--fm-line); border-radius: 4px; cursor: pointer; height: 18px; width: 18px;
}
.fm-file.is-selected .fm-check { background: var(--fm-gold); border-color: var(--fm-gold);
  box-shadow: inset 0 0 0 3px #22393f; }
.fm-thumb { display: none; }
.fm-mini { border-radius: 3px; flex: none; height: 24px; overflow: hidden; width: 24px; }
.fm-mini img { display: block; height: 100%; object-fit: cover; width: 100%; }
.fm-file-main { align-items: center; display: flex; gap: 8px; min-width: 0; }
.fm-name { color: #dfe8e9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.fm-name { cursor: pointer; text-decoration: none; }
a.fm-name:hover { color: var(--fm-text); text-decoration: underline; text-underline-offset: 2px; }
.fm-file, .fm-folder { cursor: default; user-select: none; -webkit-user-select: none; }
.fm-decrypted::after { content: " 🔒"; font-size: 0.8em; }
.fm-size, .fm-date { color: var(--fm-muted); font-size: 0.9rem; text-align: right; white-space: nowrap; }
.fm-kebab {
  background: transparent; border: 0; border-radius: 5px; color: #d5e1e3; cursor: pointer;
  height: 32px; padding: 0; width: 32px;
}
.fm-kebab:hover, .fm-kebab:focus-visible { background: var(--fm-card-hi); color: var(--fm-text); outline: none; }
.fm-folder .fm-kebab { height: 28px; width: 28px; }

/* files: grid view with thumbnails */
.fm-body[data-view="grid"] .fm-files { gap: 16px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.fm-body[data-view="grid"] .fm-file {
  background: var(--fm-card); grid-template-columns: 1fr auto; grid-template-rows: auto auto auto;
  padding: 8px; position: relative;
}
.fm-body[data-view="grid"] .fm-check { left: 10px; position: absolute; top: 10px; z-index: 1; }
.fm-body[data-view="grid"] .fm-file:not(.is-selected):not(:hover):not(:focus-visible) .fm-check { opacity: 0; }
.fm-body[data-view="grid"] .fm-thumb {
  align-items: center; aspect-ratio: 4 / 3; background: rgba(0, 0, 0, 0.18); border-radius: 4px;
  display: flex; grid-column: 1 / -1; justify-content: center; overflow: hidden; position: relative;
}
.fm-thumb img { height: 100%; inset: 0; object-fit: cover; position: absolute; width: 100%; }
.fm-body[data-view="grid"] .fm-file-main { grid-column: 1; }
.fm-body[data-view="grid"] .fm-file-main .fi { display: none; }
.fm-body[data-view="grid"] .fm-mini { display: none; }
.fm-body[data-view="grid"] .fm-size { grid-column: 1; grid-row: 3; text-align: left; font-size: 0.8rem; }
.fm-body[data-view="grid"] .fm-date { display: none; }
.fm-body[data-view="grid"] .fm-kebab { grid-column: 2; grid-row: 2 / span 2; }

.fm-empty { border: 1.5px dashed var(--fm-line); border-radius: 12px; color: var(--fm-muted); margin-top: 24px; padding: 44px 20px; text-align: center; }
.fm-empty strong { color: var(--fm-text); }
.fm-empty p { margin: 6px auto; max-width: 46ch; }
.fm-empty-title { color: var(--fm-text); font-size: 1.1rem; font-weight: 700; }
.fm-empty-icon { align-items: center; background: rgba(231, 195, 106, 0.12); border-radius: 50%; color: var(--fm-gold);
  display: inline-flex; height: 56px; justify-content: center; margin-bottom: 6px; width: 56px; }
.fm-empty-icon .ui-icon { height: 28px; width: 28px; }
.fm-empty-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px !important; }
.fm-empty-actions button { align-items: center; display: inline-flex; gap: 6px; min-height: 40px; }
.fm-hint { align-items: center; color: var(--fm-muted); display: flex; font-size: 0.84rem; gap: 8px; justify-content: center; margin: 28px 0 8px; }
.fm-hint .ui-icon { color: var(--fm-gold); height: 16px; width: 16px; }
.fm-hint kbd, .fm-level-help kbd { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--fm-line); border-radius: 3px; font-size: 0.78rem; padding: 0 4px; }
@media (pointer: coarse) { .fm-hint { display: none; } }

/* list column header (list view only) */
.fm-file-head { color: var(--fm-muted); display: grid; font-size: 0.74rem; gap: 12px; grid-template-columns: 22px minmax(0, 1fr) 90px 120px 36px;
  letter-spacing: 0.04em; padding: 6px 8px 2px 14px; text-transform: uppercase; }
.fm-file-head span:nth-child(3), .fm-file-head span:nth-child(4) { text-align: right; }
.fm-body[data-view="grid"] .fm-file-head { display: none; }

/* drag and drop */
.fm-dropzone {
  align-items: center; background: rgba(15, 30, 35, 0.78); border: 3px dashed var(--fm-gold);
  display: flex; inset: 0; justify-content: center; pointer-events: none; position: fixed; z-index: 60;
}
.fm-dropzone[hidden] { display: none; }
.fm-dropzone > div { color: var(--fm-text); font-size: 1.2rem; text-align: center; }
.fm-dropzone .ui-icon { color: var(--fm-gold); height: 56px; width: 56px; }

/* upload panel */
.fm-uploads {
  background: #20363d; border: 1px solid var(--fm-line); border-radius: 10px; bottom: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); max-height: 50vh; overflow: auto; position: fixed; right: 18px;
  width: min(380px, calc(100vw - 36px)); z-index: 50;
}
.fm-uploads[hidden] { display: none; }
.fm-uploads header { align-items: center; border-bottom: 1px solid var(--fm-line); display: flex; justify-content: space-between; padding: 8px 8px 8px 14px; position: sticky; top: 0; background: #20363d; }
.fm-uploads ul { list-style: none; margin: 0; padding: 4px 0; }
.fm-up { align-items: center; display: grid; gap: 2px 8px; grid-template-columns: 1fr auto auto; padding: 8px 10px 8px 14px; }
.fm-up-name { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-up-status { color: var(--fm-muted); font-size: 0.78rem; }
.fm-up progress { accent-color: var(--fm-gold); grid-column: 1 / 3; height: 6px; width: 100%; }
.fm-up .fm-icon-btn { grid-column: 3; grid-row: 1 / 3; min-height: 28px; padding: 2px 8px; }
.fm-up.is-done .fm-icon-btn, .fm-up.is-failed .fm-icon-btn, .fm-up.is-cancelled .fm-icon-btn { visibility: hidden; }
.fm-up.is-done .fm-up-status { color: #6fdc9b; }
.fm-up.is-failed .fm-up-status { color: #ff9a9e; white-space: normal; grid-column: 1 / 3; }
.fm-up .fm-up-retry { grid-column: 3; grid-row: 1 / 3; min-height: 30px; padding: 2px 10px; }
.fm-up-total { border-bottom: 1px solid var(--fm-line); display: grid; gap: 4px; padding: 8px 14px 10px; }
.fm-up-total progress { accent-color: var(--fm-gold); height: 8px; width: 100%; }
.fm-up-total small { color: var(--fm-muted); font-size: 0.78rem; }
.fm-uploads:not(.is-busy) .fm-up-total progress { accent-color: #6fdc9b; }

.fm-toast {
  align-items: center; background: #f9fafa; border-radius: 8px; bottom: 76px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  color: #193038; display: flex; gap: 14px; left: 50%; padding: 10px 16px; position: fixed; transform: translateX(-50%); z-index: 70;
}
.fm-toast[hidden] { display: none; }
.fm-toast button { background: transparent; border: 0; color: #a0661a; cursor: pointer; font-weight: 700; }

/* dialogs (Figma "Invite People by Email": white card, grey footer, gold action) */
.fm-dialog {
  background: #fff; border: 1px solid #3c86d8; border-radius: 6px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  color: #1f2a2d; max-width: calc(100vw - 24px); padding: 0; width: 420px;
}
.fm-dialog-wide { width: 640px; }
.fm-dialog::backdrop { background: rgba(8, 18, 21, 0.6); }
.fm-dialog form { display: grid; gap: 12px; padding: 22px 24px 0; }
.fm-dialog h2 { color: #1f2a2d; font-size: 1.1rem; margin: 0 0 4px; overflow-wrap: anywhere; }
.fm-dialog h3, .fm-dialog .fm-subhead { color: #1f2a2d; font-size: 0.95rem; margin: 6px 0 0; }
.fm-dialog label { color: #33464b; font-size: 0.9rem; font-weight: 500; gap: 6px; margin: 0; }
.fm-dialog input, .fm-dialog select, .fm-dialog textarea {
  background: #fff; border: 1px solid #c8d0d2; border-radius: 4px; color: #1f2a2d; font: inherit; padding: 8px 10px; width: 100%;
}
.fm-dialog input:focus, .fm-dialog select:focus, .fm-dialog textarea:focus { border-color: #3c86d8; outline: 2px solid rgba(60, 134, 216, 0.25); }
.fm-dialog footer {
  background: #c9d0d4; display: flex; gap: 12px; justify-content: space-between; margin: 10px -24px 0; padding: 12px 24px;
}
.fm-dialog footer .fm-plain { color: #33464b; }
.fm-dialog .fm-outline { color: #1f2a2d; }
.fm-muted { color: #6b7b80; font-size: 0.86rem; margin: 0; }
.fm-error { background: #fff0f0; border: 1px solid #f2b8bb; border-radius: 4px; color: #9b1c22; font-size: 0.88rem; margin: 0; padding: 8px 10px; }
.fm-error[hidden] { display: none; }
.fm-tree { border: 1px solid #c8d0d2; border-radius: 4px; max-height: 300px; overflow: auto; padding: 6px; }
.fm-tree-row { align-items: center; border-radius: 4px; cursor: pointer; display: flex !important; gap: 8px; padding: 6px 6px 6px calc(6px + var(--depth) * 18px); }
.fm-tree-row:hover { background: #eef3f4; }
.fm-tree-row input { width: auto; }
.fm-tree-row.is-current { color: #8a989c; }
.fm-share-grid { display: grid; gap: 10px 14px; grid-template-columns: 1fr 1fr; }
.fm-check-label { align-items: center; display: flex !important; flex-direction: row; gap: 8px; }
.fm-check-label input { width: auto; }
.fm-copy { display: flex; gap: 8px; }
.fm-copy .fm-gold { white-space: nowrap; }
.fm-share-result { background: #f2f7f2; border-radius: 6px; padding: 10px; }
.fm-links { display: grid; gap: 6px; list-style: none; margin: 0; max-height: 220px; overflow: auto; padding: 0; }
.fm-links li { align-items: center; border-bottom: 1px solid #e6eaeb; display: flex; gap: 8px; justify-content: space-between; padding: 6px 0; }
.fm-links li > span { flex: 1; font-size: 0.88rem; }
.fm-team-cols { display: grid; gap: 18px; grid-template-columns: 1fr 1.4fr; }
.fm-team-help h3 { margin: 0; }
.fm-team-help p { color: #4b5d62; font-size: 0.85rem; margin: 2px 0 12px; }
.fm-members { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.fm-members li { align-items: center; display: grid; gap: 8px; grid-template-columns: 38px 1fr auto auto; }
.fm-avatar { align-items: center; background: #21c3a3; border-radius: 50%; color: #133238; display: flex; font-weight: 700; height: 38px; justify-content: center; width: 38px; }
.fm-who { display: grid; min-width: 0; }
.fm-who strong, .fm-who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-who small { color: #6b7b80; }
.fm-warn { color: #b0541a !important; }
.fm-members select { width: auto; border-color: var(--fm-gold, #e7c36a); }
.fm-role-fixed { color: #6b7b80; font-size: 0.82rem; grid-column: 3 / 5; }
.fm-invite { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.fm-preview { width: min(960px, calc(100vw - 24px)); }
.fm-preview form { padding: 0; }
.fm-preview header { align-items: center; display: flex; gap: 10px; padding: 10px 12px 10px 18px; }
.fm-preview header h2 { flex: 1; margin: 0; }
.fm-preview .fm-icon-btn { color: #1f2a2d; }
.fm-preview img { background: #0f1d21; display: block; max-height: 78vh; object-fit: contain; width: 100%; }
.fm-keys { display: grid; gap: 6px 14px; grid-template-columns: auto 1fr; margin: 0; }
.fm-keys dt { white-space: nowrap; }
.fm-keys dd { margin: 0; }
.fm-keys kbd { color: #33464b; margin: 0; }
.fm-lock-form { display: inline; margin: 0; }
.fm-link { color: var(--fm-gold-hi); font-size: 0.85rem; min-height: 28px; padding: 2px 6px; }
.fm-link .ui-icon { height: 14px; width: 14px; }

@media (max-width: 760px) {
  .fm-tool-label { display: none; }
  .fm-file { grid-template-columns: 22px minmax(0, 1fr) 44px; }
  .fm-file-head { display: none; }
  .fm-size, .fm-date { display: none; }
  .fm-crumbs a, .fm-crumbs [aria-current] { max-width: 14ch; }
  .fm-body[data-view="grid"] .fm-size { display: block; }
  .fm-folders { gap: 20px 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .fm-share-grid, .fm-team-cols, .fm-invite { grid-template-columns: 1fr; }
  .fm-members li { grid-template-columns: 38px 1fr; }
  .fm-members select, .fm-members .fm-outline { grid-column: 2; justify-self: start; }
}
@media (pointer: coarse) {
  /* 44px touch targets */
  .fm-kebab { height: 44px; width: 44px; }
  .fm-file { min-height: 56px; }
  .fm-tool, .fm-icon-btn, .fm-gold, .fm-outline, .fm-plain { min-height: 44px; min-width: 44px; justify-content: center; }
  .fm-check { height: 22px; width: 22px; }
  .fm-crumbs a, .fm-crumbs [aria-current], .fm-crumb-expand { min-height: 36px; padding: 8px 6px; }
  .fm-level-btn { min-height: 32px; }
}
@media (prefers-reduced-motion: no-preference) {
  .fm-folder, .fm-file { transition: background-color 120ms, border-color 120ms; }
}

/* Dashboard: "Your Portals" cards (Figma). Each card opens the portal page file manager. */
.yp-head { align-items: center; border-bottom: 1px solid rgba(127, 127, 127, 0.45); display: flex;
  flex-wrap: wrap; gap: 12px; justify-content: space-between; padding-bottom: 6px; }
.yp-head h2 { margin: 0; }
.yp-head .fm-gold { display: inline-flex; align-items: center; }
.yp-head .fm-gold:focus-visible { outline: 2px solid #f5d891; outline-offset: 2px; }
.yp-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 14px; }
.yp-card {
  background: linear-gradient(180deg, #2b4249, #20363d); border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); color: #f9fafa; display: flex;
  flex-direction: column; gap: 8px; min-height: 124px; padding: 18px 22px 14px; position: relative;
}
.yp-card:hover { border-color: rgba(231, 195, 106, 0.6); }
.yp-card h3 { font-size: 1.05rem; margin: 0; }
.yp-open { align-items: center; color: inherit; display: flex; gap: 8px; text-decoration: none; }
.yp-open::after { content: ""; inset: 0; position: absolute; } /* whole card is the link */
.yp-open:focus-visible { outline: none; }
.yp-card:focus-within { box-shadow: 0 0 0 2px #f5d891; }
.yp-open img { border-radius: 4px; height: 24px; object-fit: contain; width: 24px; }
.yp-card .fm-level { align-self: flex-start; }
.yp-card .fm-level .shield { fill: #e7c36a; height: 14px; width: 11px; }
.yp-label { color: #a9bcbf; font-size: 0.78rem; overflow-wrap: anywhere; }
.yp-actions { display: flex; gap: 14px; margin-top: auto; position: relative; z-index: 1; }
.yp-actions a { align-items: center; color: #c9d6d8; display: inline-flex; font-size: 0.85rem; gap: 5px; text-decoration: none; }
.yp-actions a:hover { color: #f5d891; text-decoration: underline; }
.yp-actions .ui-icon { height: 14px; width: 14px; }
.yp-go { color: #f5d891; font-size: 0.85rem; margin-left: auto; opacity: 0; transition: opacity 120ms; }
.yp-card:hover .yp-go, .yp-card:focus-within .yp-go { opacity: 1; }
.yp-empty { border: 1.5px dashed rgba(127, 127, 127, 0.5); border-radius: 12px; grid-column: 1 / -1; padding: 22px; text-align: center; }

/* Portal settings: Portal Team rows (Figma: teal initials, role, outlined actions) */
.pt-list { display: grid; gap: 8px; list-style: none; margin: 14px 0 18px; padding: 0; }
.pt-row { align-items: center; background: #1f343a; border-radius: 10px; color: #f9fafa; display: flex; flex-wrap: wrap; gap: 10px 14px; padding: 10px 14px; }
.pt-avatar { align-items: center; background: #21c3a3; border-radius: 50%; color: #10282d; display: inline-flex; flex: none; font-weight: 700; height: 38px; justify-content: center; width: 38px; }
.pt-who { display: grid; flex: 1 1 180px; min-width: 0; }
.pt-who strong, .pt-who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-who small { color: #a9bcbf; }
.pt-role { border: 1px solid #e7c36a; border-radius: 5px; font-size: 0.8rem; padding: 3px 8px; }
.pt-warn { background: rgba(255, 154, 158, 0.15); border-radius: 5px; color: #ffb3b6; font-size: 0.78rem; padding: 3px 8px; }
.pt-actions { display: inline-flex; gap: 8px; }
.pt-actions form { margin: 0; }
.pt-btn { background: transparent; border: 1px solid rgba(255, 255, 255, 0.45); border-radius: 5px; color: #f9fafa; cursor: pointer; font: inherit; font-size: 0.85rem; min-height: 34px; padding: 4px 12px; }
.pt-btn:hover { border-color: #f5d891; }
.pt-btn:focus-visible { outline: 2px solid #f5d891; outline-offset: 2px; }
.pt-remove { border-color: #e2545a; }
.pt-remove:hover { background: rgba(226, 84, 90, 0.15); border-color: #e2545a; }
@media (pointer: coarse) { .pt-btn { min-height: 44px; } }
@media (max-width: 760px) {
  .fm-hint { display: none; }
  /* Keep the top bar from overlapping on phones. */
  .topbar { gap: 10px; }
  .brand { flex: none; }
  .nav { flex-wrap: nowrap; gap: 10px; font-size: 0.92rem; min-width: 0; }
}
