/* ============================================================
   Relacje — modern light theme
   ============================================================ */
:root {
  /* surfaces & text */
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f1f3fa;
  --text: #171a24;
  --text-muted: #5b6276;
  --line: #e7e9f2;

  /* brand (vibrant indigo/violet) */
  --primary: #6d5efc;
  --primary-600: #5848e6;
  --primary-700: #4738c8;
  --primary-tint: #ece9ff;
  --on-primary: #ffffff;

  /* circle accents */
  --c1: #f43f5e; --c1-tint: #ffe7ec;   /* przyjaciele */
  --c2: #8b5cf6; --c2-tint: #f0e9ff;   /* bliscy znajomi */
  --c3: #0ea5e9; --c3-tint: #e3f4fe;   /* luźne znajomości */

  /* semantic */
  --danger: #e5484d; --danger-tint: #fdeaea;
  --warn:   #d97706; --warn-tint:   #fff3e0;
  --ok:     #12a36a;

  /* shape & depth */
  --r: 16px; --r-sm: 11px; --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(20,24,40,.06);
  --shadow: 0 1px 2px rgba(20,24,40,.05), 0 10px 28px -8px rgba(30,32,60,.14);
  --shadow-lg: 0 12px 40px -8px rgba(30,32,60,.28);

  --maxw: 720px;
}

* { box-sizing: border-box; }
/* The hidden attribute must always win, even over display:flex/grid set on a class. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.app-header__inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1rem;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; }
.brand__mark {
  display: grid; place-items: center; width: 34px; height: 34px;
  color: var(--on-primary); border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), #9b7bff);
  box-shadow: var(--shadow-sm);
}
.brand__mark svg { width: 19px; height: 19px; }
.brand__name { font-size: 1.18rem; letter-spacing: -.02em; }
.actions { display: flex; gap: .35rem; }

/* ---------- layout ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 1.1rem 1rem 4rem; }
.section { margin-top: 1.6rem; }
.section:first-child { margin-top: 1.1rem; }
.section__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.section__title {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); margin-bottom: .7rem;
}
.section__head .section__title { margin-bottom: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 600; font-size: .95rem;
  padding: .62rem 1rem; min-height: 44px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  cursor: pointer; transition: transform .12s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn--primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--primary-600); }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn--ghost:hover { border-color: #cdd1e4; background: var(--surface-2); }
.btn--block { width: 100%; }
.btn--sm { min-height: 38px; padding: .42rem .8rem; font-size: .9rem; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px; padding: 0;
  background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--line); border-radius: 11px; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { color: var(--primary); border-color: #cdd1e4; background: var(--surface-2); }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }

/* ---------- inputs ---------- */
input, select, textarea {
  font: inherit; width: 100%;
  padding: .66rem .8rem; min-height: 44px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 70px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #9aa0b4; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }

/* ---------- auth ---------- */
.auth { display: grid; place-items: center; min-height: 62vh; }
.auth__card { width: 100%; max-width: 400px; padding: 1.6rem 1.4rem; }
.auth__title { font-size: 1.35rem; }
.auth__sub { color: var(--text-muted); margin: .35rem 0 1.2rem; font-size: .95rem; }
.stack { display: flex; flex-direction: column; gap: .6rem; }

/* ---------- reminders ---------- */
.reminders { display: flex; flex-direction: column; gap: .55rem; }
.rem {
  display: flex; align-items: center; gap: .8rem;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--line); border-radius: var(--r-sm);
  padding: .7rem .85rem; box-shadow: var(--shadow-sm);
}
.rem--overdue { border-left-color: var(--danger); }
.rem--date { border-left-color: var(--primary); }
.rem__icon {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 1.05rem;
}
.rem--overdue .rem__icon { background: var(--danger-tint); }
.rem--date .rem__icon { background: var(--primary-tint); }
.rem__text { min-width: 0; flex: 1; }
.rem__title { font-weight: 600; font-size: .96rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rem__sub { color: var(--text-muted); font-size: .85rem; }
.rem__badge {
  flex: none; font-size: .78rem; font-weight: 700; padding: .25rem .55rem;
  border-radius: var(--r-pill); white-space: nowrap;
}
.rem--overdue .rem__badge { color: var(--danger); background: var(--danger-tint); }
.rem--date .rem__badge { color: var(--primary-700); background: var(--primary-tint); }

.empty {
  text-align: center; color: var(--text-muted);
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--r); padding: 1.4rem 1rem;
}

/* ---------- people groups ---------- */
.group { margin-top: 1.2rem; }
.group__head { display: flex; align-items: center; gap: .5rem; margin: 0 0 .55rem .1rem; }
.group__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--line); }
.group__dot.c1 { background: var(--c1); }
.group__dot.c2 { background: var(--c2); }
.group__dot.c3 { background: var(--c3); }
.group__name { font-size: .92rem; font-weight: 700; }
.group__count { color: var(--text-muted); font-size: .85rem; font-weight: 600; }

