/* ============================================================
   Voice Tasks — mini app design system
   ============================================================ */

:root {
  color-scheme: light;

  /* surface */
  --lav-100: #eceafd;
  --lav-200: #dedcfa;
  --lav-300: #c9c6f6;
  --lav-400: #b8b4f2;

  /* ink */
  --ink: #171429;
  --ink-2: #3a3552;
  --muted: #6f6a87;
  --faint: #9b96ad;

  /* accents */
  --primary: #4f4ddb;
  --primary-soft: #7d7bf0;
  --noir: #1d1a27;
  --danger: #d8475c;
  --cream: #f6cfa8;
  --ice: #d6ecf8;
  --mint: #cfeddb;

  /* glass */
  --glass: rgba(255, 255, 255, 0.5);
  --glass-strong: rgba(255, 255, 255, 0.74);
  --hairline: rgba(255, 255, 255, 0.55);

  /* elevation */
  --sh-sm: 0 6px 16px rgba(46, 38, 92, 0.1);
  --sh-md: 0 14px 30px rgba(46, 38, 92, 0.14);
  --sh-lg: 0 22px 48px rgba(46, 38, 92, 0.2);

  /* geometry */
  --r-lg: 26px;
  --r-md: 20px;
  --r-sm: 14px;
  --pad: 20px;
  --tabbar-space: 108px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* class-level `display` must never beat the hidden attribute */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--lav-300);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
textarea,
input {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* the textarea carries its own focus treatment */
textarea:focus-visible {
  outline: none;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
}

/* ---------- ambient background ---------- */

.glow {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(78% 46% at 12% 2%, rgba(255, 255, 255, 0.72), transparent 62%),
    radial-gradient(62% 38% at 92% 14%, rgba(255, 238, 214, 0.5), transparent 66%),
    radial-gradient(90% 60% at 50% 108%, rgba(168, 200, 240, 0.55), transparent 70%),
    linear-gradient(168deg, var(--lav-200) 0%, var(--lav-300) 46%, var(--lav-400) 100%);
}

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

.app {
  position: relative;
  isolation: isolate;
  width: min(100%, 440px);
  min-height: 100dvh;
  margin-inline: auto;
  padding:
    calc(14px + env(safe-area-inset-top)) var(--pad)
    calc(var(--tabbar-space) + env(safe-area-inset-bottom));
}

/* lift the real UI above the ambient gradient */
.topbar,
.screen-title,
.screen-sub,
.content {
  position: relative;
  z-index: 1;
}

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  margin-bottom: 18px;
}

