/* The portal speaks Byonoy OS: the tokens of @byonoy/ui (packages/ui/src/globals.css in
   infra/ByonoyOS, as bare HSL triples), the platform's own font, Lucide icons, bordered cards,
   tinted tags with ink of the same hue, a ring for focus, squircles, never circles. Structure
   borrowed from admin-bot's console (src/admin_bot/web/static/console.css). */
:root {
  --background: 0 0% 100%; --foreground: 220 20% 14%; --canvas: 220 16% 97%;
  --card: 0 0% 100%; --primary: 234 100% 31%; --primary-foreground: 0 0% 100%;
  --secondary: 220 14% 96%; --muted-foreground: 220 9% 40%; --border: 220 13% 91%;
  --ring: 234 100% 31%; --destructive: 0 72% 51%; --destructive-ink: 0 68% 38%;
  --status-current: 152 60% 40%; --status-outdated: 38 92% 50%;
  --status-overdue: 0 72% 51%; --status-pending: 209 68% 54%;
  --status-current-ink: 152 64% 24%; --status-outdated-ink: 32 88% 28%;
  --status-overdue-ink: 0 68% 38%; --status-pending-ink: 209 74% 32%;
  --tile-teal: 175 84% 32%; --tile-indigo: 243 75% 59%;   /* teal-600, indigo-600: OS tile presets */
  --shadow: 220 20% 14%;
  --radius: 0.5rem; --control: 2.5rem; --header: 3.2rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --squircle: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20100%20100%22%20preserveAspectRatio%3D%22none%22%3E%3Cpath%20fill%3D%22black%22%20d%3D%22M100%2050L99.9%2069.75L99.61%2076.01L99.13%2080.49L98.44%2084.05L97.55%2087.01L96.44%2089.52L95.11%2091.68L93.53%2093.53L91.68%2095.11L89.52%2096.44L87.01%2097.55L84.05%2098.44L80.49%2099.13L76.01%2099.61L69.75%2099.9L50%20100L30.25%2099.9L23.99%2099.61L19.51%2099.13L15.95%2098.44L12.99%2097.55L10.48%2096.44L8.32%2095.11L6.47%2093.53L4.89%2091.68L3.56%2089.52L2.45%2087.01L1.56%2084.05L0.87%2080.49L0.39%2076.01L0.1%2069.75L0%2050L0.1%2030.25L0.39%2023.99L0.87%2019.51L1.56%2015.95L2.45%2012.99L3.56%2010.48L4.89%208.32L6.47%206.47L8.32%204.89L10.48%203.56L12.99%202.45L15.95%201.56L19.51%200.87L23.99%200.39L30.25%200.1L50%200L69.75%200.1L76.01%200.39L80.49%200.87L84.05%201.56L87.01%202.45L89.52%203.56L91.68%204.89L93.53%206.47L95.11%208.32L96.44%2010.48L97.55%2012.99L98.44%2015.95L99.13%2019.51L99.61%2023.99L99.9%2030.25Z%22%2F%3E%3C%2Fsvg%3E");
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: 220 20% 8%; --foreground: 220 14% 96%; --canvas: 220 20% 8%;
    --card: 220 20% 11%; --primary: 234 100% 70%; --primary-foreground: 220 20% 8%;
    --secondary: 220 14% 18%; --muted-foreground: 220 9% 66%; --border: 220 14% 20%;
    --ring: 234 100% 70%; --destructive: 0 72% 60%; --destructive-ink: 0 88% 80%;
    --status-current: 152 60% 50%; --status-outdated: 38 92% 60%;
    --status-overdue: 0 72% 60%; --status-pending: 209 68% 64%;
    --status-current-ink: 152 52% 70%; --status-outdated-ink: 38 88% 70%;
    --status-overdue-ink: 0 88% 80%; --status-pending-ink: 209 84% 76%;
    --shadow: 220 40% 2%;
    color-scheme: dark;
  }
}
@media (pointer: coarse) { :root { --control: 2.75rem; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: hsl(var(--canvas));
       color: hsl(var(--foreground)); font: 400 0.875rem/1.5 var(--font); -webkit-font-smoothing: antialiased; }
@media (pointer: coarse) { body { font-size: 0.9375rem; } }
a { color: hsl(var(--primary)); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 1.5rem; line-height: 1.25; font-weight: 600; letter-spacing: -0.02em; margin: 0; overflow-wrap: anywhere; }
h2 { font-size: 0.9375rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 0.5rem; }
h3 { font-size: 0.875rem; font-weight: 600; margin: 1.25rem 0 0.375rem; }
p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }
small, .muted { color: hsl(var(--muted-foreground)); }
small { font-size: 0.75rem; }
b, strong { font-weight: 600; }
code, pre { font-family: var(--mono); font-size: 0.8125em; }
code { background: hsl(var(--secondary)); padding: 0.1em 0.35em; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: hsl(var(--secondary)); padding: 0.625rem 0.75rem; border-radius: 6px; overflow-x: auto; margin: 0 0 0.75rem;
      font-size: 0.78125rem; line-height: 1.55; }
