/* ==================================================================
   ORBIX MINI — styles for assets/orbix-mini.js (the mini apps).
   Every colour comes from the app through a few tokens, so the shared
   pieces wear each app's own theme:
     --om-accent   brand colour          --om-surface  panels / sheets
     --om-card     cards inside panels   --om-text / --om-text2
     --om-line     hairlines             --om-font
   ================================================================== */
.om-mini {
  --om-accent: #7c5cfc;
  --om-on-accent: #fff;
  --om-surface: #ffffff;
  --om-card: rgba(127, 127, 127, .07);
  --om-text: #111;
  --om-text2: #6b7280;
  --om-line: rgba(127, 127, 127, .2);
  --om-green: #10b981;
  --om-ease: cubic-bezier(.22, 1, .36, 1);
  --om-spring: cubic-bezier(.34, 1.4, .64, 1);
  --om-tab-h: 62px;
  --om-safe-b: env(safe-area-inset-bottom, 0px);
}

/* ── Buttons, links, pills ─────────────────────────────────────────── */
.om-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  font: 600 13.5px/1.2 var(--om-font, inherit); text-decoration: none; white-space: nowrap;
  transition: filter .15s, background .15s, opacity .15s;
}
.om-btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 10px; }
.om-btn-primary { background: var(--om-accent); color: var(--om-on-accent); }
.om-btn-primary:hover { filter: brightness(1.08); }
.om-btn-ghost { background: var(--om-card); color: var(--om-text); border-color: var(--om-line); }
.om-btn:disabled { opacity: .55; cursor: default; filter: none; }
.om-link {
  background: none; border: 0; padding: 4px 2px; cursor: pointer; text-decoration: none;
  font: 600 12.5px var(--om-font, inherit); color: var(--om-accent);
}
.om-link:hover { text-decoration: underline; }
.om-pill {
  font: 600 10.5px var(--om-font, inherit); letter-spacing: .2px; padding: 3px 8px; border-radius: 99px;
  background: var(--om-card); color: var(--om-text2); border: 1px solid var(--om-line); white-space: nowrap;
}
.om-pill.ok { color: var(--om-green); border-color: color-mix(in srgb, var(--om-green) 35%, transparent); background: color-mix(in srgb, var(--om-green) 10%, transparent); }
.om-pill.soon { opacity: .75; }
.om-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px;
  background: var(--om-green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--om-green) 20%, transparent);
}
.om-credit { display: inline-block; font: 500 11.5px var(--om-font, inherit); color: var(--om-text2); text-decoration: none; opacity: .85; }
.om-credit b { color: var(--om-text); font-weight: 700; }
.om-credit:hover { opacity: 1; }

/* ── Top-bar "Study OS" button ─────────────────────────────────────── */
.om-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 8px; flex-shrink: 0;
  border-radius: 99px; border: 1px solid var(--om-line); background: var(--om-card); color: var(--om-text);
  font: 600 12.5px var(--om-font, inherit); cursor: pointer; white-space: nowrap;
  transition: background .2s, border-color .2s;
}
.om-chip:hover { border-color: var(--om-accent); }
.om-chip-ic { font-size: 15px; line-height: 1; display: inline-flex; }
.om-chip.on { border-color: color-mix(in srgb, var(--om-accent) 45%, transparent); background: color-mix(in srgb, var(--om-accent) 10%, transparent); }
@media (max-width: 480px) {
  .om-chip { padding: 0 9px; }
  .om-chip-txt { display: none; }
}

/* ── Settings card ─────────────────────────────────────────────────── */
.om-set { color: var(--om-text); font-family: var(--om-font, inherit); }
.om-set-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.om-set-head > span { font-size: 15px; font-weight: 700; }
.om-set-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--om-line); }
.om-set-head + .om-set-row { border-top: 0; }
.om-set-ic {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  font-size: 19px; background: var(--om-card); border: 1px solid var(--om-line);
}
.om-set-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.om-set-txt b { font-size: 13.5px; font-weight: 600; }
.om-set-txt small { font-size: 12px; color: var(--om-text2); line-height: 1.45; }
.om-set .om-credit { margin-top: 10px; }
.om-switch {
  position: relative; width: 46px; height: 28px; flex-shrink: 0; border-radius: 99px; border: 0; cursor: pointer; padding: 0;
  background: var(--om-line); transition: background .22s var(--om-ease);
}
.om-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: transform .3s var(--om-spring);
}
.om-switch.on { background: var(--om-accent); }
.om-switch.on::after { transform: translateX(18px); }

