/* The Nocturne design tokens, ported from the Avalonia app's App.axaml so the
   installed web app and the native Android app read as the same product.
   Where App.axaml pre-computes a colour-mix against the ground, the same
   pre-computed value is used here rather than re-deriving it. */

:root {
  color-scheme: dark;

  --bg: #161826;
  --surface: #232532;
  --text: #E9E9ED;
  --accent: #9184D9;
  --accent-dim: rgba(145, 132, 217, 0.20);
  --accent-wash: rgba(145, 132, 217, 0.12);

  --n100: #F3F5FE;
  --n200: #E4E7F5;
  --n300: #CFD3E5;
  --n500: #9397AB;
  --n600: #75798C;
  --n700: #595D6C;
  --n800: #3F424D;
  --n900: #292B31;

  --accent200: #E7E5FE;
  --accent700: #5D5294;
  --accent800: #423A6A;
  --accent900: #2B2741;

  --text-soft: #AEAFB6;
  --text-muted: #8A8B93;
  --text-dim: #757680;

  --danger: #E2657A;
  --danger-wash: rgba(226, 101, 122, 0.15);
  --scrim: rgba(10, 11, 18, 0.72);

  /* The notch and the home indicator. Zero everywhere that has neither. */
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Rubber-banding the whole document looks broken in a standalone web app. */
  overscroll-behavior: none;
}

body {
  /* Nothing outside a scroll region may scroll: the shell is a fixed frame. */
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  /* Kills the double-tap-to-zoom delay on iOS. */
  touch-action: manipulation;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

.hidden { display: none !important; }

/* ---- type scale ---------------------------------------------------------- */

.display { font-size: 42px; font-weight: 500; line-height: 44px; }
.h2 { font-size: 30px; font-weight: 500; line-height: 34px; margin: 0; }
.h3 { font-size: 20px; font-weight: 500; margin: 0; }

.kicker {
  font-size: 11px;
  letter-spacing: 1.1px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin: 0;
}
.kicker.accent { color: var(--accent); }

.lead { font-size: 15px; line-height: 23px; color: var(--text-muted); margin: 0; }
.caption { font-size: 13.5px; color: var(--text-soft); margin: 0; }
.meta { font-size: 11.5px; color: var(--text-dim); margin: 0; }
.muted { color: var(--text-muted); }

/* ---- buttons ------------------------------------------------------------- */

.btn-primary { color: var(--accent); border-color: var(--accent); }
.btn-primary:active:not(:disabled) { background: var(--accent-dim); }

.btn-secondary { border-color: rgba(233, 233, 237, 0.16); }
.btn-secondary:active:not(:disabled) { background: rgba(233, 233, 237, 0.14); }

.btn-quiet { color: var(--text-dim); padding: 3px 4px; }
.btn-ghost { color: var(--accent); padding: 3px 4px; }
.btn-danger { color: var(--danger); border-color: var(--danger); }

.btn-block { display: block; width: 100%; min-height: 48px; font-size: 15px; }

.btn-icon {
  width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---- surfaces ------------------------------------------------------------ */

.panel {
  background: var(--surface);
  border: 1px solid var(--n800);
  border-radius: 8px;
}
.outline { border: 1px solid var(--n800); border-radius: 8px; }
.rule { height: 1px; background: var(--n800); border: 0; margin: 0; }

.tag {
  display: inline-block;
  background: var(--n800);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--n200);
}

.error-box {
  background: var(--danger-wash);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  line-height: 19px;
}

.notice-box {
  background: var(--accent900);
  border: 1px solid var(--accent800);
  border-radius: 8px;
  padding: 12px 14px;
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--n800);
  color: var(--n200);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  flex: none;
}

/* ---- inputs -------------------------------------------------------------- */

input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid rgba(233, 233, 237, 0.16);
  font-size: 16px; /* Anything under 16px makes iOS Safari zoom on focus. */
}
input:focus { outline: none; border-color: var(--accent); }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 11px;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

