/* ==========================================================================
   App shells
     .shell--guest   login / register / errors (centered card, floating shapes)
     .shell--app     member app: sticky top bar + bottom tab bar (mobile first, framed column on desktop)
     .shell--manage  admin/PIC console: sidebar on laptops, page picker + tab bar on phones
   ========================================================================== */

/* ----------------------------------------------------------------- guest */
.guest { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 28px 16px calc(28px + var(--safe-b)); }
.guest__inner { width: min(100%, 440px); }
.guest__inner--wide { width: min(100%, 560px); }
.guest__brand { display: block; width: min(70%, 270px); margin: 0 auto 22px; animation: pop .7s var(--ease-pop) both; }
.guest__brand img { width: 100%; height: auto; }
.guest__title { text-align: center; margin-bottom: 6px; }
.guest__lead { text-align: center; color: var(--ink-2); margin-bottom: 20px; font-weight: 600; }
.guest__foot { margin-top: 22px; text-align: center; font-size: .85rem; color: var(--ink-2); }
.guest__verse { display: inline-block; margin-bottom: 10px; padding: 4px 12px; font: 800 .75rem var(--font-display); letter-spacing: .08em; text-transform: uppercase; background: var(--lime); border: 2px solid var(--ink); border-radius: var(--r-pill); transform: rotate(-1.5deg); }
.lang-switch { display: inline-flex; gap: 6px; }
.lang-switch a { padding: 4px 10px; font: 800 .75rem var(--font-display); color: var(--ink); text-decoration: none; border: 2px solid var(--ink); border-radius: var(--r-pill); background: #fff; }
.lang-switch a[aria-current="true"] { background: var(--sun); box-shadow: var(--shadow-sm); }

.deco { position: fixed; z-index: 0; border: var(--bw) solid var(--ink); pointer-events: none; animation: float 7s ease-in-out infinite; }
.deco--a { width: 120px; height: 120px; left: -64px; top: 7%; background: var(--blue); border-radius: 50%; --rot: 0deg; }
.deco--b { width: 84px; height: 84px; right: -20px; top: 22%; background: var(--lime); border-radius: 22px; --rot: 18deg; animation-delay: -2s; }
.deco--c { width: 70px; height: 70px; left: 8%; bottom: 8%; background: var(--orange); border-radius: 50% 50% 50% 8px; --rot: -12deg; animation-delay: -4s; }
.deco--d { width: 46px; height: 46px; right: 10%; bottom: 14%; background: var(--pink); border-radius: 50%; animation-delay: -1s; }
@media (min-width: 900px) {
  .deco--a { width: 220px; height: 220px; left: 6%; top: 12%; }
  .deco--b { width: 140px; height: 140px; right: 9%; top: 16%; }
  .deco--c { width: 110px; height: 110px; left: 14%; bottom: 12%; }
  .deco--d { width: 70px; height: 70px; right: 18%; bottom: 14%; }
}

/* ----------------------------------------------------------------- member app shell */
.shell--app { background-color: var(--paper-2); }
.app-frame { position: relative; max-width: var(--app-w); min-height: 100vh; min-height: 100dvh; margin: 0 auto; background-color: var(--paper); background-image: radial-gradient(rgba(22, 18, 15, .08) 1.3px, transparent 1.4px); background-size: 20px 20px; }
@media (min-width: 600px) {
  .app-frame { border-left: var(--bw) solid var(--ink); border-right: var(--bw) solid var(--ink); }
}

.topbar { position: sticky; top: 0; z-index: 30; padding-top: var(--safe-t); background: var(--paper); border-bottom: var(--bw) solid var(--ink); view-transition-name: topbar; }
.topbar__inner { display: flex; align-items: center; gap: 10px; min-height: var(--topbar-h); padding: 6px 14px; }
.brand { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; min-width: 0; } /* the full OMK logo, never cropped */
.brand img { width: auto; height: 44px; max-width: none; object-fit: contain; flex: none; transition: transform .4s var(--ease-pop); }
.brand:hover img { transform: rotate(-3deg) scale(1.05); }
.topbar__title { flex: 1; min-width: 0; font: 800 1.25rem/1.1 var(--font-display); letter-spacing: -.02em; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.back-btn { display: grid; place-items: center; flex: none; width: 44px; height: 44px; color: var(--ink); background: #fff; border: var(--bw) solid var(--ink); border-radius: 12px; box-shadow: var(--shadow-sm); transition: transform .14s var(--ease-pop), box-shadow .14s; }
.back-btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }

.page { padding: 18px 16px calc(var(--tabbar-h) + var(--safe-b) + 28px); }
.page--flush { padding-left: 0; padding-right: 0; }
.page-title { margin-bottom: 16px; }
.page-title p { margin-top: 6px; color: var(--ink-2); font-weight: 600; }
.section { margin-top: 26px; }
.section:first-child { margin-top: 0; }
.section__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section__head > :first-child { flex: 1 1 11rem; min-width: 0; }
.section__head > .btn { flex: none; white-space: nowrap; } /* a button never gets squeezed into a column of letters: it wraps below instead */

/* bottom tab bar (member + console on phones) */
.tabbar {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; margin: 0 auto; width: min(100%, var(--app-w));
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 6px var(--safe-b);
  background: #fff; border-top: var(--bw) solid var(--ink); view-transition-name: tabbar;
}
@media (min-width: 600px) { .tabbar { border-left: var(--bw) solid var(--ink); border-right: var(--bw) solid var(--ink); } }
.tab {
  --tab: var(--sun);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: var(--tabbar-h);
  color: var(--ink-3); text-decoration: none; font: 800 .68rem/1 var(--font-display); letter-spacing: .02em;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.tab__icon { position: relative; display: grid; place-items: center; width: 48px; height: 32px; border: 2.5px solid transparent; border-radius: var(--r-pill); transition: background-color .2s, transform .3s var(--ease-pop), border-color .2s, box-shadow .2s; }
.tab__icon .icon { width: 22px; height: 22px; }
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); }
.tab.is-active .tab__icon { background: var(--tab); border-color: var(--ink); box-shadow: var(--shadow-sm); transform: translateY(-3px); }
.tab:active .tab__icon { transform: scale(.86); }
.tab .badge { position: absolute; top: -8px; right: -4px; }

.tab--scan { color: var(--ink); }
.tab--scan .tab__icon { width: 66px; height: 66px; margin-top: -34px; color: var(--ink); background: var(--orange); border: var(--bw) solid var(--ink); border-radius: 50%; box-shadow: var(--shadow); transform: none; }
.tab--scan .tab__icon .icon { width: 30px; height: 30px; }
.tab--scan .tab__icon::before { content: ""; position: absolute; inset: -7px; border: 3px solid var(--orange); border-radius: 50%; animation: pulse-ring 2.6s ease-out infinite; pointer-events: none; }
.tab--scan.is-active .tab__icon { background: var(--lime); transform: none; box-shadow: var(--shadow); }
.tab--scan:active .tab__icon { transform: translate(3px, 3px) scale(.95); box-shadow: 1px 1px 0 var(--ink); }
.tab--scan .tab__label { margin-top: 0; }

/* ----------------------------------------------------------------- console (admin / PIC) */
.shell--manage { background-color: var(--paper); }
.console { min-height: 100vh; min-height: 100dvh; }
.console__main { min-width: 0; }
.console__content { padding: 18px 14px calc(var(--tabbar-h) + var(--safe-b) + 28px); max-width: 1280px; margin: 0 auto; }
.side { display: none; }

/* page picker (phones): a big dropdown that replaces the sidebar */
.picker { position: relative; flex: 1; min-width: 0; }
.picker .select { min-height: 44px; padding-top: 8px; padding-bottom: 8px; font: 800 1.05rem var(--font-display); background-color: var(--sun); border-radius: 14px; box-shadow: var(--shadow-sm); }
.picker .select:focus { box-shadow: 4px 4px 0 var(--blue); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.page-head h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.page-head p { margin-top: 6px; color: var(--ink-2); font-weight: 600; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; font: 800 .75rem var(--font-display); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.crumbs a { color: var(--ink-2); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .grow { min-width: 200px; }

@media (min-width: 960px) {
  .console { display: grid; grid-template-columns: 272px minmax(0, 1fr); }
  .console__top { display: none; }
  .console .tabbar { display: none; }
  .console__content { padding: 34px 40px 60px; }
  .side {
    position: sticky; top: 0; align-self: start; display: flex; flex-direction: column; gap: 6px;
    height: 100vh; height: 100dvh; padding: 20px 16px; overflow-y: auto;
    background: #fff; border-right: var(--bw) solid var(--ink);
  }
  .side__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; padding: 4px 4px 16px; border-bottom: 2px dashed rgba(22, 18, 15, .25); }
  .side__brand { display: block; min-width: 0; color: var(--ink); text-decoration: none; }
  .side__brand img { width: 150px; height: auto; max-width: 100%; transition: transform .4s var(--ease-pop); }
  .side__brand:hover img { transform: rotate(-3deg) scale(1.04); }
  .side__toggle { display: grid; place-items: center; flex: none; width: 38px; height: 38px; padding: 0; color: var(--ink); background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .14s var(--ease-pop), box-shadow .14s, background-color .15s; }
  .side__toggle:hover { background: var(--sun); }
  .side__toggle:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
  .side__toggle .i-open { display: none; }
  .side__label { margin: 14px 10px 6px; font: 800 .68rem/1 var(--font-display); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
  .side__link {
    display: flex; align-items: center; gap: 12px; padding: 11px 14px; color: var(--ink); text-decoration: none;
    font: 800 .95rem/1.1 var(--font-display); border: 2.5px solid transparent; border-radius: 14px;
    transition: background-color .15s, transform .2s var(--ease-pop), box-shadow .15s;
  }
  .side__link:hover { background: var(--paper-2); color: var(--ink); transform: translateX(3px); }
  .side__link.is-active { background: var(--sun); border-color: var(--ink); box-shadow: var(--shadow-sm); transform: none; }
  .side__link .badge { margin-left: auto; }
  .side__foot { margin-top: auto; padding-top: 14px; display: grid; gap: 10px; }
  .side__user { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--paper); border: var(--bw) solid var(--ink); border-radius: 16px; }

  /* collapsed sidebar: icons only (labels stay in the DOM for screen readers) */
  .console { transition: grid-template-columns .25s var(--ease-out); }
  .side-collapsed .console { grid-template-columns: 88px minmax(0, 1fr); }
  .side-collapsed .side { align-items: stretch; padding: 20px 12px; overflow-x: hidden; }
  .side-collapsed .side__head { flex-direction: column; gap: 12px; padding: 0 0 14px; }
  .side-collapsed .side__brand img { width: 52px; }
  .side-collapsed .side__toggle .i-close { display: none; }
  .side-collapsed .side__toggle .i-open { display: block; }
  .side-collapsed .side__label { height: 2px; margin: 12px 14px; font-size: 0; overflow: hidden; background: rgba(22, 18, 15, .16); border-radius: 2px; }
  .side-collapsed .side__link { position: relative; justify-content: center; padding: 12px 0; }
  .side-collapsed .side__link:hover { transform: none; }
  .side-collapsed .side__link > span:not(.badge), .side-collapsed .side__user .grow, .side-collapsed .side__foot .btn span {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .side-collapsed .side__link .badge { position: absolute; top: 2px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; font-size: .62rem; line-height: 14px; margin: 0; }
  .side-collapsed .side__user { justify-content: center; padding: 8px 0; }
  .side-collapsed .side__foot .btn { padding-left: 0; padding-right: 0; }
}

/* public reading shell (visitors without an account, used by the Info blog): wider column, no tab bar */
.shell--public { --app-w: 720px; }
.shell--public .page { padding-bottom: 24px; }
.public-foot { display: grid; gap: 16px; padding: 4px 16px 34px; }
.public-foot__card { display: grid; gap: 10px; }
.public-foot__title { font-size: 1.35rem; }
.public-foot__meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; font: 800 .8rem var(--font-display); color: var(--ink-2); }
.public-foot__link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }

/* laptops with a short screen: tighten the sidebar so the log out button stays visible without scrolling */
@media (min-width: 960px) and (max-height: 960px) {
  .side { gap: 3px; padding-top: 14px; padding-bottom: 14px; }
  .side__head { margin-bottom: 8px; padding-bottom: 12px; }
  .side__link { padding-top: 8px; padding-bottom: 8px; }
  .side__label { margin-top: 8px; margin-bottom: 4px; }
  .side__foot { padding-top: 8px; gap: 8px; }
}
@media (min-width: 960px) and (max-height: 800px) {
  .side__link { padding-top: 6px; padding-bottom: 6px; }
  .side__brand img { width: 128px; }
  .side__user { padding: 6px 8px; }
}

/* ----------------------------------------------------------------- error / info pages */
.big-art { display: grid; place-items: center; width: 150px; height: 150px; margin: 0 auto 18px; background: var(--sun); border: var(--bw) solid var(--ink); border-radius: 50%; box-shadow: var(--shadow-lg); animation: bob 3.2s ease-in-out infinite; }
.big-art img { width: 84px; transform: rotate(-8deg); }
.big-art .icon { width: 70px; height: 70px; }
.code-badge { display: inline-block; margin-bottom: 8px; padding: 4px 14px; font: 800 .8rem var(--font-display); letter-spacing: .14em; color: #fff; background: var(--ink); border-radius: var(--r-pill); }
.debug { margin-top: 18px; padding: 12px; max-height: 320px; overflow: auto; text-align: left; font: 500 .75rem/1.4 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; background: #fff; border: 2px solid var(--ink); border-radius: 12px; }

/* offline banner */
.offline-bar { position: fixed; z-index: 960; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b)); margin: 0 auto; width: min(100%, var(--app-w)); padding: 8px 14px; text-align: center; font: 800 .8rem var(--font-display); color: #fff; background: var(--ink); }

/* ----------------------------------------------------------------- notification bell (member + console top bars) and its badge */
.bell {
  position: relative; display: grid; place-items: center; flex: none; width: 40px; height: 40px; color: var(--ink);
  background: #fff; border: 2.5px solid var(--ink); border-radius: 50%; box-shadow: var(--shadow-sm); text-decoration: none;
  transition: transform .14s var(--ease-pop), box-shadow .14s, background-color .2s;
}
.bell::after { content: ""; position: absolute; inset: -4px; } /* 48px touch target around the 40px button */
.bell .icon { width: 20px; height: 20px; transform-origin: 50% 8%; }
.bell:hover { color: var(--ink); background: var(--sun-soft); }
.bell:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.bell.has-unread { background: var(--sun); }
.bell.has-unread .icon { animation: bell-ring 1.5s .5s ease-in-out 2; }
.bell.is-current { background: var(--lime); }
.bell__badge {
  position: absolute; z-index: 1; top: -8px; right: -8px; display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  font: 800 .66rem/1 var(--font-display); color: #fff; background: var(--crimson); border: 2px solid var(--ink); border-radius: var(--r-pill);
}
@keyframes bell-ring { 0%, 100% { transform: rotate(0); } 12% { transform: rotate(16deg); } 28% { transform: rotate(-13deg); } 44% { transform: rotate(9deg); } 60% { transform: rotate(-6deg); } 76% { transform: rotate(3deg); } }
/* the console's phone top bar is crowded (logo + page picker + bell + avatar): give the page picker the room on very small phones */
@media (max-width: 380px) {
  .console__top .topbar__inner { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .console__top .brand img { height: 36px; }
  .console__top .picker .select { padding-left: 10px; font-size: .95rem; }
}
