/* ===========================================================================
   LazyOlie shell - base, wordmark, chrome, springboard, forms, admin.
   Plugin-specific styling lives in public/plugins/<id>/style.css.
   =========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg-pattern), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.2; }
p { margin: 0 0 10px; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--pink-600); }

::selection { background: var(--pink-200); color: #22161D; }

:focus-visible {
  outline: 3px solid var(--pink-400);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------- wordmark -------------------------------- */
/*
   The Barbie treatment: script face, pink gradient fill, white outline, a
   forward tilt and a sparkle.

   The outline is a second copy of the word sitting underneath the gradient
   one. Stacking them in source order rather than with z-index matters: the
   gradient copy uses background-clip:text, and a background always paints
   below a negative-z-index child, so the outline would cover the letters.
*/
.logo {
  position: relative;
  display: inline-block;
  font-family: var(--font-logo);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.15;
  transform: rotate(-3deg);
  padding: 0.1em 0.3em 0.14em 0.06em;
  user-select: none;
  white-space: nowrap;
  filter: drop-shadow(var(--logo-shadow));
}

.logo__stack {
  position: relative;
  display: inline-block;
}

.logo__outline,
.logo__fill {
  display: block;
  grid-area: 1 / 1;
}

.logo__outline {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--logo-stroke);
  -webkit-text-stroke: 0.1em var(--logo-stroke);
  text-stroke: 0.1em var(--logo-stroke);
}

.logo__fill {
  position: relative;
  background: var(--logo-fill);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.logo__sparkle {
  position: absolute;
  top: 0.02em;
  right: -0.02em;
  width: 0.3em;
  height: 0.3em;
  color: var(--pink-400);
  animation: sparkle 2.8s var(--ease) infinite;
}

@keyframes sparkle {
  0%, 70%, 100% { transform: scale(1) rotate(0deg); opacity: 0.95; }
  82%           { transform: scale(1.35) rotate(20deg); opacity: 1; }
}

.logo--xl { font-size: 54px; }
.logo--lg { font-size: 36px; }
.logo--sm { font-size: 23px; }

/* --------------------------------- layout -------------------------------- */

#app { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 12px 0;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar__title {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__spacer { flex: 1; }

/* Sits tight against Back so the two read as one navigation pair, rather than
   as a button that belongs with the title. */
.topbar__home { margin-left: -8px; }

.screen {
  flex: 1;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 16px 14px calc(28px + var(--safe-bottom));
}

.screen--wide { max-width: 860px; }

.screen--center {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  padding: 24px 18px calc(24px + var(--safe-bottom));
}

/* --------------------------------- buttons -------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.12s var(--ease), box-shadow 0.18s var(--ease), background 0.18s;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.55; cursor: default; transform: none; }

.btn--primary {
  background: var(--grad-pink);
  color: var(--on-pink);
  box-shadow: 0 6px 18px var(--pink-glow);
}
.btn--primary:active { box-shadow: 0 3px 10px var(--pink-glow); }

.btn--ghost { background: transparent; border-color: var(--border-strong); }
.btn--quiet { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--block { width: 100%; }
.btn--sm { min-height: 38px; padding: 0 14px; font-size: 13.5px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.16s, transform 0.12s var(--ease), color 0.16s;
}
.icon-btn:hover { background: var(--surface-sunken); color: var(--text); }
.icon-btn:active { transform: scale(0.9); }
.icon-btn svg { width: 22px; height: 22px; }

/* --------------------------------- cards ---------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 2px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.section-title:first-child { margin-top: 4px; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 13px; }

/* ------------------------------ springboard ------------------------------- */

.greeting { margin: 6px 2px 2px; font-size: 22px; }
.greeting span { color: var(--pink-600); }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  aspect-ratio: 1 / 1;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-tile);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.16s var(--ease), box-shadow 0.2s var(--ease);
}
.tile::after {
  /* A soft wash of the plugin's own colour in the corner. */
  content: '';
  position: absolute;
  right: -34%;
  top: -42%;
  width: 118%;
  height: 118%;
  border-radius: 50%;
  background: var(--tile-color, var(--pink-400));
  opacity: 0.12;
  pointer-events: none;
}
.tile:active { transform: scale(0.955); box-shadow: var(--shadow-sm); }