pre:last-child { margin-bottom: 0; }
pre code { background: none; padding: 0; font-size: inherit; }
ul, ol { margin: 0 0 0.75rem; padding-left: 1.25rem; }
li { margin: 0.25rem 0; }
[hidden] { display: none !important; }
.ic { width: 1rem; height: 1rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
      stroke-linecap: round; stroke-linejoin: round; }
.ic.lg { width: 1.25rem; height: 1.25rem; }
.grow { flex: 1 1 0; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

/* --- The frame: a glass header row (40 px controls, 0.35 rem above and below), a column --- */
.os-header { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 0.5rem; min-height: var(--header); padding: calc(0.35rem + env(safe-area-inset-top)) max(0.8rem, env(safe-area-inset-right)) 0.35rem max(0.8rem, env(safe-area-inset-left));
  background: hsl(var(--canvas) / 0.8); -webkit-backdrop-filter: blur(12px) saturate(1.5); backdrop-filter: blur(12px) saturate(1.5);
  border-bottom: 1px solid hsl(var(--border) / 0.6); }
.hl { display: flex; align-items: center; min-width: 0; }
.hc { text-align: center; min-width: 0; }
.hr { display: flex; justify-content: flex-end; align-items: center; }
.htitle { font-weight: 600; font-size: 0.9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.hbtn { width: var(--control); height: var(--control); border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  color: hsl(var(--muted-foreground)); cursor: pointer; list-style: none; }
.hbtn:hover { background: hsl(var(--foreground) / 0.05); color: hsl(var(--foreground)); text-decoration: none; }
.hbtn::-webkit-details-marker { display: none; }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; color: hsl(var(--foreground)); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand span { display: none; }
@media (min-width: 36rem) { .brand span { display: inline; } }
.mark { width: 1.75rem; height: 1.75rem; flex: none; }
.mark-bg { fill: hsl(var(--foreground)); } .mark-b { fill: hsl(var(--canvas)); }
.me { position: relative; }
.me .menu { position: absolute; right: 0; top: calc(var(--control) + 0.5rem); width: 17rem; padding: 0.5rem; border-radius: 1rem;
  background: hsl(var(--card) / 0.9); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid hsl(var(--border)); box-shadow: 0 8px 32px hsl(var(--shadow) / 0.14); display: flex; flex-direction: column; gap: 0.25rem; }
.me .who { display: flex; gap: 0.75rem; align-items: center; padding: 0.5rem; line-height: 1.3; min-width: 0; }
.me .who b { display: block; font-weight: 500; }
.me .who small { display: block; overflow-wrap: anywhere; }
.me .menu a { display: flex; align-items: center; gap: 0.5rem; min-height: var(--control); padding: 0 0.5rem; border-radius: var(--radius);
  color: hsl(var(--foreground)); }
.me .menu a:hover { background: hsl(var(--secondary)); text-decoration: none; }
/* Nothing in Byonoy OS is a circle: a person, a tile, a glyph is a squircle. */
.avatar, .tile, .glyph { -webkit-mask: var(--squircle) center / 100% 100% no-repeat; mask: var(--squircle) center / 100% 100% no-repeat; }
.avatar { width: 2rem; height: 2rem; flex: none; background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600; }
.avatar.lg { width: 2.5rem; height: 2.5rem; font-size: 0.875rem; }

.panel { width: 100%; max-width: 48rem; margin: 0 auto; flex: 1; display: flex; flex-direction: column; gap: 1rem;
  padding: 1.5rem max(1rem, env(safe-area-inset-left)) 2.5rem; }
.foot { text-align: center; color: hsl(var(--muted-foreground)); font-size: 0.75rem; padding: 0 1rem calc(1.5rem + env(safe-area-inset-bottom)); }

/* --- A page's head ------------------------------------------------------------------------ */
.hero { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.5rem 0 0.5rem; }
.hero .tile { margin-bottom: 0.25rem; }
.hero.row-hero { flex-direction: row; align-items: center; gap: 0.875rem; }
.hero.row-hero .tile { margin: 0; }
.hero.row-hero p { margin: 0; }
.lead { font-size: 0.9375rem; color: hsl(var(--muted-foreground)); max-width: 40rem; margin: 0; }

/* --- Launcher: apps as tiles ------------------------------------------------------------- */
.tile { width: 2.5rem; height: 2.5rem; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: hsl(var(--primary)); color: #fff; }
.tile .ic { width: 1.25rem; height: 1.25rem; }
.tile.lg { width: 4rem; height: 4rem; }
.tile.lg .ic { width: 1.75rem; height: 1.75rem; }
.tile.teal { background: hsl(var(--tile-teal)); }
.tile.indigo { background: hsl(var(--tile-indigo)); }
.launcher { display: grid; gap: 0.75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 40rem) { .launcher { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.app { display: flex; align-items: center; gap: 0.875rem; padding: 1rem; color: inherit; background: hsl(var(--card));
  border: 1px solid hsl(var(--border)); border-radius: 0.75rem; box-shadow: 0 1px 2px hsl(var(--shadow) / 0.04);
  transition: border-color 150ms, box-shadow 150ms; }
.app:hover { text-decoration: none; border-color: hsl(var(--muted-foreground) / 0.35); box-shadow: 0 4px 16px hsl(var(--shadow) / 0.08); }
.app .tile { width: 3.25rem; height: 3.25rem; }
.app .tile .ic { width: 1.5rem; height: 1.5rem; }
.app-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.125rem; }
.app-text b { font-size: 0.9375rem; }
.app-text small { font-size: 0.8125rem; }
.chev { color: hsl(var(--muted-foreground) / 0.6); }

/* --- Buttons ---------------------------------------------------------------------------- */
.btn { font: inherit; font-weight: 500; min-height: var(--control); padding: 0 1rem; border-radius: var(--radius); gap: 0.5rem;
  border: 1px solid hsl(var(--border)); background: hsl(var(--background)); color: hsl(var(--foreground));
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; cursor: pointer;
  transition: background-color 150ms, border-color 150ms, opacity 150ms; text-decoration: none; }
.btn:hover { background: hsl(var(--secondary)); text-decoration: none; }
.btn:active { opacity: 0.8; }
.btn.primary { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn.primary:hover { background: hsl(var(--primary) / 0.9); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: hsl(var(--secondary)); }
.btn.danger { color: hsl(var(--destructive-ink)); }
.btn.sm { min-height: calc(var(--control) - 0.25rem); padding: 0 0.75rem; font-size: 0.8125rem; }
.btn.icon { width: var(--control); padding: 0; }
.btn.icon.sm { width: calc(var(--control) - 0.25rem); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; }

/* --- Cards, rows ------------------------------------------------------------------------- */
.card { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: 0.75rem;
  box-shadow: 0 1px 2px hsl(var(--shadow) / 0.04); min-width: 0; }
.card > .body { padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.card > .body > * { margin: 0; }
.card.narrow { max-width: 28rem; width: 100%; margin: 6vh auto 0; padding: 1.5rem; display: flex; flex-direction: column; gap: 0.875rem; }
.card.narrow > * { margin: 0; }
.card-head { display: flex; align-items: center; gap: 0.625rem; padding: 0.75rem 1rem; min-height: 3rem; border-bottom: 1px solid hsl(var(--border)); }
.card-head:last-child { border-bottom: 0; }
.count { color: hsl(var(--muted-foreground)); font-weight: 400; }
.row { display: flex; align-items: center; gap: 0.75rem; padding: 0.625rem 1rem; min-height: 3.5rem; color: inherit;
  border-top: 1px solid hsl(var(--border)); }
.row:first-child, .card-head + .row { border-top: 0; }
a.row:hover { background: hsl(var(--secondary) / 0.6); text-decoration: none; }
a.row:last-child { border-radius: 0 0 0.75rem 0.75rem; }
.row strong { font-weight: 500; display: block; overflow-wrap: anywhere; }
.row small { display: block; overflow-wrap: anywhere; }
.row form { margin: 0; }
.glyph { width: 2.25rem; height: 2.25rem; flex: none; display: flex; align-items: center; justify-content: center;
  background: hsl(var(--secondary)); color: hsl(var(--muted-foreground)); }
.empty { padding: 1.25rem 1rem; color: hsl(var(--muted-foreground)); display: flex; align-items: center; gap: 0.5rem; }
.empty.tall { flex-direction: column; text-align: center; padding: 2.25rem 1.25rem; gap: 0.375rem; }
.empty.tall > .ic { width: 1.75rem; height: 1.75rem; stroke-width: 1.5; margin-bottom: 0.25rem; }
.empty.tall b { color: hsl(var(--foreground)); font-weight: 500; }
.empty.tall span:last-child { max-width: 28rem; }
.cols { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 44rem) { .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Tags and notes: a 15 % tint of the status colour carrying darker ink of the same hue. */
.tag { display: inline-flex; align-items: center; gap: 0.3125rem; height: 1.375rem; padding: 0 0.5rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 500; white-space: nowrap; flex: none; background: hsl(var(--secondary)); color: hsl(var(--muted-foreground)); }
.dot { width: 0.375rem; height: 0.375rem; border-radius: 50%; background: currentColor; flex: none; }
.tag.ok, .glyph.ok, .note.ok { background: hsl(var(--status-current) / 0.15); color: hsl(var(--status-current-ink)); }
.tag.warn, .glyph.warn, .note.warn { background: hsl(var(--status-outdated) / 0.15); color: hsl(var(--status-outdated-ink)); }
.tag.bad, .glyph.bad, .note.bad { background: hsl(var(--status-overdue) / 0.15); color: hsl(var(--status-overdue-ink)); }
.tag.pending, .glyph.pending, .note.info, .tag.info { background: hsl(var(--status-pending) / 0.15); color: hsl(var(--status-pending-ink)); }
.tag.pending .dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.note { display: flex; gap: 0.625rem; padding: 0.75rem 0.875rem; border-radius: var(--radius); overflow-wrap: anywhere;
  background: hsl(var(--secondary)); margin: 0; align-items: flex-start; }
.note > .ic { margin-top: 0.1875rem; }
.note p { margin: 0; }
.note code { background: hsl(var(--card) / 0.6); }
a.note.link { color: hsl(var(--status-pending-ink)); align-items: center; }
a.note.link > .ic { margin-top: 0; }
a.note.link:hover { text-decoration: none; background: hsl(var(--status-pending) / 0.22); }

/* --- Forms -------------------------------------------------------------------------------- */
form { margin: 0; }
.field { display: grid; gap: 0.375rem; font-weight: 500; }
.field > span { font-weight: 400; font-size: 0.8125rem; color: hsl(var(--muted-foreground)); }
input:not([type=radio]), select { font: inherit; font-weight: 400; color: inherit; background: hsl(var(--background)); width: 100%;
  border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 0.375rem 0.75rem; min-height: var(--control);
  transition: border-color 150ms; }
input:not([type=radio]):hover { border-color: hsl(var(--muted-foreground) / 0.5); }
input::placeholder { color: hsl(var(--muted-foreground) / 0.8); }
input:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
@media (pointer: coarse) { input:not([type=radio]) { font-size: 1rem; } }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 0.375rem; min-width: 0; }
legend { font-weight: 500; padding: 0; margin-bottom: 0.375rem; }
.seg { display: inline-flex; padding: 0.1875rem; border-radius: var(--radius); background: hsl(var(--secondary)); gap: 0.125rem; }
.seg.wrap { display: flex; flex-wrap: wrap; }
.seg label { min-height: calc(var(--control) - 0.375rem); padding: 0 0.875rem; display: inline-flex; align-items: center;
  border-radius: 6px; font-weight: 500; color: hsl(var(--muted-foreground)); cursor: pointer; position: relative; }
.seg label:hover { color: hsl(var(--foreground)); }
.seg label:has(:checked) { background: hsl(var(--card)); color: hsl(var(--foreground)); box-shadow: 0 1px 2px hsl(var(--shadow) / 0.12); }
.seg label:has(:focus-visible) { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.code-input { font-family: var(--mono) !important; font-size: 1.25rem !important; letter-spacing: 0.15em; text-transform: uppercase; text-align: center; }

/* --- Content -------------------------------------------------------------------------------- */
.prose { overflow-wrap: anywhere; line-height: 1.6; }
.prose > :first-child { margin-top: 0; }
.prose ul { margin: 0; }
.kv { display: grid; grid-template-columns: 5rem 1fr; gap: 0.375rem 0.75rem; margin: 0; padding: 0.875rem 1rem;
  border-radius: var(--radius); background: hsl(var(--secondary)); }
.kv dt { color: hsl(var(--muted-foreground)); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv dd.code { font-family: var(--mono); font-size: 1.375rem; font-weight: 600; letter-spacing: 0.12em; line-height: 1.2; }
.secret { display: flex; align-items: center; gap: 0.5rem; padding: 0.375rem 0.375rem 0.375rem 0.75rem; border-radius: var(--radius);
  background: hsl(var(--secondary)); }
.secret code { flex: 1; min-width: 0; background: none; padding: 0; font-size: 0.875rem; }
.split { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 40rem) { .split { grid-template-columns: minmax(0, 1fr) auto; } }
.qr { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.qr img { width: 13rem; height: 13rem; image-rendering: pixelated; border-radius: var(--radius); background: #fff; padding: 0.5rem;
  border: 1px solid hsl(var(--border)); }
.qr-more > summary { cursor: pointer; color: hsl(var(--muted-foreground)); font-weight: 500; font-size: 0.8125rem; }
.qr-more > summary:hover { color: hsl(var(--foreground)); }
.qr-more[open] > summary { margin-bottom: 0.75rem; }
.qr figcaption { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.steps-list { margin: 0; padding-left: 1.25rem; }
.steps-list li { margin: 0.5rem 0; padding-left: 0.25rem; }
.steps-list pre { margin: 0.375rem 0 0; }
.spinner { width: 1.75rem; height: 1.75rem; border-radius: 50%; border: 2.5px solid hsl(var(--border));
  border-top-color: hsl(var(--primary)); animation: spin 0.8s linear infinite; margin-bottom: 0.25rem; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner, .tag.pending .dot { animation: none; } }
.step { width: 1.5rem; height: 1.5rem; flex: none; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); font-size: 0.75rem; font-weight: 600; }
.steps-list.guide li { margin: 0.625rem 0; }
.steps-list i, .plain i { color: hsl(var(--muted-foreground)); font-style: normal; }
ul.plain { margin: 0.5rem 0 0; padding-left: 1.1rem; }
ul.plain li { margin: 0.375rem 0; }