.identity {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  margin-right: auto;
}

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(150deg, #ffd36e, #f58aa6 58%, #b48bf4);
  box-shadow: 0 8px 18px rgba(196, 114, 150, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.65);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.hello {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  flex: none;
  gap: 9px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 11px;
  border-radius: 50%;
  background: var(--glass-strong);
  color: var(--ink);
  box-shadow: var(--sh-sm), inset 0 0 0 1px var(--hairline);
  transition: transform 0.22s var(--ease), background 0.22s var(--ease);
}

.icon-btn:active {
  transform: scale(0.9);
  background: #fff;
}

.back-btn {
  display: none;
}

/* back-mode: hide avatar block, show back arrow */
.app.subpage .back-btn {
  display: grid;
}

.app.subpage .identity {
  display: none;
}

.app.subpage .topbar-actions {
  margin-left: auto;
}

/* ---------- headline ---------- */

.screen-title {
  margin: 0 0 4px;
  max-width: 15ch;
  font-size: clamp(30px, 8.6vw, 36px);
  line-height: 1.04;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.screen-title .thin {
  font-weight: 400;
  color: var(--ink-2);
}

.screen-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
}

.screen-sub svg {
  flex: none;
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.content {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

/* enter animation for each view */
.content > * {
  animation: rise 0.46s var(--ease) both;
}

.content > *:nth-child(2) { animation-delay: 0.05s; }
.content > *:nth-child(3) { animation-delay: 0.1s; }
.content > *:nth-child(4) { animation-delay: 0.14s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------- stat grid ---------- */

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.stat {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  padding: 15px 15px 14px;
  border-radius: var(--r-md);
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--hairline), 0 8px 18px rgba(46, 38, 92, 0.07);
  text-align: left;
  transition: transform 0.24s var(--ease), background 0.24s var(--ease);
}

.stat::after {
  content: "";
  position: absolute;
  right: -30px;
  bottom: -46px;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
}

.stat:active {
  transform: scale(0.97);
  background: var(--glass-strong);
}

.stat-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 700;
}

.stat-ico {
  display: grid;
  place-items: center;
  flex: none;
  width: 27px;
  height: 27px;
  padding: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  color: var(--primary);
  box-shadow: 0 3px 8px rgba(46, 38, 92, 0.08);
}

.stat-num {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 26px;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}

.stat-num small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---------- section header ---------- */

.sec {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 -4px;
}

.sec h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sec button {
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 700;
}

.sec button:active {
  opacity: 0.55;
}

/* ---------- filter tabs ---------- */

.filters {
  display: flex;
  gap: 8px;
  margin: -2px -20px 0;
  padding: 2px 20px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filters button {
  flex: none;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--hairline);
  transition: background 0.24s var(--ease), color 0.24s var(--ease), transform 0.2s var(--ease);
}

.filters button:active {
  transform: scale(0.95);
}

.filters button.on {
  background: var(--noir);
  color: #fff;
  box-shadow: 0 8px 18px rgba(29, 26, 39, 0.28);
}

/* ---------- task cards ---------- */

.stack {
  display: grid;
  gap: 12px;
}

/* swipe-to-done: the reveal sits behind, the card slides over it */
.task-row {
  position: relative;
}

.reveal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  border-radius: var(--r-lg);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
}

/* swipe left -> complete */
.reveal.done {
  justify-content: flex-end;
  padding-right: 26px;
  background: linear-gradient(100deg, #46b578, #2f9a5c);
}

/* swipe right -> edit */
.reveal.edit {
  justify-content: flex-start;
  padding-left: 26px;
  background: linear-gradient(260deg, #8d7bf3, #5b53dd);
}

.reveal svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.task {
  position: relative;
  padding: 17px 18px 16px;
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--sh-md);
  touch-action: pan-y;
  transition: transform 0.34s var(--ease), opacity 0.34s var(--ease), box-shadow 0.24s var(--ease);
}

/* while the finger is down there must be no easing, or the card lags behind */
.task-row.dragging .task {
  transition: none;
  box-shadow: var(--sh-lg);
}

.task.done-state {
  background: rgba(255, 255, 255, 0.66);
  box-shadow: var(--sh-sm);
}

/* inset, not flush: a flush bar escapes the card's 26px corner radius */
.task.overdue::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 20px;
  bottom: 20px;
  width: 3px;
  border-radius: 999px;
  background: var(--danger);
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.task-meta svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.task-meta .flag {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(216, 71, 92, 0.1);
  color: var(--danger);
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.task h3 {
  margin: 0 0 5px;
  padding-right: 52px;
  font-size: 19px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.028em;
  overflow-wrap: anywhere;
}

.task.done-state h3 {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: rgba(111, 106, 135, 0.45);
}

.task-note {
  margin: 0 0 15px;
  padding-right: 52px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-right: 52px;
}

/* completed cards have no round button — reclaim the gutter */
.task.done-state h3,
.task.done-state .task-note,
.task.done-state .actions {
  padding-right: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 15px;
  border-radius: 999px;
  background: #f2f1f7;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

.pill svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.pill:active {
  transform: scale(0.94);
}

.pill.noir {
  background: var(--noir);
  color: #fff;
}

.pill.warn {
  background: rgba(216, 71, 92, 0.09);
  color: var(--danger);
}

.pill.static {
  cursor: default;
  background: rgba(29, 26, 39, 0.06);
  color: var(--muted);
}

.pill.static:active {
  transform: none;
}

.go {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 12px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 22px rgba(79, 77, 219, 0.36);
  transition: transform 0.22s var(--ease);
}

.go:active {
  transform: scale(0.88);
}

/* ---------- progress ---------- */

.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day {
  display: grid;
  place-items: center;
  gap: 1px;
  min-height: 58px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.day b {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.day.now {
  background: var(--noir);
  color: rgba(255, 255, 255, 0.66);
  box-shadow: 0 10px 20px rgba(29, 26, 39, 0.28);
}

.day.now b {
  color: #fff;
}

.panel {
  padding: 20px 18px 16px;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 0 0 1px var(--hairline), var(--sh-md);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 6px;
}

.panel-head h2 {
  margin: 0 0 3px;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.panel-head .go {
  position: static;
  flex: none;
  background: var(--noir);
  box-shadow: 0 10px 20px rgba(29, 26, 39, 0.26);
}

.chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 8px;
  height: 186px;
  padding-top: 14px;
}

/* flex, not grid: the track needs a resolvable height for the bar's % */
.col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  height: 100%;
}

.col .track {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
}

.col .bar {
  width: 100%;
  max-width: 30px;
  min-height: 18px;
  border-radius: 999px;
  background: repeating-linear-gradient(
    132deg,
    rgba(51, 45, 78, 0.22) 0 2px,
    rgba(51, 45, 78, 0) 2px 6px
  );
  box-shadow: inset 0 0 0 1px rgba(51, 45, 78, 0.12);
  transform-origin: bottom;
  animation: grow 0.66s var(--ease) both;
}

.col .bar.hot {
  background: linear-gradient(180deg, var(--primary-soft), var(--primary));
  box-shadow: 0 10px 22px rgba(79, 77, 219, 0.3);
}

@keyframes grow {
  from { transform: scaleY(0.05); opacity: 0; }
  to { transform: scaleY(1); opacity: 1; }
}

.col span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.col.now span {
  color: var(--ink);
}

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.tile {
  min-height: 88px;
  padding: 15px 16px;
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
}

.tile b {
  display: block;
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}

.tile span {
  display: block;
  margin-top: 9px;
  color: rgba(23, 20, 41, 0.6);
  font-size: 12.5px;
  font-weight: 700;
}

.tile.cream { background: var(--cream); }
.tile.ice { background: var(--ice); }
.tile.mint { background: var(--mint); }
.tile.paper { background: rgba(255, 255, 255, 0.8); }

/* ---------- profile ---------- */

.hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: var(--r-lg);
  background: linear-gradient(140deg, var(--noir), #322c47);
  color: #fff;
  box-shadow: var(--sh-lg);
}

.hero .avatar {
  width: 52px;
  height: 52px;
  font-size: 15px;
}

.hero h2 {
  margin: 0 0 2px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12.5px;
  font-weight: 600;
}

.list {
  padding: 6px 18px;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: inset 0 0 0 1px var(--hairline), var(--sh-sm);
}

.row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 0;
  border-bottom: 1px solid rgba(23, 20, 41, 0.07);
}

.row:last-child {
  border-bottom: 0;
}

.row-ico {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 9px;
  border-radius: 12px;
  background: rgba(79, 77, 219, 0.1);
  color: var(--primary);
}

.row strong {
  font-size: 14px;
  font-weight: 700;
}

.row em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
}

.row .val {
  margin-left: auto;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

/* ---------- empty / skeleton ---------- */

.empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 38px 24px;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.58);
  box-shadow: inset 0 0 0 1px var(--hairline);
  text-align: center;
}

.empty-ico {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 8px;
  padding: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  color: var(--primary);
  box-shadow: var(--sh-sm);
}

.empty strong {
  font-size: 15px;
  font-weight: 700;
}

.empty span {
  max-width: 26ch;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.skel {
  border-radius: var(--r-lg);
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0.42) 28%, rgba(255, 255, 255, 0.8) 48%, rgba(255, 255, 255, 0.42) 68%)
    0 0 / 280% 100%;
  animation: shimmer 1.5s linear infinite;
}

@keyframes shimmer {
  to { background-position: -280% 0; }
}

/* ---------- tabbar ---------- */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 4;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr 1fr 70px 1fr 1fr;
  align-items: center;
  width: min(calc(100% - 30px), 410px);
  height: 72px;
  padding: 0 8px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow: 0 16px 38px rgba(35, 30, 62, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.tab {
  display: grid;
  justify-items: center;
  gap: 4px;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 700;
  transition: color 0.24s var(--ease);
}

.tab svg {
  width: 22px;
  height: 22px;
  transition: transform 0.28s var(--ease);
}

.tab.on {
  color: var(--primary);
}

.tab.on svg {
  transform: translateY(-2px);
}

.tab:active svg {
  transform: scale(0.88);
}

.fab {
  justify-self: center;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  padding: 14px;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--primary-soft), var(--primary));
  color: #fff;
  box-shadow: 0 14px 28px rgba(79, 77, 219, 0.42);
  transition: transform 0.26s var(--ease);
}

