/* Rubi: coral-red mascot on a dark field. Dark is the default; light follows the system setting. */
:root {
  --bg: #0f0d0d;
  --bg-2: #161313;
  --card: #1b1717;
  --text: #f5f1ee;
  --muted: #a59d97;
  --line: #2d2726;
  --accent: #ce383d;
  --accent-2: #e2585c;
  --accent-ink: #ffffff;
  --eye: #0b0909;
  --danger: #ff7b72;
  --ok: #7fd18b;
  --radius: 20px;
  --radius-sm: 12px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf7f5;
    --bg-2: #f3eeea;
    --card: #ffffff;
    --text: #1b1716;
    --muted: #6f6762;
    --line: #ebe3de;
    --accent: #ce383d;
    --accent-2: #b92e33;
    --accent-ink: #ffffff;
    --eye: #1b1111;
    --danger: #b3261e;
    --ok: #2e7d32;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); }
h1, h2, h3 { letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }

/* ---------- mascot ---------- */

.mascot-eyes rect, .mascot-eyes path:not(.eye-stroke) { fill: var(--eye); }
.mascot-eyes .eye-stroke { stroke: var(--eye); }
.mascot.mood-idle .mascot-eyes { transform-origin: 50% 48%; animation: blink 5s infinite; }
.mascot.mood-alert { animation: nudge 0.6s ease-in-out 2; }

@keyframes blink {
  0%, 94%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.1); }
}
@keyframes nudge {
  0%, 100% { transform: rotate(0); }
  30% { transform: rotate(-6deg); }
  70% { transform: rotate(6deg); }
}
@media (prefers-reduced-motion: reduce) {
  .mascot .mascot-eyes, .mascot { animation: none !important; }
}

/* ---------- landing ---------- */

#landing { max-width: 960px; margin: 0 auto; padding: 0 20px max(32px, env(safe-area-inset-bottom)); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 0 18px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.toplink { color: var(--muted); text-decoration: none; font-weight: 600; }
.toplink:hover { color: var(--text); }

.hero { text-align: center; padding: 48px 0 56px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.hero-mascot { filter: drop-shadow(0 18px 40px rgba(206, 56, 61, 0.35)); }
.hero h1 { font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1.08; }
.lede { max-width: 620px; color: var(--muted); font-size: 1.15rem; }

.install { width: 100%; max-width: 680px; margin-top: 8px; text-align: left; }
.install-label { color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }
.install-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 12px 12px 16px;
}
.install-box code { flex: 1; font: 0.9rem/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow-wrap: anywhere; color: var(--text); }
button.copy { width: auto; padding: 8px 14px; font-size: 0.85rem; background: var(--accent); color: var(--accent-ink); border-radius: 10px; flex-shrink: 0; }