input[type="range"] {
  width: 100%;
  margin: 10px 0 6px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  touch-action: pan-y; /* let a vertical drag still scroll the sheet */
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px; background: var(--n800);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px; margin-top: -9.5px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
input[type="range"]::-moz-range-track {
  height: 3px; border-radius: 2px; background: var(--n800);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}

.check {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; cursor: pointer;
}
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

/* ---- shell --------------------------------------------------------------- */

#screens { height: 100%; }

.screen { display: none; height: 100%; }
.screen.on { display: block; }

/* A centred column for the signed-out screens. */
.centered {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--top) + 40px) 22px calc(var(--bottom) + 40px);
}
.centered .inner { max-width: 26rem; margin: 0 auto; }

.shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.shell-header {
  display: flex; align-items: center; gap: 12px;
  padding: calc(var(--top) + 14px) 20px 10px;
}
.shell-header h1 { flex: 1; font-size: 19px; font-weight: 500; margin: 0; }

.bell { position: relative; }
.bell .dot {
  position: absolute; top: -2px; right: -2px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
}

/* Grid children refuse to shrink below their content unless told to, which
   would let the tab pages push the tab bar off the bottom of the screen. */
.shell > .tabs { min-height: 0; }

.tabpage {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.tabpage > .pad { padding: 8px 20px 28px; }

.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--n800);
  padding: 6px 8px calc(var(--bottom) + 10px);
  background: var(--bg);
}
.tabbar button {
  border: 0; border-radius: 0; padding: 8px 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--n600);
  font-size: 10px; font-weight: 500;
}
.tabbar button.on { color: var(--accent); }
.tabbar svg { width: 21px; height: 21px; }

/* ---- home ---------------------------------------------------------------- */

.slab {
  position: relative;
  display: block;
  width: 100%;
  height: 168px;
  padding: 22px;
  border-radius: 14px;
  border: 1px solid var(--n700);
  overflow: hidden;
  text-align: left;
  margin-bottom: 12px;
  /* The press must not turn into a text selection or a callout on iOS. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.slab.fart {
  background: radial-gradient(120% 120% at 88% 8%, #2B2E3F 0%, #1C1E2C 62%, #1C1E2C 100%);
}
.slab.poop {
  border-color: var(--accent700);
  background: radial-gradient(120% 120% at 88% 8%, #353B80 0%, #262A60 45%, #1D2047 100%);
}

/* The fill that climbs while the slab is held. Reaching the top means the
   hold lasted long enough and the detail sheet opens. */
.slab .rise {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0;
  background: var(--accent-dim);
  pointer-events: none;
}
.slab.holding .rise {
  height: 100%;
  transition: height 480ms linear;
}

.slab .body {
  position: relative;
  height: 100%;
  display: flex; flex-direction: column;
}
.slab .glyph { width: 30px; height: 30px; flex: none; }
/* The glyph sits top left and the label pair sits on the floor, whatever the
   slab's height ends up being. */
.slab .name { margin-top: auto; font-size: 30px; font-weight: 500; line-height: 32px; }
.slab .hint { display: flex; align-items: center; gap: 7px; margin-top: 7px; }
.slab .hint i { display: block; width: 14px; height: 1px; background: var(--accent); }
.slab.poop .hint i { background: var(--accent200); }

.dots { display: flex; align-items: center; }
.dots .avatar {
  width: 26px; height: 26px; font-size: 10px;
  margin-right: -7px;
  border: 2px solid var(--surface);
}

/* ---- lists --------------------------------------------------------------- */

.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
}
.row + .row { border-top: 1px solid var(--n800); }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-size: 14.5px; }
.row .sub { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

.event {
  width: 100%;
  text-align: left;
  border: 0; border-radius: 0;
  padding: 13px 0;
  display: flex; align-items: center; gap: 12px;
}
.event + .event { border-top: 1px solid var(--n800); }
.event .mark {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--n700);
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.event.is-poop .mark { border-color: var(--accent700); }
.event .mark svg { width: 17px; height: 17px; }
.event .clap {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-dim);
  flex: none;
}
.event .clap.on { color: var(--accent); }
.event .clap svg { width: 15px; height: 15px; }