/* ── Orbix panel ───────────────────────────────────────────────────── */
.om-panel-wrap {
  position: fixed; inset: 0; z-index: 99980; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(8, 10, 20, .42); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: omFade .22s ease;
}
.om-panel {
  width: min(640px, 100%); max-height: min(86vh, 860px); overflow-y: auto; overscroll-behavior: contain;
  padding: 22px; border-radius: 28px; border: 1px solid var(--om-line);
  background: var(--om-surface); color: var(--om-text); font-family: var(--om-font, inherit);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .35);
}
.om-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.om-panel-title { font-size: 22px; font-weight: 800; letter-spacing: -.4px; }
.om-panel-sub { font-size: 12.5px; color: var(--om-text2); margin-top: 2px; }
.om-panel-x, .om-pair-x {
  width: 32px; height: 32px; border-radius: 50%; border: 0; flex-shrink: 0; cursor: pointer;
  background: var(--om-card); color: var(--om-text2); font-size: 13px; display: inline-flex; align-items: center; justify-content: center;
}
.om-sec { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--om-text2); margin: 18px 0 10px; }
.om-study {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 18px;
  background: var(--om-card); border: 1px solid var(--om-line);
}
.om-study.on { border-color: color-mix(in srgb, var(--om-accent) 40%, transparent); background: color-mix(in srgb, var(--om-accent) 8%, var(--om-card)); }
.om-study-ic { width: 46px; height: 46px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 24px; background: var(--om-surface); border: 1px solid var(--om-line); flex-shrink: 0; }
.om-study-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.om-study-txt b { font-size: 14.5px; font-weight: 700; }
.om-study-txt small { font-size: 12px; color: var(--om-text2); line-height: 1.45; }
.om-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 10px; }
.om-card { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 18px; background: var(--om-card); border: 1px solid var(--om-line); }
.om-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.om-card-ic { font-size: 26px; line-height: 1; }
.om-card-name { font-size: 14px; font-weight: 700; margin-top: 2px; }
.om-card-desc { font-size: 12px; color: var(--om-text2); line-height: 1.45; flex: 1; }
.om-card-actions { display: flex; gap: 8px; margin-top: 4px; }
.om-panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--om-line); }
.om-panel-wrap.om-out { animation: omFadeOut .24s ease forwards; }
.om-panel-wrap.om-out .om-panel { animation: omSheetOut .26s var(--om-ease) forwards; }
@keyframes omFade { from { opacity: 0; } }
@keyframes omFadeOut { to { opacity: 0; } }
@keyframes omSheetIn { from { transform: translateY(100%); } }
@keyframes omSheetOut { to { transform: translateY(100%); } }
@media (max-width: 640px) {
  .om-panel-wrap { align-items: flex-end; padding: 0; }
  .om-panel { width: 100%; max-height: 90vh; border-radius: 28px 28px 0 0; padding: 14px 16px calc(18px + var(--om-safe-b)); animation: omSheetIn .42s var(--om-ease); }
  .om-panel::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; margin: 0 auto 12px; background: var(--om-line); }
  .om-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .om-study { flex-wrap: wrap; }
  .om-study-txt { flex-basis: calc(100% - 60px); }
}