.steps, .features, .integrations { padding: 28px 0; }
.steps h2, .integrations h2 { font-size: 1.5rem; margin-bottom: 18px; }
.steps ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.steps li { display: flex; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.steps h3, .feature h3 { font-size: 1.05rem; margin-bottom: 6px; }
.steps p, .feature p { color: var(--muted); font-size: 0.95rem; }
.num {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
}

.features { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.feature { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }

.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.chip.on { border-color: var(--accent); color: var(--text); }
.chip.on::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 8px; vertical-align: 1px; }

.footer { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.9rem; padding: 32px 0 8px; border-top: 1px solid var(--line); margin-top: 24px; }
.footer a { color: var(--muted); }

/* ---------- panel ---------- */

#app {
  min-height: 100vh; min-height: 100dvh;
  display: flex; justify-content: center; align-items: flex-start;
  padding: max(28px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}
#app[hidden] { display: none; }

.card {
  width: 100%; max-width: 460px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 20px; display: flex; flex-direction: column; gap: 14px;
}
.card h1 { font-size: 1.5rem; line-height: 1.25; overflow-wrap: anywhere; }
.card h2 { font-size: 1rem; margin-top: 10px; }

.screen-mascot { display: flex; justify-content: center; margin: 4px 0 2px; }

.muted { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.eyebrow { color: var(--accent-2); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.question { font-weight: 600; }
.error { color: var(--danger); }
.ok { color: var(--ok); }

.instance { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.instance .mascot { flex-shrink: 0; }

form { display: flex; flex-direction: column; gap: 10px; }

input, select {
  font: inherit; padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-2); color: var(--text); width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit; font-weight: 650; padding: 14px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; width: 100%;
  transition: transform 0.08s ease, background 0.15s ease;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.6; cursor: progress; }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.primary:hover { background: var(--accent-2); }
button.secondary { background: transparent; color: var(--text); border-color: var(--line); }
button.danger { background: transparent; color: var(--danger); border-color: var(--line); }
button.link { background: none; color: var(--muted); font-weight: 500; padding: 4px; text-decoration: underline; }
button.small { width: auto; padding: 8px 12px; font-size: 0.9rem; }

.actions { display: flex; flex-direction: column; gap: 10px; }

.preview { margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.preview .row { display: grid; grid-template-columns: 88px 1fr; gap: 10px; padding: 11px 12px; border-top: 1px solid var(--line); }
.preview .row:first-child { border-top: 0; }
.preview dt { color: var(--muted); font-size: 0.85rem; }
.preview dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
pre.body { margin: 0; white-space: pre-wrap; font: inherit; overflow-wrap: anywhere; max-height: 50vh; overflow: auto; }

.receipts { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.9rem; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 0.95rem; }
.field small, .field span small { color: var(--muted); font-weight: 400; font-size: 0.85rem; display: block; }
.row-field { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.row-field select { max-width: 55%; }
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
a.button-link { color: var(--accent-2); font-weight: 600; font-size: 0.95rem; }

/* ---------- approval request ---------- */

.req-top { display: flex; align-items: center; gap: 10px; }
.req-who { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
.req-who strong { font-size: 0.95rem; }
.req-who span { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer {
  font-variant-numeric: tabular-nums; font-size: 0.85rem; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
}
.timer.urgent { color: var(--danger); border-color: var(--danger); }

.mail { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-2); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.mail-row { display: grid; grid-template-columns: 40px 1fr; gap: 8px; align-items: start; }
.mail-label { color: var(--muted); font-size: 0.85rem; padding-top: 6px; }
.mail-note { grid-column: 2; color: var(--muted); font-size: 0.8rem; }
.chips-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar-dot {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-2); font-weight: 700; font-size: 0.9rem;
}
.person-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.person-name { font-weight: 600; overflow-wrap: anywhere; }
.person-email { color: var(--muted); font-size: 0.82rem; overflow-wrap: anywhere; }
.mail-subject { font-weight: 700; font-size: 1.08rem; padding-top: 10px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.mail-thread { color: var(--muted); font-size: 0.82rem; }
.mail-body { margin: 0; white-space: pre-wrap; font: inherit; line-height: 1.55; overflow-wrap: anywhere; }
.mail-body { overflow: hidden; transition: max-height 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
.mail-body.clamped {
  max-height: 10.85em;
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent);
  mask-image: linear-gradient(to bottom, #000 60%, transparent);
}
button.more { align-self: flex-start; width: auto; padding: 0; text-decoration: none; color: var(--accent-2); font-weight: 600; }
.mail-from { color: var(--muted); font-size: 0.82rem; padding-top: 8px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }

.fields { margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-2); }
.field-item { padding: 11px 14px; border-top: 1px solid var(--line); }
.field-item:first-child { border-top: 0; }
.field-item.attention { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.field-item.attention dd { color: var(--text); font-weight: 500; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent); vertical-align: 1px; white-space: nowrap; }
.tag.warn { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.item.plugin { align-items: flex-start; }
.item .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; flex-shrink: 0; }
.muted.small { font-size: 0.8rem; }
.sideload { margin-top: 18px; }
.sideload summary { cursor: pointer; color: var(--muted); }
.sideload[open] summary { margin-bottom: 8px; }
.field-item dt { color: var(--muted); font-size: 0.8rem; }
.field-item dd { margin: 2px 0 0; overflow-wrap: anywhere; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; font-weight: 600;
}
input.switch {
  appearance: none; -webkit-appearance: none; flex-shrink: 0; width: 50px; height: 30px; padding: 0; border: 0;
  border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background 0.15s;
}
input.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; transition: transform 0.15s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(20px); }
input.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.choice input { width: auto; margin-top: 4px; accent-color: var(--accent); }
.choice small { display: block; color: var(--muted); font-size: 0.85rem; }

.actionbar {
  position: sticky; bottom: 0; margin: 4px -20px -24px; padding: 14px 20px max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--card) 22%); display: flex; flex-direction: column; gap: 6px;
  border-radius: 0 0 var(--radius) var(--radius);
}
.actionbar-row { display: flex; justify-content: center; gap: 18px; }
button.big { padding: 16px; font-size: 1.05rem; }
button.decline { color: var(--muted); text-decoration: none; font-weight: 600; width: auto; }
.fine { color: var(--muted); font-size: 0.8rem; text-align: center; }
.center { text-align: center; }
.muted-strong { color: var(--muted); }
.pw-box input { text-align: center; }

/* ---------- request page: desktop layout ---------- */

.req-grid { display: flex; flex-direction: column; gap: 14px; }
.req-main, .req-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

@media (min-width: 900px) {
  #app { padding-top: 48px; }
  .card.approve { max-width: 1000px; padding: 28px 32px 32px; }
  .card.approve .req-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; align-items: start; }
  .card.approve .req-side {
    position: sticky; top: 24px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--bg-2);
  }
  .card.approve .req-main h1 { font-size: 1.9rem; }
  .card.approve .actionbar { position: static; margin: 0; padding: 0; background: none; border-radius: 0; }
  .card.approve .mail { padding: 20px 22px; }
  .card.approve .mail-body.clamped { max-height: 16em; }
  .card.approve .fine { text-align: left; }
}

/* ---------- motion ---------- */

.rise { animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: var(--d, 0ms); }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.screen-mascot { position: relative; }
.pop .mascot { animation: pop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes pop {
  0% { transform: scale(0.4) rotate(-12deg); opacity: 0; }
  60% { transform: scale(1.08) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
.pop.mood-happy .mascot { animation: pop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both, hop 0.9s ease-in-out 0.7s 2; }
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  35% { transform: translateY(-14px) scaleY(1.04); }
  60% { transform: translateY(0) scaleY(0.94) scaleX(1.05); }
}
.sigh .mascot { animation: pop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both, sigh 1.2s ease-in-out 0.7s both; }
@keyframes sigh {
  0% { transform: none; }
  50% { transform: translateY(6px) scaleY(0.94) scaleX(1.04); }
  100% { transform: translateY(3px) scaleY(0.97); }
}

/* Idle eyes look around now and then, on top of blinking. */
.mascot.mood-idle .mascot-gaze { animation: look 9s ease-in-out infinite; }
@keyframes look {
  0%, 18%, 100% { transform: none; }
  24%, 40% { transform: translateX(-3px); }
  48%, 62% { transform: translateX(3px) translateY(-1px); }
  70% { transform: none; }
}
.mascot.nod { animation: nod 0.6s ease-in-out; }
@keyframes nod {
  0%, 100% { transform: none; }
  30% { transform: translateY(3px) rotate(4deg); }
  65% { transform: translateY(-2px) rotate(-3deg); }
}

.sparks { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
.sparks i {
  position: absolute; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: var(--accent);
  opacity: 0; animation: spark 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) 0.45s both;
}
.sparks i:nth-child(3n) { background: var(--ok); width: 6px; height: 6px; }
.sparks i:nth-child(4n) { background: #f2c14e; }
@keyframes spark {
  0% { opacity: 0; transform: rotate(var(--a)) translateX(10px) scale(0.6); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a)) translateX(var(--r)) scale(1); }
}

button.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 35%, transparent); }
button.is-busy {
  background-image: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.22) 50%, transparent 70%);
  background-size: 250% 100%; animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

.timer.urgent { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

.switch-row { transition: border-color 0.2s, background 0.2s; }
.switch-row:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent) 7%, transparent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
