/* NuFlow shell — tokens alias the canonical palette in app.css */
:root {
  --gold: #BC9B6A;
  --stone: #BBB2A6;
  --sand: #F1E7DB;
  --sage: #606662;
  --terra: #904A2D;
  --ink: #252823;
  --muted: #797b75;
  --line: #e9e5de;
  --white: #fff;
  --shadow: 0 18px 45px rgba(54, 58, 53, .08);
  --nf-gold: var(--gold);
  --nf-sidebar: var(--sage);
  --nf-page: #f8f7f4;
  --nf-surface: var(--white);
  --nf-border: var(--line);
  --nf-text: var(--ink);
  --nf-muted: var(--muted);
  --nf-width: 224px;
  --nf-text-eyebrow: .72rem;
  --nf-text-label: .72rem;
  --nf-text-sm: .84rem;
  --nf-text-body: .875rem;
  --nf-text-md: .94rem;
  --nf-text-lg: 1.12rem;
  --nf-text-xl: 1.35rem;
  --nf-text-display: 1.65rem;
  --nf-text-page: 2rem;
}

body.nf-auth {
  margin: 0;
  background: var(--nf-page);
  color: var(--nf-text);
  overflow-x: hidden;
}

.nf-sidebar {
  position: fixed;
  z-index: 100;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--nf-width);
  flex-direction: column;
  overflow-y: auto;
  background: var(--nf-sidebar);
  color: #fff;
}

.nf-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px 18px 26px;
}

.nf-brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  overflow: hidden;
  background: transparent;
  flex: 0 0 auto;
}

.nf-brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nf-brand > div:last-child {
  display: grid;
  gap: 2px;
}

.nf-brand strong {
  font-size: 1rem;
}

.nf-brand span {
  color: rgba(255, 255, 255, .55);
  font-size: .61rem;
  letter-spacing: .13em;
}

.nf-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  padding: 0 17px 16px;
}

.nf-nav-link {
  display: flex;
  min-height: 44px;
  align-items: center;
  padding: 0 13px;
  border-radius: 11px;
  color: rgba(255, 255, 255, .8);
  font-size: .88rem;
  line-height: 1.2;
  text-decoration: none;
  transition: background .16s ease, color .16s ease;
}

.nf-nav-link:hover,
.nf-nav-link.is-active {
  background: rgba(255, 255, 255, .14);
  color: #fff;
}

.nf-nav-link.is-active {
  box-shadow: inset 3px 0 0 var(--nf-gold);
}

.nf-nav-spacer {
  min-height: 84px;
}

.nf-nav-label {
  margin: 10px 4px 2px;
  padding: 0 9px;
  color: rgba(255, 255, 255, .42);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.nf-nav-note {
  display: block;
  margin: 8px 8px 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .72);
  font-size: .72rem;
  line-height: 1.35;
}

.nf-account {
  margin: 0 17px;
  padding: 14px 0 20px;
  border-top: 1px solid rgba(255, 255, 255, .16);
}

.nf-account-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  border-radius: 9px;
  margin: -4px;
  padding: 4px;
  transition: background .12s ease;
}

.nf-account-row:hover {
  background: rgba(255, 255, 255, .08);
}

.nf-avatar,
.nf-top-avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--nf-gold);
  color: #fff;
  font-weight: 700;
}

.nf-avatar {
  width: 34px;
  height: 34px;
  font-size: .72rem;
}

.nf-account-row > div:last-child {
  display: grid;
  gap: 1px;
}

.nf-account strong {
  font-size: .82rem;
}

.nf-account span {
  color: rgba(255, 255, 255, .55);
  font-size: .68rem;
}

.nf-account > a.nf-signout {
  display: inline-block;
  margin-top: 12px;
  color: rgba(255, 255, 255, .8);
  font-size: .76rem;
  text-decoration: none;
  transition: color .12s ease;
}

.nf-account > a.nf-signout:hover {
  color: #fff;
}

.nf-column {
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--nf-width);
  overflow-x: clip;
}

.nf-topbar {
  position: sticky;
  z-index: 60;
  top: 0;
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 24px;
  border-bottom: 1px solid var(--nf-border);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
}

.nf-menu {
  display: none;
  width: 42px;
  height: 42px;
  place-content: center;
  gap: 4px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.nf-menu span {
  width: 22px;
  height: 3px;
  border-radius: 999px;
  background: var(--ink);
  transition: transform .16s ease, opacity .16s ease;
}

.nf-search {
  position: relative;
  display: flex;
  width: min(420px, 45vw);
  min-height: 36px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--nf-border);
  border-radius: 10px;
  background: #f6f4f0;
  color: var(--nf-muted);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.nf-search:focus-within {
  border-color: var(--nf-gold);
  box-shadow: 0 0 0 3px rgba(188, 155, 106, .16);
}

.nf-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: .72rem;
  color: var(--nf-text);
}

