/* FN Gather — FN People suite · Singapore, the hawker-centre commons.
   Doctrine: FN-DESIGN-LANGUAGE.md. The common table, not a chat app: a marble
   table top, teak stools and screens, Peranakan jade tilework, coral-rose
   enamel, brass fittings. Materials with grain and warm light — never the
   purple-gradient-on-dark SaaS look the doctrine forbids, and never a
   system/Inter face as the brand type. */
:root {
  /* FN People materials */
  --jade:      #2f8f7a;
  --jade-deep: #216858;
  --coral:     #d16a6a;
  --marble:    #f2ede2;
  --teak:      #6b4a2e;
  --teak-deep: #503620;
  --orchid:    #7a4b8f;
  --brass:     #b9863c;

  /* semantic */
  --primary: var(--jade);
  --accent:  var(--brass);
  --bg:      var(--marble);
  --panel:   #fbf8f1;
  --panel-2: #ece5d7;
  --border:  rgba(107, 74, 46, 0.24);
  --text:    #2a2119;
  --muted:   #6d6154;
  --radius: 10px;

  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans:  Optima, 'Gill Sans', 'Segoe UI', 'Trebuchet MS', system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--text); min-height: 100vh;
  /* marble table top: veining and warm light, not a flat fill */
  background-color: var(--bg);
  background-image:
    radial-gradient(1000px 500px at 12% -8%, rgba(255, 255, 250, 0.9), transparent 60%),
    radial-gradient(800px 500px at 95% 10%, rgba(47, 143, 122, 0.08), transparent 62%),
    repeating-linear-gradient(102deg, rgba(107, 74, 46, 0.028) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(8deg, rgba(107, 74, 46, 0.020) 0 1px, transparent 1px 7px);
  background-attachment: fixed;
}
h1, h2, h3, .brand-name, .login-card h1 { font-family: var(--serif); font-weight: 600; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
a { color: var(--jade-deep); text-decoration: none; }

/* login */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1100px 560px at 50% -10%, rgba(47,143,122,0.12), transparent 62%), transparent;
}
.login-card {
  /* an enamel-topped table card: marble face, teak edge, jade tile-rule */
  width: min(420px, 92vw);
  background: linear-gradient(180deg, #fdfbf6, var(--panel-2));
  border: 1px solid var(--border);
  border-top: 4px solid var(--jade);
  border-radius: 4px 4px 12px 12px;
  padding: 36px 32px; text-align: center;
  box-shadow: 0 1px 0 rgba(255, 255, 252, 0.8) inset, 0 10px 34px rgba(42, 33, 25, 0.14);
}
.login-logo { font-size: 40px; color: var(--jade); margin-bottom: 12px; }
.login-card h1 { font-size: 26px; margin-bottom: 6px; }
.login-card p { margin-bottom: 20px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }

/* shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0; color: #f4ece0;
  background: linear-gradient(180deg, #5f411f 0%, var(--teak-deep) 100%);
  border-right: 3px solid var(--brass);
  box-shadow: inset -8px 0 18px rgba(0,0,0,0.18);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand-row { display: flex; align-items: center; gap: 8px; padding: 4px 10px 18px; }
.brand-dot { color: var(--brass); font-size: 20px; }
.brand-name { font-weight: 700; font-size: 17px; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-btn {
  text-align: left; background: none; border: none; color: #efe4d4;
  padding: 10px 12px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.nav-btn:hover { background: rgba(255,255,255,0.09); }
.nav-btn.active { background: rgba(47,143,122,0.34); color: #fff; box-shadow: inset 3px 0 0 var(--brass); }
.sidebar-foot { display: flex; flex-direction: column; gap: 8px; padding: 8px 10px 0; }
.me-chip { font-size: 13px; color: var(--muted); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  padding: 18px 28px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(242, 237, 226, 0.9);
  backdrop-filter: blur(8px); z-index: 5;
}
.topbar h2 { font-size: 19px; }
.view { padding: 24px 28px 60px; max-width: 780px; width: 100%; }

/* cards + forms */
.card {
  background: linear-gradient(180deg, #fdfbf6, var(--panel));
  border: 1px solid var(--border); border-left: 3px solid var(--jade);
  border-radius: 2px var(--radius) var(--radius) 2px;
  padding: 16px 18px; margin-bottom: 14px;
  box-shadow: 0 1px 0 rgba(255,255,252,0.8) inset, 0 2px 8px rgba(42,33,25,0.07);
}
.card.pinned { border-left-color: var(--coral); box-shadow: 0 1px 0 rgba(255,255,252,0.8) inset, 0 3px 12px rgba(209,106,106,0.16); }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.card-head .who { color: var(--text); font-weight: 600; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(47,143,122,0.16); border: 1px solid rgba(47,143,122,0.4); color: var(--jade-deep);
}
.badge.green { background: rgba(185,134,60,0.16); border-color: rgba(185,134,60,0.45); color: #8a6229; }
.card h3 { font-size: 16px; margin-bottom: 6px; }
.card p.body { font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.card-actions { display: flex; gap: 12px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.link-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.link-btn:hover { color: var(--text); }
.link-btn.on { color: var(--coral); }

input, textarea, select {
  background: #fffdf8; border: 1px solid var(--border); color: var(--text);
  border-radius: 5px; padding: 10px 12px; font-size: 14px; font-family: inherit; width: 100%;
  box-shadow: inset 0 2px 3px rgba(107,74,46,0.10);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--jade);
  box-shadow: inset 0 2px 3px rgba(107,74,46,0.10), 0 0 0 3px rgba(47,143,122,0.22); }
textarea { resize: vertical; min-height: 70px; }
.btn {
  border: 1px solid var(--border); background: linear-gradient(180deg, #fbf6ec, var(--panel-2));
  color: var(--teak); padding: 9px 16px; border-radius: 5px; font-size: 14px; cursor: pointer;
  font-weight: 600; font-family: var(--serif);
  box-shadow: 0 1px 0 rgba(255,255,255,0.7) inset, 0 1px 2px rgba(42,33,25,0.12);
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #3aa78d, var(--jade)); border-color: var(--jade-deep); color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.22); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.wide { width: 100%; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn.ghost.on { border-color: var(--brass); color: #8a6229; }
.composer { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.composer .row { display: flex; gap: 10px; }
.composer .row > * { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }

/* chat */
.chat-wrap { display: flex; gap: 16px; align-items: flex-start; }
.chan-list { width: 190px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }
.chan-btn {
  text-align: left; background: none; border: 1px solid transparent; color: var(--muted);
  padding: 7px 10px; border-radius: 8px; font-size: 13.5px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chan-btn.active { background: var(--panel-2); color: var(--teak); border-color: var(--jade); font-weight: 600; }
.chat-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 62vh;
  background: linear-gradient(180deg, #fdfbf6, var(--panel)); border: 1px solid var(--border);
  border-top: 3px solid var(--jade); border-radius: 2px 2px var(--radius) var(--radius); }
.chat-head { padding: 8px 16px 0; min-height: 14px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--jade); box-shadow: 0 0 6px rgba(47,143,122,0.6); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { font-size: 14px; line-height: 1.4; }
.msg .who { font-weight: 700; margin-right: 6px; }
.msg .when { font-size: 11px; color: var(--muted); margin-left: 6px; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }

/* misc */
.empty { text-align: center; padding: 40px 0; color: var(--muted); font-size: 14px; }
.streak { font-family: var(--serif); font-size: 42px; font-weight: 700; color: var(--jade-deep); }
.rsvp-row { display: flex; gap: 8px; margin-top: 10px; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--border); font-size: 14px; }
.task-row input[type="checkbox"] { width: auto; }
.task-row.done .t-title { text-decoration: line-through; color: var(--muted); }
.t-title { flex: 1; }

/* topbar subtitle */
.topbar { display: flex; align-items: center; }
.topbar-sub { margin-top: 2px; }
.topbar > div:first-child { flex: 1; min-width: 0; }

/* notifications (T7) */
.bell {
  position: relative; background: none; border: 1px solid transparent; border-radius: 10px;
  font-size: 18px; padding: 7px 10px; cursor: pointer; flex-shrink: 0;
}
.bell:hover { background: var(--panel-2); border-color: var(--border); }
.bell-badge {
  position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: #e0574f; color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}
.notif-panel {
  position: absolute; top: 58px; right: 20px; width: min(360px, calc(100vw - 32px));
  max-height: 62vh; overflow-y: auto; z-index: 30;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px; box-shadow: 0 14px 40px rgba(0,0,0,0.5);
}
.notif-row { display: flex; flex-direction: column; gap: 2px; padding: 9px 10px; border-radius: 8px; }
.notif-row:hover { background: var(--panel); }
.notif-row.unread { border-left: 3px solid var(--accent); }
.notif-row .n-title { font-size: 13.5px; font-weight: 600; }
.notif-row .n-body { font-size: 12.5px; color: var(--muted); }

/* toasts */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 50; pointer-events: none; }
.toast {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 18px; font-size: 14px; font-weight: 500;
  box-shadow: 0 12px 34px rgba(0,0,0,0.45); animation: toast-in .22s ease;
}
.toast.ok { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.toast.err { border-color: #e0574f; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* user menu */
.me-chip {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: none; border: 1px solid transparent; border-radius: 10px; padding: 7px 9px;
  color: var(--text); cursor: pointer;
}
.me-chip:hover { background: var(--panel-2); border-color: var(--border); }
.me-avatar {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; font-size: 16px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--primary) 25%, transparent);
}
.me-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.me-text #me-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-caret { color: var(--muted); font-size: 12px; }
.me-menu {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 4px; margin: 4px 0; box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.me-menu-item { width: 100%; text-align: left; background: none; border: none; color: var(--text); padding: 8px 10px; border-radius: 7px; font-size: 13.5px; cursor: pointer; }
.me-menu-item:hover { background: var(--panel); }

.btn:disabled { opacity: 0.6; cursor: default; }

/* uploads / media (T10) */
.media-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.media {
  max-width: min(260px, 100%); max-height: 220px; border-radius: 10px;
  border: 1px solid var(--border); object-fit: cover; display: block;
}
.msg .media { max-width: min(200px, 100%); max-height: 160px; }
.media-doc {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
}
.attach-chip { font-size: 13px; margin-right: 4px; }
.me-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* billing */
.billing-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.notice { border-color: color-mix(in srgb, #e0762c 45%, var(--border)); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.plan { display: flex; flex-direction: column; gap: 8px; }
.plan.current { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.plan .price { font-size: 24px; font-weight: 800; }
.plan .price .tiny { font-weight: 500; }
.plan-credits { margin-top: auto; }
.plan .btn { margin-top: 6px; }
.ledger-row { display: grid; grid-template-columns: 1fr auto 70px; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--border); }
.ledger-row span:last-child { text-align: right; }

/* ── mobile polish (T12) ─────────────────────────────────────────────────── */
@media (max-width: 760px) {
  body { min-height: 100dvh; }
  .shell { flex-direction: column; min-height: 100dvh; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 10;
    flex-direction: row; align-items: center; overflow-x: auto;
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top));
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand-row { padding: 4px 8px 4px 4px; flex-shrink: 0; }
  .brand-name { display: none; }
  nav { flex-direction: row; flex-wrap: nowrap; }
  .nav-btn { white-space: nowrap; padding: 10px 11px; min-height: 42px; }
  .sidebar-foot { margin-left: auto; flex-direction: row; align-items: center; padding: 0; flex-shrink: 0; }
  .sidebar-foot .me-text, .sidebar-foot #powered-by { display: none; }
  .me-menu { position: absolute; top: 58px; right: 10px; z-index: 20; }
  .topbar { top: 62px; padding: 12px 16px; }
  .view { padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); }
  .form-grid { grid-template-columns: 1fr; }
  /* 16px inputs stop iOS Safari's focus zoom */
  input, textarea, select { font-size: 16px; }
  .btn { min-height: 42px; }
  .chat-wrap { flex-direction: column; }
  .chan-list { width: 100%; flex-direction: row; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .chan-btn { flex-shrink: 0; }
  .chat-panel { height: 58dvh; width: 100%; }
  /* thumb-sized taps for the controls that skip .btn */
  .chan-btn, .link-btn { min-height: 40px; }
  /* composer rows wrap instead of crushing buttons against helper text */
  .composer .row { flex-wrap: wrap; }
  .composer .row .tiny { flex: 1 1 100%; }
  /* one column of plans — no orphan card floating in a half-filled row */
  .plan-grid { grid-template-columns: 1fr; }
}

/* ── Teak-screen contrast: everything sitting on the sidebar reads on wood ── */
.sidebar .me-chip { color: #f4ece0; }
.sidebar .me-chip:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 255, 255, 0.18); }
.sidebar .me-avatar { background: rgba(185, 134, 60, 0.32); }
.sidebar .me-chip .muted, .sidebar .me-caret, .sidebar #powered-by { color: #cbb79a; }
.sidebar #powered-by a { color: var(--brass); }
.sidebar .me-menu {
  background: linear-gradient(180deg, #fdfbf6, var(--panel-2));
  border-color: var(--border);
  box-shadow: 0 10px 30px rgba(42, 33, 25, 0.28);
}
.sidebar .me-menu-item { color: var(--teak); }
.sidebar .me-menu-item:hover { background: rgba(47, 143, 122, 0.14); }

/* ─── depth layer, shared across the suite ───────────────────────────────
 * Appended by fn-life-apply.mjs. Canonical source:
 * fn-universe/packages/storefront/fn-life.css — edit there and re-run.
 */
/* ─── fn-life — depth for a flat page ────────────────────────────────────────
 *
 * Owner brief, 2026-07-25: "bring all the pages to life, we don't want a
 * dead-app. Bunch of sophisticated, but not process heavy graphics."
 *
 * Every app in this suite has its own deliberate aesthetic — a Guadalajara
 * mercado, a Florence studiolo, a Lagos counting house. This layer does NOT
 * impose a look. It adds DEPTH to whatever look is already there, by reading the
 * app's own background colour and building light and grain out of it.
 *
 * WHAT IT COSTS TO RUN — the "not process heavy" half of the brief, taken
 * seriously:
 *
 *   · no JavaScript, no canvas, no WebGL, no requestAnimationFrame
 *   · no network requests: the grain is an inline SVG data URI, so it costs one
 *     paint and nothing else, ever
 *   · two fixed pseudo-elements on <html>, both pointer-events:none, both
 *     composited — they never trigger layout or repaint on scroll
 *   · the one movement is a 120-second drift on a single GPU-composited layer,
 *     and it is switched off entirely for anyone who asks for reduced motion
 *
 * On <html> rather than <body>: several apps already use body::before for their
 * own ornament (fn-welcome's panel rule, for one), and quietly stealing a
 * pseudo-element an app is already using would break its design rather than
 * enrich it.
 */

@layer fn-life {
  :root {
    /* Read from the app's own palette where it has one, with a warm neutral
       fallback so an app with no variables still gets sensible light. */
    --fn-life-warm: var(--amber, var(--brass, var(--gold, #b9863c)));
    --fn-life-cool: var(--jade, var(--teal, var(--indigo, #2f8f7a)));
    /* Tuned in a live browser against a real page, not guessed. At 0.035/0.06
       the layer was invisible — technically present, doing nothing. At 0.55/0.18
       it read as a coloured filter over somebody else work. These are the values
       where light arrives and the app own design still leads. */
    --fn-life-grain: 0.22;
    --fn-life-wash: 0.34;
  }

  html {
    position: relative;
    /* Any background the app set stays exactly as it is; this only adds to it. */
    background-attachment: fixed;
  }

  /* LIGHT — two very soft pools, as if the page were lit from off-frame.
     Sized in vmax so the geometry holds on a phone as well as a monitor. */
  html::before {
    content: "";
    position: fixed;
    inset: -20vmax;
    z-index: -2;
    pointer-events: none;
    background:
      radial-gradient(42vmax 42vmax at 18% 8%,
        color-mix(in oklab, var(--fn-life-warm) calc(var(--fn-life-wash) * 100%), transparent),
        transparent 70%),
      radial-gradient(38vmax 38vmax at 88% 92%,
        color-mix(in oklab, var(--fn-life-cool) calc(var(--fn-life-wash) * 70%), transparent),
        transparent 72%);
    will-change: transform;
    animation: fn-life-drift 120s ease-in-out infinite alternate;
  }

  /* GRAIN — the thing that stops a large flat fill looking like a dead screen.
     Static, one paint, no animation.

     soft-light, not multiply: multiplying dark grain into a DARK page does
     nothing whatsoever, and half this suite is dark. soft-light is the classic
     film-grain blend precisely because it gives tooth on both ends. */
  html::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: var(--fn-life-grain);
    mix-blend-mode: soft-light;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  @keyframes fn-life-drift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(2.5vmax, -1.5vmax, 0) scale(1.04); }
  }

  /* Asked for less motion, given none. The light stays; only the drift stops. */
  @media (prefers-reduced-motion: reduce) {
    html::before { animation: none; }
  }

  /* There is deliberately NO prefers-color-scheme branch.

     The first version had one, and it was keyed to the wrong thing: the
     VISITOR'S operating system preference. An app's theme is fixed by the app —
     fn-scribe is a dark stenograph whatever your laptop is set to — so the branch
     fired on a signal that had nothing to do with the page it was adjusting, and
     on a dark app in a light-mode OS it did exactly the wrong thing.

     soft-light needs no branch: it lightens what is dark and darkens what is
     light, per pixel, which is the behaviour the branch was clumsily faking. */

  /* Print: none of this. It is light, not content. */
  @media print {
    html::before, html::after { display: none; }
  }
}
