/* Šeimos kalendorius. Išdėstymas: permatoma lipni juosta su mėnesiu ir narių filtru; mėnesio kortelė ir dienos kortelės
   (plačiame ekrane greta, telefone vienos po kitų); apvalus „+“ apačioje dešinėje. */
:root {
  --bg: #F2F3F7;
  --surface: #FFFFFF;
  --sunk: #EBEDF3;
  --ink: #0F1322;
  --muted: #6A7085;
  --line: #E1E4EC;
  --accent: #2F5BFF;
  --on-accent: #FFFFFF;
  --accent-soft: color-mix(in srgb, var(--accent) 11%, var(--surface));
  --holiday: #E5484D;
  --warn: #B45F06;
  --knob: #FFFFFF;
  --glass: color-mix(in srgb, var(--bg) 80%, transparent);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 1px 2px rgb(15 19 34 / .04), 0 10px 30px rgb(15 19 34 / .06);
  --shadow-lg: 0 12px 32px rgb(47 91 255 / .32);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A0C11; --surface: #151821; --sunk: #1C202B; --ink: #EDEFF6; --muted: #8C93A7; --line: #262B38;
    --accent: #7590FF; --on-accent: #0A0C11; --holiday: #FF6B70; --warn: #FFB547; --knob: #FFFFFF;
    --shadow: 0 0 0 1px #20242F, 0 10px 30px rgb(0 0 0 / .35);
    --shadow-lg: 0 12px 32px rgb(0 0 0 / .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.45; font-weight: 500;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wrap {
  max-width: 1200px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); font-weight: 600; padding: 24px; text-align: center; }

/* Prisijungimas ir pirmas paleidimas */
.auth {
  min-height: 100vh; display: grid; place-items: center;
  padding: calc(24px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.auth-card {
  width: 100%; max-width: 420px; display: grid; gap: 14px;
  background: var(--surface); border-radius: 28px; padding: 28px 22px 22px; box-shadow: var(--shadow);
}
.auth-icon { width: 72px; height: 72px; border-radius: 18px; justify-self: center; box-shadow: var(--shadow-lg); }
.auth-card h1 { margin: 4px 0 0; text-align: center; font-size: 26px; font-weight: 800; letter-spacing: -.03em; }
.auth-card .lead { margin: -6px 0 4px; text-align: center; color: var(--muted); }
.hint.center { text-align: center; padding: 0; }

/* Viršus */
header.top {
  position: sticky; top: 0; z-index: 5;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6);
}
.top .wrap { padding-block: 14px 12px; display: flex; flex-direction: column; gap: 12px; }
.bar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.title-block { flex: 1 1 auto; min-width: 0; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); }
.eyebrow b { color: var(--accent); font-weight: 700; }
.month-title {
  font-weight: 800; font-size: clamp(30px, 7.5vw, 44px); line-height: 1.02;
  letter-spacing: -.035em; margin: 2px 0 0; text-wrap: balance;
}
.month-title .yr { color: var(--muted); font-weight: 600; }
.nav { display: flex; gap: 6px; align-items: center; }
.btn {
  border: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  height: 40px; padding: 0 16px; border-radius: 999px; font-weight: 700; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap;
}
.btn:hover { background: var(--sunk); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.icon { width: 40px; padding: 0; }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn.big { height: 52px; font-size: 16px; margin-top: 4px; }
.btn.soft { background: var(--sunk); box-shadow: none; }
.btn.danger { background: color-mix(in srgb, var(--holiday) 12%, var(--surface)); color: var(--holiday); box-shadow: none; }
.btn.danger.armed { background: var(--holiday); color: var(--surface); }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; }
@media (max-width: 479px) {
  #familyBtn .lbl { display: none; }
  #familyBtn { width: 40px; padding: 0; }
  #todayBtn { padding: 0 12px; }
}
.me-btn { border: 0; padding: 0; background: none; border-radius: 50%; width: 40px; height: 40px; display: grid; place-items: center; }
.me-btn .av { width: 36px; height: 36px; font-size: 15px; box-shadow: 0 0 0 2px var(--surface), var(--shadow); }

.filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-inline: -4px; padding: 2px 4px; }
.filters::-webkit-scrollbar { display: none; }
.av {
  width: 24px; height: 24px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  background: var(--c); color: #FFFFFF; font-size: 11.5px; font-weight: 800; line-height: 1;
}
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px 0 6px; border-radius: 999px; border: 0;
  background: var(--surface); box-shadow: var(--shadow); font-size: 14px; font-weight: 700;
}
.chip[aria-pressed="false"] { color: var(--muted); background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.chip[aria-pressed="false"] .av { background: var(--line); color: var(--muted); }
.chip.ghost { padding: 0 14px; color: var(--accent); background: var(--accent-soft); box-shadow: none; }

.status { font-size: 13px; font-weight: 600; color: var(--muted); }
.status:empty { display: none; }

/* Pagrindinė dalis */
main.wrap { padding-block: 6px calc(130px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 16px; }
@media (min-width: 920px) {
  main.wrap { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; gap: 20px; }
  .side { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 150px); }
}

.cal { background: var(--surface); border-radius: 28px; padding: 14px 10px 12px; box-shadow: var(--shadow); overflow: hidden; }
.dow, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dow div { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--muted); padding-bottom: 8px; letter-spacing: .02em; }
.dow div:last-child { color: var(--holiday); }
.day {
  position: relative; min-width: 0; min-height: 60px; padding: 6px 2px 7px; border: 0; border-radius: 16px;
  background: transparent; display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.day:hover { background: var(--sunk); }
.day.out { opacity: .35; }
.day.sel { background: var(--accent-soft); }
.num {
  font-weight: 700; font-size: 15.5px; font-variant-numeric: tabular-nums;
  width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center;
}
.day.hol .num, .day.sun .num { color: var(--holiday); }
.day.sel .num { color: var(--accent); }
.day.today .num { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-lg); }
.hol-name { display: none; }
.marks { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; min-width: 0; max-width: 100%; }
.ev { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.ev .t { display: none; }
.more { font-size: 10px; font-weight: 800; color: var(--muted); line-height: 6px; }

@media (min-width: 680px) {
  .cal { padding: 18px 16px 16px; }
  .dow, .grid { gap: 6px; }
  .dow div { text-align: left; padding-left: 10px; }
  .day { min-height: 116px; padding: 8px; align-items: stretch; text-align: left; gap: 4px; }
  .num { width: 32px; height: 32px; align-self: flex-start; font-size: 15px; }
  .hol-name {
    display: block; font-size: 11px; line-height: 1.25; color: var(--holiday); font-weight: 700; padding-left: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .marks { flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; gap: 3px; }
  .ev {
    width: auto; height: auto; border-radius: 8px; padding: 3px 7px;
    background: color-mix(in srgb, var(--c) 15%, var(--surface)); color: var(--ink);
    font-size: 12px; font-weight: 700; line-height: 1.3;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  }
  .ev .t { display: inline; }
  .ev .tm { font-variant-numeric: tabular-nums; color: color-mix(in srgb, var(--c) 70%, var(--ink)); margin-right: 4px; }
  .more { line-height: 1.3; padding-left: 7px; font-size: 11.5px; }
}

/* Dienos ir artimiausių įvykių kortelės */
.side { display: grid; gap: 16px; }
.panel { background: var(--surface); border-radius: 28px; padding: 20px 16px 16px; box-shadow: var(--shadow); }
.panel h2 { font-weight: 800; font-size: 22px; line-height: 1.15; letter-spacing: -.02em; margin: 0; text-wrap: balance; }
.panel h3 { font-weight: 800; font-size: 17px; letter-spacing: -.01em; margin: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 4px 14px; }
.panel-head .sub { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.list { display: grid; gap: 8px; }
.item {
  display: grid; grid-template-columns: 4px 50px minmax(0, 1fr); gap: 12px; align-items: start;
  width: 100%; text-align: left; padding: 12px 14px 12px 12px; border-radius: 18px; border: 0;
  background: color-mix(in srgb, var(--c) 9%, var(--surface));
}
.item:hover { background: color-mix(in srgb, var(--c) 15%, var(--surface)); }
.item .stripe { align-self: stretch; border-radius: 4px; overflow: hidden; display: flex; flex-direction: column; }
.item .stripe span { flex: 1; background: var(--c); }
.item .when { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 15px; line-height: 1.2; }
.item .when small { display: block; font-weight: 600; color: var(--muted); font-size: 12px; margin-top: 2px; }
.item .what { min-width: 0; display: grid; gap: 4px; }
.item .ttl { font-weight: 700; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.item .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.item .meta svg.i { width: 14px; height: 14px; }
.item .meta .rep { display: inline-flex; align-items: center; gap: 4px; }
.avs { display: inline-flex; }
.avs .av { width: 20px; height: 20px; font-size: 9.5px; box-shadow: 0 0 0 2px var(--surface); }
.avs .av + .av { margin-left: -5px; }
.item .note { font-size: 13px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.hol-row {
  display: flex; gap: 8px; align-items: center; font-size: 13.5px; font-weight: 700; color: var(--holiday);
  padding: 10px 14px; border-radius: 16px; background: color-mix(in srgb, var(--holiday) 9%, var(--surface));
}
.hol-row svg.i { width: 16px; height: 16px; }
.empty { color: var(--muted); font-size: 14px; font-weight: 600; padding: 18px 8px; text-align: center; background: var(--sunk); border-radius: 18px; margin: 0; }
.group { display: grid; gap: 8px; }
.group + .group { margin-top: 16px; }
.group-head { font-size: 13px; font-weight: 800; color: var(--ink); padding-left: 4px; }
.group-head span { color: var(--muted); font-weight: 600; }
.foot { font-size: 12.5px; font-weight: 500; color: var(--muted); margin: 0 8px; }

/* Pridėjimo mygtukas */
.fab {
  position: fixed; z-index: 6;
  right: max(18px, calc(env(safe-area-inset-right, 0px) + 12px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 62px; height: 62px; border-radius: 22px; border: 0;
  background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: var(--shadow-lg);
}
.fab svg.i { width: 26px; height: 26px; stroke-width: 2.4; }
.fab .lbl { display: none; }
@media (min-width: 680px) { .fab { width: auto; padding: 0 24px 0 18px; border-radius: 999px; } .fab .lbl { display: inline; } }

/* Langai */
dialog.sheet {
  border: 0; padding: 0; background: var(--surface); color: var(--ink);
  width: min(540px, calc(100vw - 32px)); max-height: min(92vh, 880px);
  border-radius: 28px; box-shadow: 0 30px 80px rgb(0 0 0 / .3);
}
dialog.sheet::backdrop { background: rgb(5 8 18 / .45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.grab { display: none; }
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0 0; width: 100vw; max-width: 100vw; border-radius: 28px 28px 0 0; max-height: 94vh; }
  .grab { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: -6px auto 0; }
}
.sheet-in {
  display: grid; gap: 14px;
  padding-block: 18px calc(18px + env(safe-area-inset-bottom, 0px));
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.sheet-in h2 { font-size: 24px; font-weight: 800; margin: 0; letter-spacing: -.025em; }
.sheet-in .lead { margin: -8px 0 0; color: var(--muted); font-size: 14px; font-weight: 500; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .lbl { font-size: 12.5px; font-weight: 700; color: var(--muted); padding-left: 4px; }
.hint { font-size: 12.5px; color: var(--muted); padding-left: 4px; }
.lbl-strong { font-weight: 800; font-size: 15px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type=text], input[type=password], input[type=date], input[type=time], select, textarea {
  width: 100%; min-width: 0; height: 50px; padding: 0 14px; border-radius: 16px;
  border: 1.5px solid transparent; background: var(--sunk); font-size: 16px; font-weight: 600;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 15px) 22px; background-size: 5px 5px; background-repeat: no-repeat;
  padding-right: 34px;
}
input#fTitle { font-size: 18px; font-weight: 700; }
#lCode, #lPin, #sPin, #sPin2 { font-size: 22px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
textarea { height: auto; min-height: 84px; padding: 12px 14px; resize: vertical; font-weight: 500; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background-color: var(--surface); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; font-weight: 500; letter-spacing: normal; font-size: 15px; }
.switch {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 8px 0 16px; height: 50px; border-radius: 16px; background: var(--sunk); font-weight: 700; cursor: pointer;
}
.switch input {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none; cursor: pointer;
  width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative;
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--knob); box-shadow: 0 2px 6px rgb(0 0 0 / .2);
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }
.who { display: flex; flex-wrap: wrap; gap: 8px; }
.who .chip { box-shadow: none; background: var(--accent-soft); color: var(--ink); }
.who .chip[aria-pressed="false"] { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--line); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-top: 4px; }
.actions .grow { flex: 1; }
.actions .btn { height: 48px; padding: 0 20px; font-size: 15px; }
.err { color: var(--holiday); font-size: 13.5px; font-weight: 700; padding-left: 4px; }
.err:empty { display: none; }
.warn {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 16px;
  background: color-mix(in srgb, var(--warn) 14%, var(--surface)); color: var(--ink);
  font-size: 13.5px; font-weight: 600; line-height: 1.4;
}
.warn svg.i { color: var(--warn); margin-top: 1px; }
.warn b { color: var(--warn); font-weight: 800; }

.mem-list { display: grid; gap: 10px; }
.mem { display: grid; gap: 10px; padding: 12px; border-radius: 20px; background: color-mix(in srgb, var(--c) 9%, var(--surface)); }
.mem-top { display: flex; gap: 10px; align-items: center; }
.mem-top .av { width: 40px; height: 40px; font-size: 16px; }
.mem-top input { flex: 1; height: 44px; background: var(--surface); }
.mem-name { flex: 1; min-width: 0; display: grid; }
.mem-name b { font-size: 16px; overflow-wrap: anywhere; }
.mem-name span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.mem-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.mem-tools .code { flex-basis: 100%; font-size: 13px; font-weight: 700; color: var(--muted); padding-left: 2px; font-variant-numeric: tabular-nums; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0; background: var(--c);
  display: grid; place-items: center; color: #FFFFFF;
}
.swatch svg.i { width: 16px; height: 16px; stroke-width: 3; visibility: hidden; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.swatch[aria-pressed="true"] svg.i { visibility: visible; }
.swatch:disabled { cursor: default; }
.add-mem { display: grid; gap: 12px; padding: 14px; border-radius: 20px; background: var(--sunk); }
.add-mem input[type=text], .add-mem input[type=password] { background-color: var(--surface); }

.cred { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cred div { background: var(--accent-soft); border-radius: 18px; padding: 14px; display: grid; gap: 2px; text-align: center; }
.cred span { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.cred b { font-size: 34px; font-weight: 800; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
#credMsg { font-size: 14px; font-weight: 500; min-height: 190px; }

.me-head { display: flex; gap: 14px; align-items: center; }
.me-head .av { width: 56px; height: 56px; font-size: 22px; }
.me-head h2 { margin: 0; }
.me-head p { margin: 2px 0 0; color: var(--muted); font-weight: 600; }
.me-head p b { color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: .06em; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-weight: 700; font-size: 14px; box-shadow: var(--shadow-lg);
}

@media (prefers-reduced-motion: no-preference) {
  .day, .btn, .chip, .item, .switch input, .switch input::after, .swatch { transition: background-color .18s, color .18s, box-shadow .18s, transform .2s cubic-bezier(.3,.7,.4,1); }
  .btn:active, .chip:active, .day:active, .item:active { transform: scale(.97); }
  .fab { transition: transform .2s cubic-bezier(.3,.7,.4,1); }
  .fab:active { transform: scale(.92); }
  .grid.slide-l { animation: slideL .28s cubic-bezier(.2,.8,.3,1); }
  .grid.slide-r { animation: slideR .28s cubic-bezier(.2,.8,.3,1); }
  @keyframes slideL { from { transform: translateX(24px); opacity: .3; } to { transform: none; opacity: 1; } }
  @keyframes slideR { from { transform: translateX(-24px); opacity: .3; } to { transform: none; opacity: 1; } }
  dialog.sheet[open] { animation: up .3s cubic-bezier(.2,.8,.3,1); }
  @keyframes up { from { transform: translateY(24px); opacity: .5; } to { transform: none; opacity: 1; } }
  .toast:not([hidden]) { animation: pop .25s cubic-bezier(.2,.8,.3,1); }
  @keyframes pop { from { transform: translate(-50%, 10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
  .warn:not([hidden]) { animation: shake .35s ease-out; }
  @keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 60% { transform: translateX(3px); } }
}
.btn.soft.armed { background: var(--accent); color: var(--on-accent); }
