/* FerOS shared look. Hand-written; no inline styles, no scripts. */
/* Light is the default. A page that has no dark look of its own (Desk) puts
   data-theme="light" on <html>, and then stays light whatever the system says. */
:root,
:root[data-theme="light"] {
  --feros-bg: #f5f2ea;
  --feros-surface: #fffcf6;
  --feros-surface-2: #ece7da;
  --feros-border: #ded9cd;
  --feros-text: #17211b;
  --feros-muted: #687169;
  --feros-accent: #1b4332;
  --feros-accent-text: #ffffff;
  --feros-highlight: #d7f171;
  --feros-danger: #862e27;
  --feros-danger-bg: #f7dcd8;
  --feros-ok: #1f5b3a;
  --feros-ok-bg: #dcefe2;
  --feros-radius: 14px;
  --feros-topbar-h: 56px;
  --feros-bottombar-h: 60px;
  --feros-rail-w: 220px;
  --feros-font: "Geist", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color-scheme: light dark;
}
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --feros-bg: #121815;
    --feros-surface: #1b231f;
    --feros-surface-2: #26302b;
    --feros-border: #2f3b35;
    --feros-text: #e8ede9;
    --feros-muted: #98a69d;
    --feros-accent: #d7f171;
    --feros-accent-text: #17211b;
    --feros-highlight: #2d6a4f;
    --feros-danger: #f2b8b0;
    --feros-danger-bg: #3d1f1b;
    --feros-ok: #a9e0bd;
    --feros-ok-bg: #1d3a2a;
  }
}

.feros-body-root {
  margin: 0;
  background: var(--feros-bg);
  color: var(--feros-text);
  font-family: var(--feros-font);
}

[data-phx-session],
[data-phx-teleported-src] { display: contents; }

.feros-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Top bar */

.feros-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--feros-topbar-h);
  padding: 0 16px;
  background: var(--feros-surface);
  border-bottom: 1px solid var(--feros-border);
}

.feros-brand {
  font-weight: 800;
  letter-spacing: -0.04em;
  font-size: 1.25rem;
  color: var(--feros-text);
  text-decoration: none;
}

.feros-sections {
  display: flex;
  flex: 1;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.feros-section-link {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--feros-muted);
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  white-space: nowrap;
}

.feros-section-link:hover {
  background: var(--feros-surface-2);
  color: var(--feros-text);
}

.feros-section-link.is-current {
  background: var(--feros-accent);
  color: var(--feros-accent-text);
}

/* User menu */

.feros-user {
  position: relative;
  margin-left: auto;
}

.feros-user-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-radius: 999px;
  cursor: pointer;
  list-style: none;
}

.feros-user-summary:hover { background: var(--feros-surface-2); }

.feros-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--feros-surface-2);
}

.feros-avatar-initial {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--feros-text);
}

.feros-user-name {
  max-width: 14ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 600;
}

.feros-user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  padding: 12px;
  background: var(--feros-surface);
  border: 1px solid var(--feros-border);
  border-radius: var(--feros-radius);
}

.feros-user-email {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  color: var(--feros-muted);
  overflow-wrap: anywhere;
}

.feros-logout {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--feros-danger);
  font-weight: 600;
  text-decoration: none;
}

.feros-logout:hover { background: var(--feros-danger-bg); }

/* Frame: content plus optional sub-navigation */

.feros-frame {
  flex: 1;
  display: flex;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.feros-main {
  flex: 1;
  min-width: 0;
  padding: 24px 16px 32px;
}

.feros-subnav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: var(--feros-rail-w);
  flex-shrink: 0;
  padding: 24px 8px 24px 16px;
  position: sticky;
  top: var(--feros-topbar-h);
  align-self: flex-start;
}

.feros-subnav-link {
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--feros-muted);
  font-weight: 600;
  text-decoration: none;
}

.feros-subnav-link:hover {
  background: var(--feros-surface-2);
  color: var(--feros-text);
}

.feros-subnav-link.is-active {
  background: var(--feros-highlight);
  color: var(--feros-text);
}

/* Flash messages */
.feros-flashes {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.feros-flash {
  margin: 0;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  background: var(--feros-ok-bg);
  color: var(--feros-ok);
  font-weight: 600;
}

.feros-flash.is-error {
  background: var(--feros-danger-bg);
  color: var(--feros-danger);
}

/* Narrow screens: the rail becomes a bottom bar */

@media (max-width: 767px) {
  .feros-user-name { display: none; }
  .feros-topbar { gap: 8px; }
  .feros-section-link { padding: 8px 10px; }

  .feros-frame.has-subnav {
    padding-bottom: calc(var(--feros-bottombar-h) + env(safe-area-inset-bottom, 0px));
  }

  .feros-subnav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    flex-direction: row;
    justify-content: space-around;
    width: auto;
    height: calc(var(--feros-bottombar-h) + env(safe-area-inset-bottom, 0px));
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    background: var(--feros-surface);
    border-top: 1px solid var(--feros-border);
    overflow-x: auto;
  }

  .feros-subnav-link {
    flex: 1;
    display: grid;
    place-items: center;
    padding: 0 8px;
    border-radius: 0;
    font-size: 0.75rem;
    text-align: center;
  }

  .feros-subnav-link.is-active {
    background: none;
    color: var(--feros-accent);
    box-shadow: inset 0 3px 0 var(--feros-accent);
  }
}

@media (min-width: 768px) {
  .feros-topbar {
    padding: 0 24px;
  }

  .feros-main {
    padding: 32px 24px 48px;
  }
}