.fab:active {
  transform: scale(0.86) rotate(90deg);
}

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

.scrim {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  align-items: end;
  background: rgba(18, 15, 32, 0.42);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fade 0.26s var(--ease) both;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  width: min(100%, 440px);
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  margin-inline: auto;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  border-radius: 30px 30px 0 0;
  background: #fff;
  box-shadow: 0 -20px 50px rgba(18, 15, 32, 0.3);
  animation: slide 0.4s var(--ease) both;
}

@keyframes slide {
  from { transform: translateY(100%); }
  to { transform: none; }
}

.sheet::-webkit-scrollbar {
  display: none;
}

.sheet-grip {
  display: block;
  width: 44px;
  height: 5px;
  margin: 0 auto 16px;
  border-radius: 999px;
  background: #e2e0ec;
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.sheet-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(79, 77, 219, 0.1);
  color: var(--primary);
}

.sheet-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.sheet-head p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

textarea {
  width: 100%;
  min-height: 104px;
  padding: 15px;
  border: 1.5px solid #eae8f2;
  border-radius: 18px;
  background: #f8f7fc;
  font-size: 15px;
  font-weight: 500;
  resize: none;
  outline: none;
  transition: border-color 0.24s var(--ease), background 0.24s var(--ease);
}

textarea::placeholder {
  color: var(--faint);
}