.empty {
  text-align: center;
  padding: 34px 10px;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 20px;
}

/* ---- sheet / overlay ----------------------------------------------------- */

.overlay {
  position: fixed; inset: 0;
  background: var(--scrim);
  display: flex; align-items: flex-end;
  z-index: 20;
}

.sheet {
  width: 100%;
  max-height: 88%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--surface);
  border-top: 1px solid var(--n700);
  border-radius: 14px 14px 0 0;
  padding: 12px 22px calc(var(--bottom) + 28px);
}
.sheet .grab {
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--n700);
  margin: 0 auto 16px;
}
.sheet .group { margin-bottom: 20px; }
.sheet .group .top {
  display: flex; align-items: baseline; justify-content: space-between;
}
.sheet .group .value { font-size: 15px; font-weight: 500; color: var(--accent200); }

.seg {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--n800);
  border-radius: 8px;
}
.seg button {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 0;
  font-weight: 400;
}
.seg button.on { border-color: var(--accent); color: var(--accent); }

/* The applaud screen, shown over the shell when a notification is opened. */
.applaud-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 30;
  overflow-y: auto;
  padding: calc(var(--top) + 44px) 22px calc(var(--bottom) + 44px);
  display: flex; flex-direction: column;
}
.applaud-screen .tags { margin: 0 0 auto; }
.applaud-screen .tags .tag { margin: 0 6px 6px 0; }

.clap-target {
  width: 180px; height: 180px;
  border-radius: 50%;
  margin: 18px auto 26px;
  border: 1px solid var(--n700);
  color: var(--n300);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
}
.clap-target svg { width: 44px; height: 44px; }
.clap-target span { font-size: 17px; font-weight: 500; }
.clap-target.clapped {
  border-color: var(--accent);
  color: var(--accent200);
  background: var(--accent-dim);
}

/* ---- banners and toast --------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bottom) + 96px);
  z-index: 40;
  background: rgba(35, 37, 50, 0.96);
  border: 1px solid var(--n700);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  pointer-events: none;
  max-width: calc(100% - 40px);
  text-align: center;
}

/* "Add to Home Screen" instructions. Only ever shown over the shell, so it sits
   above the tab bar rather than on top of it — being unable to change tabs
   until you dismiss a hint would be worse than the hint. */
.prompt {
  position: fixed;
  left: 10px; right: 10px;
  bottom: calc(var(--bottom) + 82px);
  z-index: 25;
  background: rgba(35, 37, 50, 0.98);
  border: 1px solid var(--n700);
  border-radius: 14px;
  padding: 14px 16px;
}
.prompt h4 { margin: 0 0 4px; font-size: 14.5px; font-weight: 500; }
.prompt p { margin: 0; font-size: 12.5px; line-height: 19px; color: var(--text-muted); }
.prompt ol { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; line-height: 21px; color: var(--text-muted); }
.prompt .actions { display: flex; gap: 8px; margin-top: 12px; }
.prompt .actions button { flex: 1; }
.prompt .share {
  display: inline-block;
  vertical-align: -3px;
  width: 15px; height: 15px;
  color: var(--accent);
}

.spinner {
  width: 100%; height: 2px;
  border-radius: 1px;
  background: var(--n800);
  overflow: hidden;
}
.spinner i {
  display: block; height: 100%; width: 40%;
  background: var(--accent);
  animation: slide 1.1s ease-in-out infinite;
}
@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner i { animation: none; width: 100%; }
  .slab.holding .rise { transition: none; }
}