.people-grid { display: flex; flex-direction: column; gap: .6rem; }

/* ---------- person card ---------- */
.person {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center; gap: .85rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: .8rem .9rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease, transform .12s ease, border-color .15s ease;
}
.person:hover { box-shadow: var(--shadow); border-color: #dfe2ef; }
.avatar {
  flex: none; width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; font-weight: 700; font-size: 1.02rem; letter-spacing: .01em;
}
.avatar.c1 { color: var(--c1); background: var(--c1-tint); }
.avatar.c2 { color: var(--c2); background: var(--c2-tint); }
.avatar.c3 { color: var(--c3); background: var(--c3-tint); }
.person__main { min-width: 0; }
.person__name { font-weight: 600; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person__meta { color: var(--text-muted); font-size: .85rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.person__meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }
.person__meta .stale { color: var(--danger); font-weight: 600; }
.person__actions { display: flex; align-items: center; gap: .35rem; }
.chip-btn {
  display: inline-flex; align-items: center; gap: .35rem;
  font: inherit; font-weight: 600; font-size: .85rem;
  padding: .42rem .7rem; min-height: 38px;
  color: var(--primary-700); background: var(--primary-tint);
  border: none; border-radius: var(--r-pill); cursor: pointer;
  transition: background .15s, transform .1s;
}
.chip-btn:hover { background: #ddd6ff; }
.chip-btn:active { transform: scale(.96); }
.chip-btn svg { width: 16px; height: 16px; }
.mini-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  color: var(--text-muted); background: transparent; border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.mini-btn svg { width: 17px; height: 17px; }
.mini-btn:hover { color: var(--text); border-color: #cdd1e4; background: var(--surface-2); }
.mini-btn.danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-tint); }

/* ---------- messages ---------- */
.msg { color: var(--primary-700); min-height: 1.2em; font-size: .9rem; margin: .7rem 0 0; }
.msg--warn { color: var(--warn); }

/* ---------- dialog / bottom sheet ---------- */
dialog.sheet {
  width: min(96vw, 580px); max-height: 92vh; padding: 0;
  border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-lg); overflow: hidden;
  color: var(--text); background: var(--surface);
}
dialog.sheet::backdrop { background: rgba(18,20,38,.45); backdrop-filter: blur(2px); }
.sheet__form { display: flex; flex-direction: column; max-height: 92vh; }
.sheet__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--line);
}
.sheet__head h3 { font-size: 1.1rem; }
.sheet__body { padding: 1.1rem; overflow-y: auto; display: flex; flex-direction: column; gap: .85rem; }
.sheet__foot {
  display: flex; gap: .6rem; justify-content: flex-end;
  padding: .85rem 1.1rem; border-top: 1px solid var(--line); background: var(--surface);
}
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.field input, .field select, .field textarea { font-weight: 400; color: var(--text); }
.field__head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.field__head .btn--sm { min-height: 32px; padding: .3rem .6rem; font-size: .82rem; }

.subcard { border: 1px solid var(--line); border-radius: var(--r-sm); padding: .9rem; margin: 0; display: flex; flex-direction: column; gap: .7rem; }
.subcard legend { font-weight: 700; font-size: .9rem; padding: 0 .35rem; }

/* ---------- date sub-form ---------- */
.dates-list { display: flex; flex-direction: column; gap: .4rem; }
.dates-list > div {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  background: var(--surface-2); border-radius: var(--r-sm); padding: .45rem .6rem; font-size: .9rem;
}
.dates-list button {
  font: inherit; font-size: .82rem; color: var(--danger); background: none;
  border: none; cursor: pointer; padding: .2rem .4rem; min-height: auto; width: auto;
}
.date-add { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.date-add input, .date-add select { width: auto; min-height: 40px; flex: 0 1 auto; }
.date-add .date-add__label { flex: 1 1 100%; }
.date-add input[type="number"] { width: 6rem; }
.date-add #d-lead-label { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; color: var(--text-muted); }
.date-add #d-lead { width: 4rem; }
.date-add [hidden] { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .person { grid-template-columns: auto 1fr; }
  .person__actions {
    grid-column: 1 / -1; padding-top: .3rem;
    display: grid; grid-template-columns: 1fr auto auto; gap: .4rem;
  }
  .chip-btn { width: 100%; min-height: 44px; }
  .mini-btn { width: 44px; height: 44px; }

  /* dialog becomes a bottom sheet */
  dialog.sheet {
    width: 100%; max-width: 100%; max-height: 94vh;
    margin: 0; position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    border-radius: 20px 20px 0 0; border-bottom: none;
    animation: sheet-up .22s ease-out;
  }
  .sheet__form, dialog.sheet { max-height: 94vh; }
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