textarea:focus {
  border-color: var(--primary-soft);
  background: #fff;
}

/* ---------- voice recorder ---------- */

.recorder {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 20px;
  background: #f8f7fc;
  box-shadow: inset 0 0 0 1.5px #eae8f2;
  transition: background 0.26s var(--ease), box-shadow 0.26s var(--ease);
}

.recorder[data-state="rec"],
.recorder[data-state="locked"] {
  background: rgba(216, 71, 92, 0.07);
  box-shadow: inset 0 0 0 1.5px rgba(216, 71, 92, 0.3);
}

.recorder[data-state="cancel"] {
  background: rgba(216, 71, 92, 0.14);
  box-shadow: inset 0 0 0 1.5px var(--danger);
}

.recorder[data-state="busy"] {
  background: rgba(79, 77, 219, 0.06);
  box-shadow: inset 0 0 0 1.5px rgba(79, 77, 219, 0.24);
}

.recorder[data-state="err"] {
  background: rgba(216, 71, 92, 0.07);
  box-shadow: inset 0 0 0 1.5px rgba(216, 71, 92, 0.22);
}

/* ---- the button ---- */

.rec-btn {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--primary-soft), var(--primary));
  color: #fff;
  box-shadow: 0 8px 18px rgba(79, 77, 219, 0.34);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.22s var(--ease), background 0.26s var(--ease), box-shadow 0.26s var(--ease);
}