/* ── Link card (AirPods-style) ─────────────────────────────────────── */
.om-pair-wrap {
  position: fixed; inset: 0; z-index: 99990; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(8, 10, 20, .32); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: omFade .22s ease;
}
.om-pair {
  position: relative; width: min(370px, 100%); max-height: 92vh; overflow-y: auto; text-align: center; padding: 26px 22px 20px;
  border-radius: 30px; border: 1px solid var(--om-line); background: var(--om-surface); color: var(--om-text);
  font-family: var(--om-font, inherit); box-shadow: 0 28px 80px rgba(0, 0, 0, .3);
}
.om-pair-x { position: absolute; top: 14px; right: 14px; }
.om-pair-visual { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 6px 0 18px; }
.om-pair-tile {
  position: relative; width: 66px; height: 66px; border-radius: 20px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 32px; background: var(--om-card); border: 1px solid var(--om-line); box-shadow: 0 8px 22px rgba(0, 0, 0, .1);
  transition: transform .4s var(--om-spring);
}
.om-pair-dots { display: inline-flex; gap: 5px; }
.om-pair-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--om-line); }
.om-pair[data-state="linking"] .om-pair-dots i { animation: omFlow 1s ease-in-out infinite; }
.om-pair[data-state="linking"] .om-pair-dots i:nth-child(2) { animation-delay: .12s; }
.om-pair[data-state="linking"] .om-pair-dots i:nth-child(3) { animation-delay: .24s; }
.om-pair[data-state="linking"] .om-pair-dots i:nth-child(4) { animation-delay: .36s; }
.om-pair[data-state="linking"] .om-pair-dots i:nth-child(5) { animation-delay: .48s; }
@keyframes omFlow { 0%, 100% { background: var(--om-line); transform: scale(1); } 40% { background: var(--om-accent); transform: scale(1.35); } }
.om-pair[data-state="done"] .om-pair-dots i { background: var(--om-green); }
.om-pair[data-state="done"] .om-pair-tile { transform: scale(1.04); }
.om-pair-check {
  position: absolute; right: -7px; bottom: -7px; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 900; color: #fff;
  background: var(--om-green); border: 3px solid var(--om-surface); transform: scale(0); opacity: 0;
  transition: transform .45s cubic-bezier(.2, 1.4, .4, 1), opacity .2s;
}
.om-pair[data-state="done"] .om-pair-check { transform: scale(1); opacity: 1; }
.om-pair-title { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.om-pair-sub { font-size: 13px; color: var(--om-text2); line-height: 1.55; margin: 6px auto 16px; max-width: 300px; }
.om-pair-list { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.om-pair-list:empty { display: none; }
.om-pair-list + .om-pair-actions:not(:empty) { margin-top: 12px; }
.om-pick {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 16px; cursor: pointer;
  background: var(--om-card); border: 1px solid var(--om-line); color: var(--om-text); font-family: inherit; text-align: left;
}
.om-pick:hover, .om-pick:focus-visible { border-color: var(--om-accent); }
.om-pick-ic { font-size: 24px; width: 32px; text-align: center; }
.om-pick-txt { flex: 1; display: flex; flex-direction: column; }
.om-pick-txt b { font-size: 14px; }
.om-pick-txt small { font-size: 11.5px; color: var(--om-text2); }
.om-pick-tag { font-size: 10px; font-weight: 700; color: var(--om-green); white-space: nowrap; }
.om-pair-actions { display: flex; flex-direction: column; gap: 8px; }
.om-pair-actions .om-btn { width: 100%; padding: 12px; font-size: 14px; border-radius: 14px; white-space: normal; }
.om-pair-note { font-size: 11px; color: var(--om-text2); margin-top: 10px; }
.om-pair-note:empty { display: none; }
@media (max-width: 640px) {
  .om-pair-wrap { align-items: flex-end; padding: 10px 10px calc(10px + var(--om-safe-b)); }
  .om-pair { width: 100%; border-radius: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  .om-pair[data-state="linking"] .om-pair-dots i { animation: none; background: var(--om-accent); }
}

/* ── Phone tab bar + More sheet ────────────────────────────────────── */
.om-tabbar, .om-more, .om-scrim { display: none; }
@media (max-width: 900px) {
  html.om-has-tabs .om-tabbar {
    display: flex; position: fixed; z-index: 1180; gap: 2px; padding: 6px;
    left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
    bottom: calc(10px + var(--om-safe-b)); height: var(--om-tab-h); border-radius: 24px;
    background: color-mix(in srgb, var(--om-surface) 84%, transparent);
    -webkit-backdrop-filter: blur(28px) saturate(180%); backdrop-filter: blur(28px) saturate(180%);
    border: 1px solid var(--om-line); box-shadow: 0 10px 34px rgba(0, 0, 0, .18);
    transition: transform .45s var(--om-ease), opacity .3s;
  }
  html.om-kbd .om-tabbar, html.om-tabs-hidden .om-tabbar, html.om-more-open .om-tabbar, html.om-modal-open .om-tabbar { transform: translateY(calc(100% + 24px)); opacity: 0; pointer-events: none; }
  .om-tab {
    flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 0; background: transparent; cursor: pointer; border-radius: 18px; color: var(--om-text2); font-family: var(--om-font, inherit);
  }
  .om-tab::before {
    content: ""; position: absolute; inset: 0; border-radius: 18px; opacity: 0; transform: scale(.82);
    background: color-mix(in srgb, var(--om-accent) 14%, transparent);
    transition: opacity .25s var(--om-ease), transform .45s var(--om-spring);
  }
  .om-tab.active { color: var(--om-accent); }
  .om-tab.active::before { opacity: 1; transform: scale(1); }
  .om-tab-ic { position: relative; height: 24px; display: flex; align-items: center; font-size: 21px; filter: grayscale(.35); opacity: .8; transition: transform .45s var(--om-spring), filter .25s, opacity .25s; }
  .om-tab.active .om-tab-ic { filter: none; opacity: 1; transform: translateY(-1px) scale(1.06); }
  .om-tab-ic svg.oi { width: 22px; height: 22px; }
  .om-tab-lb { position: relative; font-size: 10px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  html.om-has-tabs .om-scrim {
    display: block; position: fixed; inset: 0; z-index: 1190; background: rgba(0, 0, 0, .34);
    opacity: 0; visibility: hidden; transition: opacity .3s var(--om-ease), visibility 0s linear .3s;
  }
  .om-scrim.open { opacity: 1 !important; visibility: visible !important; transition: opacity .3s var(--om-ease), visibility 0s !important; }
  html.om-has-tabs .om-more {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1200; max-height: 80vh; overflow-y: auto; overscroll-behavior: contain;
    padding: 0 14px calc(16px + var(--om-safe-b)); border-radius: 28px 28px 0 0;
    background: var(--om-surface); color: var(--om-text); border-top: 1px solid var(--om-line); box-shadow: 0 -18px 60px rgba(0, 0, 0, .22);
    transform: translateY(105%); visibility: hidden; transition: transform .36s cubic-bezier(.4, 0, 1, 1), visibility 0s linear .36s;
  }
  html.om-has-tabs .om-more.open { transform: translateY(var(--om-drag, 0px)); visibility: visible; transition: transform .5s var(--om-ease), visibility 0s; }
  html.om-has-tabs .om-more.dragging { transition: none; }
  .om-more-grab { position: sticky; top: 0; height: 24px; cursor: grab; background: var(--om-surface); }
  .om-more-grab::after { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; margin: 10px auto 0; background: var(--om-line); }
  .om-more-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-top: 6px; }
  .om-more-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 78px; padding: 10px 6px;
    border-radius: 18px; border: 1px solid var(--om-line); background: var(--om-card); color: var(--om-text); cursor: pointer;
    font: 600 12px var(--om-font, inherit); text-align: center;
  }
  .om-more-item.on { border-color: var(--om-accent); color: var(--om-accent); background: color-mix(in srgb, var(--om-accent) 10%, var(--om-card)); }
  .om-more-ic { font-size: 22px; line-height: 1; }
}
@media (min-width: 560px) and (max-width: 900px) {
  html.om-has-tabs .om-tabbar { left: 50%; right: auto; width: min(560px, calc(100% - 48px)); transform: translateX(-50%); }
  html.om-kbd .om-tabbar, html.om-tabs-hidden .om-tabbar, html.om-more-open .om-tabbar, html.om-modal-open .om-tabbar { transform: translate(-50%, calc(100% + 24px)); }
  html.om-has-tabs .om-more { left: 50%; right: auto; width: min(560px, calc(100% - 32px)); margin-left: calc(min(560px, calc(100% - 32px)) / -2); }
  .om-more-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ── Motion: View Transitions (true morph from what you tapped) ────── */
html.om-vt .om-panel-wrap, html.om-vt .om-pair-wrap, html.om-vt .om-panel { animation-duration: 0s !important; animation-delay: 0s !important; }
::view-transition-group(om-morph) {
  animation-duration: var(--om-dur, 480ms);
  animation-timing-function: var(--om-ease, cubic-bezier(.22, 1, .36, 1));
  overflow: clip;
}
::view-transition-image-pair(om-morph) { isolation: isolate; }
::view-transition-old(om-morph), ::view-transition-new(om-morph) {
  width: 100%; height: 100%; mix-blend-mode: plus-lighter;
  animation-timing-function: cubic-bezier(.33, 0, .2, 1); animation-fill-mode: both;
}
html.om-vt-open::view-transition-old(om-morph)  { object-fit: none; object-position: center; animation-name: omOut; animation-duration: calc(var(--om-dur, 480ms) * .3); }
html.om-vt-open::view-transition-new(om-morph)  { object-fit: cover; object-position: 50% 0; animation-name: omIn; animation-duration: calc(var(--om-dur, 480ms) * .45); }
html.om-vt-close::view-transition-old(om-morph) { object-fit: cover; object-position: 50% 0; animation-name: omOut; animation-duration: calc(var(--om-dur, 480ms) * .62); animation-delay: calc(var(--om-dur, 480ms) * .18); }
html.om-vt-close::view-transition-new(om-morph) { object-fit: none; object-position: center; animation-name: omIn; animation-duration: calc(var(--om-dur, 480ms) * .5); animation-delay: calc(var(--om-dur, 480ms) * .3); }
@keyframes omOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes omIn  { from { opacity: 0; } to { opacity: 1; } }
::view-transition-old(root), ::view-transition-new(root) {
  animation-duration: calc(var(--om-dur, 480ms) * .7);
  animation-timing-function: cubic-bezier(.4, 0, .2, 1);
}
html.om-off .om-panel, html.om-off .om-panel-wrap, html.om-off .om-pair-wrap, html.om-off .om-more, html.om-off .om-tabbar { animation-duration: .01s !important; transition-duration: .01s !important; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .om-panel, .om-panel-wrap, .om-pair-wrap, .om-more, .om-tabbar { animation: none !important; transition-duration: .01s !important; }
}

/* ── Small shared polish ───────────────────────────────────────────── */
.om-mini body { -webkit-tap-highlight-color: transparent; }
.om-mini :focus-visible { outline: 2px solid var(--om-accent); outline-offset: 2px; }
/* Inside a study app the add-on has the study app's chrome around it */
html.om-embedded #orbix-pwa-bottom-pill, html.om-embedded #orbix-pwa-guide-modal { display: none !important; }
