:root {
  --bg: var(--tg-theme-secondary-bg-color, #f4f3f8);
  --surface: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #17151d);
  --muted: var(--tg-theme-hint-color, #85818e);
  --accent: var(--tg-theme-button-color, #7868e6);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--muted) 18%, transparent);
  --shadow: 0 12px 32px rgba(35, 27, 70, .08);
  --blue: #4f7cff; --green: #2fc98f; --yellow: #f5b940; --red: #f26666;
  --purple: #9368e6; --orange: #f28b45; --white: #d7d7dd; --black: #33333a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app { width: min(100%, 680px); min-height: 100vh; margin: auto; padding: 20px 16px calc(94px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; margin: 8px 4px 18px; }
.topbar h1 { font-size: 28px; letter-spacing: -.8px; margin: 2px 0 0; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: 1.5px; }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 16px; color: #fff; font-weight: 800; background: linear-gradient(145deg, #8e7bf4, #6250cd); box-shadow: 0 8px 18px rgba(97, 80, 205, .25); }

.view { display: none; animation: rise .22s ease both; }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } }

.calendar-card, .settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.calendar-card { padding: 16px 12px 14px; }
.month-toolbar { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; margin-bottom: 10px; }
.icon-button, .month-title { border: 0; background: transparent; }
.icon-button { height: 38px; font-size: 31px; color: var(--muted); border-radius: 12px; }
.icon-button:active { background: var(--bg); }
.month-title { font-size: 18px; font-weight: 750; text-transform: capitalize; }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekdays span { color: var(--muted); font-size: 9px; font-weight: 800; text-align: center; padding: 8px 0; }
.day { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 1; min-width: 0; border: 0; border-radius: 14px; background: transparent; font-size: 14px; }
.day.outside { color: color-mix(in srgb, var(--muted) 45%, transparent); }
.day.today::after { content: ""; position: absolute; inset: 5px; border: 1.5px solid color-mix(in srgb, var(--accent) 65%, transparent); border-radius: 12px; }
.day.selected { color: var(--accent-text); font-weight: 800; background: var(--accent); box-shadow: 0 7px 15px color-mix(in srgb, var(--accent) 30%, transparent); }
.dots { position: absolute; bottom: 4px; left: 50%; display: flex; gap: 2px; transform: translateX(-50%); z-index: 2; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--dot); }
.day.selected .dot { outline: 1px solid rgba(255,255,255,.7); }

.agenda-header { display: flex; align-items: end; justify-content: space-between; margin: 24px 4px 12px; }
.agenda-header h2, .section-heading h2 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.4px; }
.add-button { border: 0; border-radius: 13px; padding: 9px 12px; color: var(--accent); font-weight: 700; background: color-mix(in srgb, var(--accent) 11%, transparent); }
.events-list { display: grid; gap: 10px; }
.event-card { display: grid; grid-template-columns: 5px 62px 1fr auto; align-items: center; gap: 12px; padding: 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 5px 18px rgba(35,27,70,.045); }
.event-stripe { align-self: stretch; border-radius: 8px; background: var(--event-color); }
.event-time { font-size: 17px; font-weight: 800; }
.event-info { min-width: 0; }
.event-info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-info small { display: block; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delete-event { width: 34px; height: 34px; border: 0; border-radius: 11px; color: var(--muted); background: var(--bg); }
.empty { padding: 30px 20px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 18px; }

.section-heading { margin: 8px 4px 20px; }
.section-heading p { color: var(--muted); line-height: 1.45; margin: 9px 0 0; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.action-card { display: flex; align-items: center; gap: 10px; min-height: 82px; padding: 12px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.action-card b, .action-card small { display: block; }
.action-card small { color: var(--muted); font-size: 10px; margin-top: 3px; }
.action-icon { display: grid; place-items: center; flex: 0 0 38px; height: 38px; border-radius: 13px; font-size: 21px; font-weight: 400; }
.violet { color: #7564d8; background: #eeeafe; }.mint { color: #15956d; background: #e1f7ee; }
.shared-list { display: grid; gap: 12px; }
.shared-card { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }
.shared-title { display: flex; justify-content: space-between; align-items: center; }
.share-code { padding: 5px 8px; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 9px; font-size: 12px; font-weight: 800; letter-spacing: .8px; }
.members { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.member { padding: 6px 9px; border-radius: 10px; background: var(--bg); font-size: 12px; }

.settings-card { padding: 18px; margin-bottom: 12px; }
.settings-card label, form label, fieldset legend { display: block; color: var(--muted); font-size: 11px; font-weight: 750; margin: 0 0 7px; }
input, select { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 14px; padding: 0 13px; background: var(--bg); outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.settings-card select { margin-bottom: 16px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.primary { border: 0; border-radius: 14px; color: var(--accent-text); background: var(--accent); font-weight: 750; }
.compact { padding: 0 14px; }
.full { width: 100%; min-height: 50px; margin-top: 8px; }
.hint { color: var(--muted); font-size: 12px; margin: 14px 0 0; }.hint code { color: var(--text); }
.about { display: flex; gap: 12px; align-items: center; }.about p { color: var(--muted); font-size: 12px; line-height: 1.4; margin: 4px 0 0; }
.logo-small, .logo-mark { display: grid; place-items: center; color: #fff; font-weight: 850; background: linear-gradient(145deg, #8e7bf4, #6250cd); }
.logo-small { flex: 0 0 42px; height: 42px; border-radius: 14px; }

.bottom-nav { position: fixed; z-index: 20; bottom: 10px; left: 50%; display: grid; grid-template-columns: repeat(3, 1fr); width: min(calc(100% - 24px), 656px); padding: 7px; padding-bottom: calc(7px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: color-mix(in srgb, var(--surface) 91%, transparent); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 14px 35px rgba(35,27,70,.16); backdrop-filter: blur(18px); }
.nav-item { display: grid; justify-items: center; gap: 2px; border: 0; border-radius: 15px; padding: 7px; color: var(--muted); background: transparent; }
.nav-item span { font-size: 20px; line-height: 20px; }.nav-item small { font-size: 9px; font-weight: 700; }
.nav-item.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.floating-add { display: none; position: fixed; z-index: 19; right: 20px; bottom: calc(92px + env(safe-area-inset-bottom)); width: 52px; height: 52px; border: 0; border-radius: 18px; color: var(--accent-text); background: var(--accent); font-size: 29px; box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 34%, transparent); }

.modal { position: fixed; z-index: 50; inset: 0; display: flex; align-items: end; justify-content: center; background: rgba(15,12,26,.42); backdrop-filter: blur(3px); }
.sheet { width: min(100%, 680px); max-height: 92vh; overflow-y: auto; padding: 8px 20px calc(24px + env(safe-area-inset-bottom)); background: var(--surface); border-radius: 26px 26px 0 0; animation: sheet-up .25s ease both; }
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet-handle { width: 40px; height: 4px; margin: 2px auto 14px; border-radius: 8px; background: var(--line); }
.sheet-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.sheet-title h2 { margin: 0; font-size: 22px; }.close-modal { width: 34px; height: 34px; border: 0; border-radius: 50%; color: var(--muted); background: var(--bg); font-size: 22px; }
form label { margin-bottom: 14px; } form label input, form label select { margin-top: 7px; color: var(--text); }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
fieldset { padding: 0; margin: 0 0 13px; border: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip input { display: none; }.chip span { display: inline-block; padding: 9px 11px; border: 1px solid var(--line); border-radius: 12px; font-size: 12px; background: var(--bg); }
.chip input:checked + span { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); font-weight: 750; }

.toast { position: fixed; z-index: 80; left: 50%; bottom: calc(102px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 36px); padding: 11px 15px; transform: translateX(-50%); color: #fff; text-align: center; border-radius: 13px; background: #25222d; box-shadow: var(--shadow); font-size: 13px; }
.loader-screen, .fatal { min-height: 100vh; display: grid; place-content: center; justify-items: center; padding: 30px; text-align: center; }
.logo-mark { width: 62px; height: 62px; border-radius: 21px; font-size: 27px; box-shadow: 0 14px 30px rgba(97,80,205,.28); }
.spinner { width: 22px; height: 22px; margin-top: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-screen p, .fatal p { color: var(--muted); }.fatal-icon { font-size: 44px; }.fatal h1 { font-size: 23px; margin: 16px 0 0; }

@media (min-width: 520px) { .floating-add { display: block; } .calendar-card { padding: 20px; }.day { font-size: 15px; } }