.tile__icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
}
.tile__icon img, .tile__icon svg { width: 100%; height: 100%; }

.tile__name { font-size: 15px; font-weight: 700; }
.tile__tag {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 1px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile--soon { opacity: 0.5; cursor: default; }
.tile--soon:active { transform: none; }

/* --------------------------------- forms ---------------------------------- */

.field { margin-bottom: 14px; }

.field__label {
  display: block;
  margin: 0 0 6px 4px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.input, .textarea, .select {
  width: 100%;
  min-height: var(--tap);
  padding: 13px 15px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  /* 16px keeps iOS Safari from zooming when the field takes focus. */
  font-size: 16px;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--pink-400);
  box-shadow: 0 0 0 4px var(--pink-glow);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }

.textarea { min-height: 170px; resize: vertical; line-height: 1.5; }

.select { appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23B58AA3' stroke-width='2.5' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 18px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: var(--tap);
  cursor: pointer;
  user-select: none;
}
.checkbox input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox__box {
  width: 24px; height: 24px; flex: 0 0 24px;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  display: grid; place-items: center;
  transition: background 0.16s, border-color 0.16s, transform 0.12s var(--ease);
}
.checkbox__box svg { width: 15px; height: 15px; color: #fff; opacity: 0; transform: scale(0.5); transition: all 0.16s var(--ease); }
.checkbox input:checked + .checkbox__box { background: var(--grad-pink); border-color: transparent; }
.checkbox input:checked + .checkbox__box svg { opacity: 1; transform: scale(1); }
.checkbox input:focus-visible + .checkbox__box { box-shadow: 0 0 0 4px var(--pink-glow); }

.switch { display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  width: 52px; height: 30px; border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background 0.2s var(--ease);
}
.switch__track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.2s var(--ease);
}
.switch input:checked + .switch__track { background: var(--grad-pink); }
.switch input:checked + .switch__track::after { transform: translateX(22px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 4px var(--pink-glow); }

.form-error {
  display: none;
  margin: 0 0 12px;
  padding: 11px 14px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 34%, transparent);
  color: var(--danger);
  font-size: 13.5px;
}
.form-error.is-visible { display: block; }

/* ---------------------------------- auth ---------------------------------- */

.auth { width: 100%; max-width: 400px; }
.auth__logo { text-align: center; margin-bottom: 6px; }
.auth__tagline {
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 2px 0 22px;
}
.auth__card { padding: 22px 20px 18px; }
.auth__switch { text-align: center; margin-top: 14px; font-size: 13.5px; color: var(--text-muted); }
.auth__switch button {
  background: none; border: 0; padding: 4px 6px;
  color: var(--pink-600); font-weight: 700; cursor: pointer;
}

.badge-first {
  display: flex; gap: 10px; align-items: flex-start;
  margin-bottom: 16px; padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--panel-soft-bg);
  border: 1px solid var(--panel-soft-border);
  color: var(--panel-soft-text);
  font-size: 13px;
}

/* --------------------------------- rows ----------------------------------- */