.rec-btn svg {
  grid-area: 1 / 1;
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.rec-stop {
  display: none;
}

.recorder[data-state="rec"] .rec-btn,
.recorder[data-state="locked"] .rec-btn,
.recorder[data-state="cancel"] .rec-btn {
  background: linear-gradient(150deg, #ea6275, var(--danger));
  box-shadow: 0 10px 24px rgba(216, 71, 92, 0.42);
}

/* holding swells the button; locked swaps in the stop glyph */
.recorder[data-state="rec"] .rec-btn,
.recorder[data-state="cancel"] .rec-btn {
  transform: scale(1.16);
}

.recorder[data-state="locked"] .rec-mic {
  display: none;
}

.recorder[data-state="locked"] .rec-stop {
  display: block;
}

/* ---- rings around the button ---- */

.rec-ring,
.rec-halo {
  position: absolute;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.rec-ring {
  inset: 0;
}

.rec-halo {
  inset: -6px;
}

/* capturing: a soft heartbeat */
.recorder[data-state="rec"] .rec-ring,
.recorder[data-state="locked"] .rec-ring,
.recorder[data-state="cancel"] .rec-ring {
  opacity: 1;
  box-shadow: 0 0 0 0 rgba(216, 71, 92, 0.5);
  animation: halo 1.6s ease-out infinite;
}

@keyframes halo {
  to { box-shadow: 0 0 0 18px rgba(216, 71, 92, 0); }
}

/* transcribing: a sweep around the rim plus expanding rings */
.recorder[data-state="busy"] .rec-ring {
  opacity: 1;
  inset: -5px;
  background: conic-gradient(
    from 0deg,
    rgba(79, 77, 219, 0) 0 42%,
    var(--primary-soft) 74%,
    var(--primary) 96%,
    rgba(79, 77, 219, 0) 100%
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  animation: spin 0.9s linear infinite;
}

.recorder[data-state="busy"] .rec-halo {
  opacity: 1;
}

.recorder[data-state="busy"] .rec-halo::before,
.recorder[data-state="busy"] .rec-halo::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(79, 77, 219, 0.45);
  animation: ripple 1.8s var(--ease) infinite;
}

.recorder[data-state="busy"] .rec-halo::after {
  animation-delay: 0.9s;
}

@keyframes ripple {
  from { transform: scale(0.82); opacity: 0.7; }
  to { transform: scale(1.5); opacity: 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- swipe-up lock pill ---- */

.rec-lock {
  --lift: 0;

  position: absolute;
  left: 14px;
  bottom: calc(100% - 6px);
  z-index: 2;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 46px;
  padding: 9px 0 7px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  box-shadow: var(--sh-md);
  transform: translateY(calc(6px - var(--lift) * 14px));
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}

.recorder[data-state="rec"] .rec-lock {
  display: flex;
  /* fade only — `rise` would overwrite the --lift transform with `none` */
  animation: fade 0.26s var(--ease) both;
}

.rec-lock-ico {
  width: 17px;
  height: 17px;
}

.rec-lock-chev {
  width: 15px;
  height: 15px;
  transform: rotate(90deg);
  opacity: calc(0.35 + var(--lift) * 0.65);
  animation: nudge 1.4s ease-in-out infinite;
}

@keyframes nudge {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -3px; }
}

/* armed: one more millimetre and it latches */
.rec-lock.armed {
  background: var(--noir);
  color: #fff;
}

/* ---- copy + meter ---- */

.rec-copy {
  flex: 1;
  min-width: 0;
}

.rec-copy strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rec-copy span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.recorder[data-state="err"] .rec-copy span,
.recorder[data-state="cancel"] .rec-copy span {
  color: var(--danger);
  font-weight: 600;
}

.rec-wave {
  display: none;
  align-items: center;
  gap: 3px;
  flex: none;
  height: 26px;
}

.recorder[data-state="rec"] .rec-wave,
.recorder[data-state="locked"] .rec-wave {
  display: flex;
}

.rec-wave i {
  width: 3px;
  height: 100%;
  border-radius: 999px;
  background: var(--danger);
  transform: scaleY(0.18);
  transform-origin: center;
  transition: transform 0.09s linear;
}

/* no AnalyserNode? fall back to a canned equaliser */
.rec-wave.faux i {
  transition: none;
  animation: bounce 0.9s ease-in-out infinite;
}

.rec-wave.faux i:nth-child(2) { animation-delay: 0.15s; }
.rec-wave.faux i:nth-child(3) { animation-delay: 0.3s; }
.rec-wave.faux i:nth-child(4) { animation-delay: 0.45s; }
.rec-wave.faux i:nth-child(5) { animation-delay: 0.6s; }

@keyframes bounce {
  0%, 100% { transform: scaleY(0.2); }
  50% { transform: scaleY(1); }
}

/* ---------- when: date + time picker ---------- */

.when {
  margin-top: 12px;
  padding: 14px;
  border-radius: 20px;
  background: #f8f7fc;
  box-shadow: inset 0 0 0 1.5px #eae8f2;
}

.when-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.when-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
}

.when-label svg {
  flex: none;
  width: 15px;
  height: 15px;
  color: var(--primary);
}

.when-clear {
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}

.when-clear:active {
  opacity: 0.55;
}

.when-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 8px;
}

.when-field {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border-radius: 14px;
  background: #fff;
  box-shadow: inset 0 0 0 1.5px #eae8f2;
  transition: box-shadow 0.22s var(--ease), transform 0.18s var(--ease);
}

.when-field svg {
  flex: none;
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.when-field span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.when-field.empty span {
  color: var(--faint);
  font-weight: 500;
}

.when-field[aria-expanded="true"] {
  box-shadow: inset 0 0 0 1.5px var(--primary);
}

.when-field[aria-expanded="true"] svg {
  color: var(--primary);
}

.when-field:active {
  transform: scale(0.98);
}

/* ---------- picker panels ---------- */

.picker {
  margin-top: 10px;
  padding: 12px;
  border-radius: 16px;
  background: #fff;
  box-shadow: inset 0 0 0 1.5px #eae8f2;
  animation: unfold 0.28s var(--ease) both;
}

@keyframes unfold {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.cal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.cal-top strong {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.cal-nav {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 7px;
  border-radius: 50%;
  background: #f2f1f7;
  color: var(--ink-2);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

.cal-nav.next svg {
  transform: rotate(180deg);
}

.cal-nav:active {
  transform: scale(0.88);
  background: #e8e6f2;
}

.cal-dow,
.cal-grid {
  display: grid;
  /* minmax(0,...): an aspect-ratio cell's auto minimum would blow out `1fr` */
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}

.cal-dow {
  margin-bottom: 4px;
}

.cal-dow span {
  padding: 4px 0;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
}

.cal-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}

.cal-cell:active {
  transform: scale(0.88);
}

.cal-cell.today {
  color: var(--primary);
  font-weight: 800;
  box-shadow: inset 0 0 0 1.5px rgba(79, 77, 219, 0.35);
}

.cal-cell.sel {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(79, 77, 219, 0.34);
}

/* ---------- time wheels ---------- */

.wheels {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
}

.wheels::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 44px;
  transform: translateY(-50%);
  border-radius: 13px;
  background: rgba(79, 77, 219, 0.06);
  pointer-events: none;
}

.wheel {
  --wheel-h: 150px;
  --item-h: 40px;

  flex: 1;
  max-width: 110px;
  height: var(--wheel-h);
  overflow-y: auto;
  scrollbar-width: none;
  scroll-snap-type: y mandatory;
  display: grid;
  gap: 3px;
  align-content: start;
  /* let the first and last values reach the centre line, like a real wheel */
  padding: calc((var(--wheel-h) - var(--item-h)) / 2) 2px;
}

.wheel::-webkit-scrollbar {
  display: none;
}

.wheel-sep {
  align-self: center;
  color: var(--faint);
  font-size: 18px;
  font-weight: 800;
}

.wheel-item {
  display: grid;
  place-items: center;
  height: var(--item-h);
  scroll-snap-align: center;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.wheel-item.sel {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.wheel-done {
  width: 100%;
  height: 42px;
  margin-top: 10px;
  border-radius: 13px;
  background: var(--noir);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  transition: transform 0.2s var(--ease);
}

.wheel-done:active {
  transform: scale(0.97);
}

.when .quick-row {
  margin: 10px -14px 0;
  padding: 0 14px;
}

.quick-row button.on {
  background: var(--noir);
  color: #fff;
}

.when-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.quick-row {
  display: flex;
  gap: 8px;
  margin: 12px -20px;
  padding: 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

.quick-row::-webkit-scrollbar {
  display: none;
}

.quick-row button {
  flex: none;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: #f2f1f7;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 700;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

.quick-row button:active {
  transform: scale(0.94);
  background: #e8e6f2;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 10px;
}

.btn {
  height: 52px;
  border-radius: 18px;
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.55;
  pointer-events: none;
}

.btn.ghost {
  background: #f2f1f7;
  color: var(--ink-2);
}

.btn.solid {
  background: linear-gradient(150deg, var(--primary-soft), var(--primary));
  color: #fff;
  box-shadow: 0 12px 24px rgba(79, 77, 219, 0.34);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-space) + env(safe-area-inset-bottom));
  z-index: 9;
  transform: translateX(-50%);
  max-width: calc(100% - 48px);
  padding: 13px 20px;
  border-radius: 999px;
  background: var(--noir);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--sh-lg);
  animation: pop 0.34s var(--ease) both;
}

.toast.bad {
  background: var(--danger);
}

@keyframes pop {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- desktop frame ---------- */

/* Short viewports — landscape phones, or an open Telegram keyboard.
   The display headline and the card rhythm both have to give way. */
@media (max-height: 620px) {
  :root {
    --tabbar-space: 90px;
  }

  .topbar {
    min-height: 38px;
    margin-bottom: 12px;
  }

  .avatar,
  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .icon-btn {
    padding: 9px;
  }

  .screen-title {
    max-width: none;
    font-size: clamp(21px, 6vw, 26px);
  }

  .content {
    margin-top: 14px;
    gap: 12px;
  }

  .stat {
    min-height: 88px;
  }

  .stat-num {
    margin-top: 12px;
    font-size: 25px;
  }

  .tabbar {
    height: 62px;
  }

  .fab {
    width: 46px;
    height: 46px;
    padding: 12px;
  }

  .chart {
    height: 132px;
  }
}

/* On a wide screen the shell reads as a phone: rounded, lifted, centred.
   The tabbar stays viewport-fixed — the frame is full-height, so it lands
   exactly on its bottom edge. */
@media (min-width: 540px) and (min-height: 700px) {
  body {
    padding: 24px 0;
    background: #b6c6dd;
  }

  .app {
    min-height: calc(100dvh - 48px);
    border-radius: 42px;
    box-shadow: 0 40px 90px rgba(35, 30, 62, 0.32), inset 0 0 0 1px rgba(255, 255, 255, 0.45);
  }

  .glow {
    border-radius: inherit;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