.nf-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 70vh;
  overflow-y: auto;
  border: 1px solid var(--nf-border);
  border-radius: 12px;
  background: var(--nf-surface);
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 70;
}

.nf-search-group {
  padding: 6px 4px;
}

.nf-search-group + .nf-search-group {
  border-top: 1px solid var(--nf-border);
  margin-top: 4px;
  padding-top: 10px;
}

.nf-search-group-label {
  display: block;
  padding: 2px 8px 6px;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--nf-muted);
}

.nf-search-result {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: background .12s ease;
}

.nf-search-result:hover {
  background: var(--sand);
}

.nf-search-result strong {
  font-size: .74rem;
  color: var(--ink);
}

.nf-search-result span {
  font-size: .66rem;
  color: var(--nf-muted);
}

.nf-search-empty {
  padding: 14px 10px;
  font-size: .7rem;
  color: var(--nf-muted);
  text-align: center;
}

.nf-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nf-switch-view,
.bp-readonly-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--nf-border);
  background: #fff;
  color: var(--nf-muted, #797b75);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.nf-switch-view:hover {
  border-color: var(--gold, #BC9B6A);
  color: var(--ink, #252823);
  background: #faf6ef;
}

.nf-switch-view-icon {
  display: block;
  flex: 0 0 auto;
}

.nf-top-actions .nf-ask,
.nf-top-actions button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--nf-border);
  border-radius: 10px;
  background: var(--nf-surface);
  color: var(--sage);
  font: inherit;
  font-size: .72rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.nf-top-actions .nf-ask-icon {
  display: none;
  width: 42px;
  min-width: 42px;
  justify-content: center;
  padding: 0;
  font-size: 1.05rem;
  color: var(--gold);
  border-color: var(--gold);
  background: #faf6ef;
}

.nf-top-actions .nf-ask:hover,
.nf-top-actions button:hover {
  border-color: var(--nf-gold);
  background: #faf6ef;
  color: var(--ink);
}

.nf-top-avatar {
  width: 28px;
  height: 28px;
  font-size: .58rem;
}

.nf-main > div,
.nf-main > .page {
  width: auto;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 24px 54px;
}

.nf-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.nf-subnav-link {
  display: flex;
  min-height: 38px;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--nf-border);
  border-radius: 10px;
  background: var(--nf-surface);
  color: var(--sage);
  text-decoration: none;
  transition: border-color .15s ease, background .15s ease;
}

.nf-subnav-link:hover,
.nf-subnav-link.is-active {
  border-color: var(--nf-gold);
  background: #f5efe4;
}

.nf-page-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.nf-page-actions > * {
  min-height: 42px;
  margin: 0 !important;
}