.rows { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 58px; padding: 10px 15px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  width: 100%; text-align: left; border-left: 0; border-right: 0; border-top: 0;
}
.row:last-child { border-bottom: 0; }
button.row { cursor: pointer; transition: background 0.14s; }
button.row:active { background: var(--surface-sunken); }
.row__main { flex: 1; min-width: 0; }
.row__title { font-weight: 700; font-size: 14.5px; }
.row__sub { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--surface-sunken); border: 1px solid var(--border);
  font-size: 11.5px; font-weight: 700; color: var(--text-muted);
  white-space: nowrap;
}
.pill--pink { background: var(--grad-pink); border-color: transparent; color: #fff; }
.pill--ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.pill--off { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* --------------------------------- toasts --------------------------------- */

#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(440px, calc(100vw - 28px));
}

.toast {
  pointer-events: auto;
  max-width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s var(--ease);
}
.toast--error { border-color: var(--danger); color: var(--danger); }
.toast--ok { border-color: var(--success); }
.toast.is-out { animation: toast-out 0.24s var(--ease) forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(0.97); } }

/* --------------------------------- dialogs -------------------------------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: var(--overlay);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in 0.2s var(--ease);
  backdrop-filter: blur(2px);
}
.sheet {
  width: min(520px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--border);
  border-bottom: 0;
  padding: 10px 18px calc(20px + var(--safe-bottom));
  box-shadow: var(--shadow-lg);
  animation: sheet-up 0.28s var(--ease);
}
.sheet__grip {
  width: 40px; height: 4px; border-radius: 999px;
  background: var(--border-strong); margin: 4px auto 14px;
}
.sheet__title { font-size: 17px; margin-bottom: 12px; }
.sheet__actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet__actions .btn { flex: 1; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }

/* --------------------------------- spinner -------------------------------- */

.spinner {
  width: 18px; height: 18px; flex: 0 0 18px;
  border: 2.5px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  gap: 16px;
}

/* ---------------------------------- admin --------------------------------- */

.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.admin-row:last-child { border-bottom: 0; }
.admin-row__text { flex: 1; min-width: 0; }
.admin-row__text strong { display: block; font-size: 14.5px; }
.admin-row__text span { font-size: 12.5px; color: var(--text-muted); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; word-break: break-all; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

.user-card { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.user-card:last-child { border-bottom: 0; }
.avatar {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 50%;
  background: var(--grad-pink);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  text-transform: uppercase;
}
.avatar--sm { width: 32px; height: 32px; flex-basis: 32px; font-size: 13px; }
.avatar--xs { width: 20px; height: 20px; flex-basis: 20px; font-size: 9px; font-weight: 700; }

/* --------------------------- motion preferences --------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.ai-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* ---------------------------------- badges --------------------------------- */

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--surface);
}
.badge[hidden] { display: none; }

.tile__badge {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
}

/* ----------------------------------- dock ---------------------------------- */

/*
 * Floating buttons from background plugins. The container ignores pointers so
 * it never blocks the page; each button turns them back on for itself.
 */
#dock {
  position: fixed;
  right: 16px;
  bottom: calc(26px + var(--safe-bottom));
  z-index: 60;
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  pointer-events: none;
}

/*
 * Reserve room underneath so a floating button never sits on top of the last
 * thing on the page - Profile's Save was disappearing behind it. Only applies
 * while something is actually docked, so screens that hide it (chat's own) get
 * their space back.
 */
body:has(#dock > *:not([hidden])) .screen {
  padding-bottom: calc(104px + var(--safe-bottom));
}

/* --------------------------------- banners --------------------------------- */

#banners {
  position: fixed;
  top: calc(8px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 92;
  width: min(520px, calc(100vw - 20px));
  pointer-events: none;
}

.banner {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  box-shadow: var(--shadow-lg);
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
  animation: banner-in 0.28s var(--ease);
}
.banner.is-out { animation: banner-out 0.22s var(--ease) forwards; }

.banner__text { flex: 1; min-width: 0; }
.banner__title { font-size: 13.5px; font-weight: 700; }
.banner__body {
  font-size: 12.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.banner__close {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
}
.banner__close:hover { background: var(--surface-sunken); color: var(--text); }

@keyframes banner-in  { from { opacity: 0; transform: translateY(-14px) scale(0.97); } }
@keyframes banner-out { to   { opacity: 0; transform: translateY(-10px) scale(0.98); } }
