/* Brand theme, same as the bot's welcome picture: violet night gradient, glass cards,
   white pill buttons. Fixed on purpose: it does not follow the Telegram theme. */
:root {
  color-scheme: dark;
  --page: #1e1b4b;
  --bg: rgba(255, 255, 255, .08);       /* fields and inner blocks */
  --card: rgba(255, 255, 255, .09);
  --card-border: rgba(255, 255, 255, .13);
  --text: #ffffff;
  --muted: #c4b5fd;
  --accent: #ffffff;
  --accent-text: #4c1d95;
  --danger: #fb7185;
  --line: rgba(255, 255, 255, .14);
  --ok: #4ade80;
  --radius: 20px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(167, 139, 250, .35), transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(236, 72, 153, .22), transparent 45%),
    linear-gradient(160deg, #1e1b4b 0%, #312e81 55%, #4c1d95 100%) fixed;
  background-color: var(--page);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

h1 { font-size: 30px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; margin: 6px 0 8px; }
h2 { font-size: 17px; font-weight: 700; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.lead { margin: 0 0 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.ritual-head { display: flex; gap: 12px; align-items: center; }
.ritual-emoji { font-size: 30px; line-height: 1; }
.ritual-head > div { flex: 1; min-width: 0; }
.ritual-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; gap: 8px; margin-top: 12px; }
.row > * { flex: 1; }

button {
  font: inherit;
  border: 0;
  border-radius: 99px;
  padding: 11px 16px;
  cursor: pointer;
  background: rgba(255, 255, 255, .12);
  color: var(--accent);
  font-weight: 700;
}
button.primary { background: var(--accent); color: var(--accent-text); font-weight: 800;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .28); }
button.danger { background: transparent; color: var(--danger); }
button.ghost { background: transparent; padding: 6px 8px; }
button.back { margin: -6px 0 6px -8px; font-size: 16px; }
button:disabled { opacity: .5; }
button.wide { width: 100%; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.segmented { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--card-border);
  padding: 6px; border-radius: 99px; margin-bottom: 12px; }
.segmented button { flex: 1; background: transparent; color: var(--muted); }
.segmented button.on { background: var(--accent); color: var(--accent-text); }
.item-row > span { flex: 0 0 auto; }

.feedback-link { margin-top: 18px; font-weight: 600; }
.feedback-banner { display: flex; gap: 12px; align-items: center;
  background: linear-gradient(135deg, rgba(167, 139, 250, .28), rgba(236, 72, 153, .18)); }
.feedback-banner > div { flex: 1; }
.feedback-banner .small { margin-top: 4px; color: var(--muted); }
.feedback-banner button { flex: 0 0 auto; padding: 10px 12px; font-size: 14px; }

.prio { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; vertical-align: middle; }
.prio-1 { background: #fff3c4; color: #8a6400; }
.prio-2 { background: #ffe0df; color: #b42318; }
.prio-card-1 { box-shadow: inset 4px 0 0 #f5c542; }
.prio-card-2 { box-shadow: inset 4px 0 0 #e5484d; }
.day-title { font-size: 15px; color: var(--muted); margin: 18px 4px 8px; text-transform: none; }
.intro { margin: 0 0 18px; padding: 16px; border-radius: var(--radius); background: var(--card);
  border: 1px solid var(--card-border); line-height: 1.45; }
button.add-time { flex: 0 0 auto; padding: 7px 10px; font-size: 13px; }
.small-btn { font-size: 13px; padding: 6px 0 0; margin-top: 6px; }
.confirm { margin-top: 10px; padding: 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 10%, transparent); }
.confirm > span { display: block; font-weight: 600; margin-bottom: 8px; }
.confirm .row { margin-top: 0; }
.confirm .row button { white-space: nowrap; }
/* The confirm box replaces a button inside a .row: give it a full line of its own. */
.row { flex-wrap: wrap; }
.row > .confirm { flex: 1 0 100%; margin-top: 0; }
button.danger-solid { background: var(--danger); color: #fff; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 26px; }
.stat span { font-size: 12px; color: var(--muted); }
.promo-row { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); }
.promo-row span:last-child { margin-left: auto; }
.section-title { margin: 18px 4px 8px; }
.done-card { opacity: .55; }

.big-btn { padding: 18px; font-size: 18px; margin-top: 20px; }
.photo-full { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.9);
  display: grid; place-items: center; padding: 12px; }
.photo-full img { max-width: 100%; max-height: 100%; border-radius: 10px; }
.photos img { cursor: zoom-in; }

.rec-btn.recording { background: var(--danger); color: #fff; animation: rec-pulse 1.2s ease-in-out infinite; }
@keyframes rec-pulse { 50% { opacity: .75; } }

.time-field { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.time-field select { width: auto; min-width: 62px; padding: 9px 6px; text-align: center;
  font-variant-numeric: tabular-nums; font-size: 16px; }
.time-field select:disabled { opacity: .5; }
.time-field b { color: var(--muted); }

.icon-btn { flex: 0 0 auto; display: flex; align-items: center; gap: 2px; padding: 6px 6px 6px 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
.icon-face { font-size: 22px; line-height: 1; }
.icon-caret { font-size: 11px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 4px;
  padding: 8px; margin: 0 0 10px; border-radius: 12px; background: var(--bg); }
.icon-grid[hidden] { display: none; }
.icon-grid button { font-size: 22px; padding: 6px 0; background: transparent; }
.icon-grid button.none { font-size: 12px; color: var(--muted); }

.bar { height: 8px; border-radius: 99px; background: var(--bg); overflow: hidden; margin: 6px 0; }
.bar > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #4ade80, #22c55e); }
.player-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.player-head b { font-size: 17px; }
.player .bar > div { background: linear-gradient(90deg, #ffd166, #f59e0b); }
.habit { margin-top: 10px; }
.habit .small { color: var(--muted); }
.habit.formed .small { color: var(--ok); font-weight: 700; }

.week-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.week-tabs button { padding: 8px 12px; font-size: 14px; background: var(--bg); color: var(--muted); }
.week-tabs button.on { background: var(--accent); color: var(--accent-text); }
.week-tabs button.add-week { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.current-week { margin-bottom: 8px; }

.week-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.week-row:first-child { border-top: 0; }
.week-row > b { flex: 0 0 30px; }
.week-times { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.week-time { display: flex; align-items: center; }
.week-time input { width: 104px; padding: 8px; }
.week-time button { padding: 4px 6px; }

.thought-text { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; }
.thought audio { width: 100%; margin-top: 8px; }
.tabs button { padding: 11px 4px; font-size: 13px; white-space: nowrap; }

input[type=text], input[type=time], input[type=date], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(255, 255, 255, .7); outline-offset: -1px; }
select option { background: #312e81; color: #fff; }
::placeholder { color: rgba(221, 214, 254, .6); }

.emojis, .days { display: flex; flex-wrap: wrap; gap: 6px; }
.days { flex-wrap: nowrap; gap: 4px; }
.emojis button { font-size: 22px; padding: 6px 8px; background: var(--bg); }
.emojis button.on { outline: 2px solid var(--accent); }
.days button { flex: 1; min-width: 0; padding: 9px 0; background: var(--bg); color: var(--muted); }
.days button.on { background: var(--accent); color: var(--accent-text); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.switch input { width: 44px; height: 24px; accent-color: var(--accent); }

.item-row { display: flex; gap: 6px; margin-bottom: 8px; align-items: center; }
.item-row input { flex: 1; }

.log-items { list-style: none; padding: 0; margin: 10px 0 0; }
.log-items li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px solid var(--line); }
.log-items time { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.access { margin: -8px 0 16px; color: var(--ok); font-weight: 600; }
button.renew { padding: 0; font-size: inherit; color: #fde68a; text-decoration: underline; }
.plan-btn { margin-top: 10px; }
.offer { margin-top: 14px; }
.offer a { color: #fde68a; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.item-photos { margin: 0 0 8px 28px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--bg); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.open { background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 6px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(30, 27, 75, .82);
  border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  z-index: 5;
}
.tabs button { flex: 1; background: transparent; color: var(--muted); }
.tabs button.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.tabs[hidden] { display: none; }

.toast {
  position: fixed;
  left: 50%; bottom: 84px;
  transform: translateX(-50%);
  background: #fff;
  color: var(--accent-text);
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 99px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  z-index: 20;
  max-width: calc(100% - 32px);
  font-size: 14px;
}