.nf-overlay {
  display: none;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-card {
  display: block;
  padding: 20px;
  color: inherit;
  text-decoration: none;
}

.settings-card h2 {
  margin: 0;
}

.settings-card p {
  margin: 8px 0 0;
  color: var(--nf-muted);
}

@media (max-width: 820px) {
  :root {
    --nf-width: min(82vw, 380px);
  }

  body.nf-menu-open {
    overflow: hidden;
  }

  .nf-sidebar {
    width: var(--nf-width);
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: 18px 0 50px rgba(0, 0, 0, .24);
  }

  body.nf-menu-open .nf-sidebar {
    transform: translateX(0);
  }

  .nf-column {
    margin-left: 0;
  }

  .nf-topbar {
    min-height: 74px;
    padding: 0 20px;
  }

  .nf-menu {
    display: grid;
  }

  .nf-search,
  .nf-top-actions .nf-ask:not(.nf-ask-icon) {
    display: none;
  }

  .nf-top-actions .nf-ask-icon {
    display: inline-flex;
  }

  .nf-top-actions {
    margin-left: auto;
  }

  .nf-top-avatar {
    width: 48px;
    height: 48px;
    font-size: .95rem;
  }

  .nf-brand {
    padding: 44px 28px 30px;
  }

  .nf-brand-mark {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    font-size: 1.65rem;
  }

  .nf-brand strong {
    font-size: 1.27rem;
  }

  .nf-brand span {
    font-size: .82rem;
  }

  .nf-nav {
    gap: 10px;
    padding: 14px 26px 24px;
  }

  .nf-nav-link {
    min-height: 50px;
    padding: 0 18px;
    border-radius: 14px;
    font-size: 1rem;
  }

  .nf-nav-spacer {
    min-height: 110px;
  }

  .nf-nav-label {
    font-size: .72rem;
    margin-top: 18px;
  }

  .nf-account {
    margin: 0 26px;
    padding: 24px 0 28px;
  }

  .nf-avatar {
    width: 42px;
    height: 42px;
    font-size: .82rem;
  }

  .nf-account strong {
    font-size: 1rem;
  }

  .nf-account span {
    font-size: .84rem;
  }

  .nf-account > a.nf-signout {
    margin-top: 24px;
    font-size: 1rem;
  }

  .nf-overlay {
    position: fixed;
    z-index: 90;
    inset: 0;
    background: rgba(22, 25, 24, .38);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
  }

  body.nf-menu-open .nf-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .nf-main > div,
  .nf-main > .page {
    padding: 28px 18px 50px;
  }

  .nf-page-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .nf-page-actions > * {
    width: 100%;
    min-height: 50px;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .nf-page-actions,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

/* Ask NuFlow conversational panel */
.nf-ask-panel {
  position: fixed;
  top: 72px;
  right: 24px;
  z-index: 120;
  display: flex;
  box-sizing: border-box;
  width: min(420px, calc(100% - 32px));
  max-width: calc(100% - 32px);
  max-height: min(560px, calc(100dvh - 96px), calc(100vh - 96px));
  min-width: 0;
  flex-direction: column;
  border: 1px solid var(--nf-border);
  border-radius: 16px;
  background: linear-gradient(180deg, #fffdf9 0%, var(--nf-surface) 40%);
  box-shadow: 0 18px 48px rgba(42, 36, 28, .16);
  overflow: hidden;
}

.nf-ask-panel[hidden] {
  display: none !important;
}

.nf-ask-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--nf-border);
}

.nf-ask-panel-head strong {
  display: block;
  color: var(--ink);
  font-size: .92rem;
}

.nf-ask-panel-head span {
  display: block;
  margin-top: 2px;
  color: var(--nf-muted);
  font-size: .68rem;
}

.nf-ask-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nf-ask-panel-actions a {
  color: var(--sage);
  font-size: .68rem;
  font-weight: 600;
  text-decoration: none;
}

.nf-ask-panel-actions button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--nf-border);
  border-radius: 8px;
  background: var(--nf-surface);
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.nf-ask-thread {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.nf-ask-msg {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: .78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.nf-ask-bot {
  align-self: flex-start;
  background: #f4efe6;
  color: var(--ink);
}

.nf-ask-user {
  align-self: flex-end;
  background: #2f3a32;
  color: #f8f4ec;
}

.nf-ask-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.nf-ask-links a {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--nf-border);
  border-radius: 8px;
  background: #fff;
  color: var(--sage);
  font-size: .68rem;
  font-weight: 600;
  text-decoration: none;
}

.nf-ask-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  padding: 0 16px 10px;
}

.nf-ask-suggestions button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--nf-border);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: .66rem;
  cursor: pointer;
}

.nf-ask-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--nf-border);
}

.nf-ask-form input[type="text"] {
  flex: 1 1 140px;
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--nf-border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: .8rem;
}

.nf-ask-form button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--gold);
  border-radius: 10px;
  background: #faf6ef;
  color: var(--ink);
  font: inherit;
  font-size: .74rem;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 820px) {
  body.nf-ask-open {
    overflow: hidden;
    overscroll-behavior: none;
  }

  /* Full-screen sheet; JS pins to visualViewport so the composer stays above the keyboard. */
  .nf-ask-panel {
    top: var(--nf-ask-top, 0px);
    right: auto;
    bottom: auto;
    left: var(--nf-ask-left, 0px);
    width: var(--nf-ask-width, 100%);
    max-width: none;
    height: var(--nf-ask-height, 100dvh);
    max-height: none;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .nf-ask-panel-head {
    padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 10px;
  }

  .nf-ask-thread {
    padding: 12px 14px;
  }

  .nf-ask-suggestions {
    padding: 0 14px 8px;
  }

  body.nf-ask-keyboard .nf-ask-suggestions {
    display: none;
  }

  .nf-ask-suggestions button {
    max-width: 100%;
    white-space: normal;
    text-align: left;
    line-height: 1.3;
    padding: 6px 10px;
    min-height: 32px;
    border-radius: 10px;
  }

  .nf-ask-form {
    flex-shrink: 0;
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, #fffdf9 0%, var(--nf-surface) 40%);
  }

  .nf-ask-form button {
    flex: 0 0 auto;
  }
}

/* Shared typography consistency across shell pages */
body.nf-auth {
  font-size: var(--nf-text-body);
}

.nf-main .page-heading h1,
.nf-main > .page > h1,
.nf-main header h1 {
  font-size: var(--nf-text-page);
  line-height: 1.15;
  letter-spacing: -.03em;
}

.nf-main .page-heading p {
  font-size: var(--nf-text-sm);
}

.nf-main .panel-heading h2,
.nf-main article.panel h2,
.nf-main .panel > h2 {
  font-size: var(--nf-text-lg);
}

.nf-main .eyebrow {
  font-size: var(--nf-text-eyebrow);
}

@media (max-width: 820px) {
  .nf-main .page-heading h1,
  .nf-main > .page > h1,
  .nf-main header h1 {
    font-size: var(--nf-text-display);
  }
}
