/* Baza treści — arkusz stylów.
   Mobile-first: układ projektowany pod telefon, na szerokim ekranie tylko się rozsuwa. */

:root {
  --bg:        #f7f4ef;
  --surface:   #ffffff;
  --surface-2: #f1ece4;
  --ink:       #1c1917;
  --ink-soft:  #6b625b;
  --line:      #e2dbd1;
  --accent:    #c2410c;
  --accent-ink:#ffffff;
  --danger:    #b91c1c;
  --ok:        #15803d;
  --radius:    14px;
  --shadow:    0 1px 2px rgb(28 25 23 / 6%), 0 8px 24px rgb(28 25 23 / 6%);
  --tabbar-h:  62px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #14110f;
    --surface:   #1f1b18;
    --surface-2: #272220;
    --ink:       #f5f1ec;
    --ink-soft:  #a79d94;
    --line:      #352f2b;
    --accent:    #fb923c;
    --accent-ink:#1c1917;
    --danger:    #f87171;
    --ok:        #4ade80;
    --shadow:    0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
  }
}

:root[data-theme="dark"] {
  --bg:        #14110f;
  --surface:   #1f1b18;
  --surface-2: #272220;
  --ink:       #f5f1ec;
  --ink-soft:  #a79d94;
  --line:      #352f2b;
  --accent:    #fb923c;
  --accent-ink:#1c1917;
  --danger:    #f87171;
  --ok:        #4ade80;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.is-locked { overflow: hidden; }

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p  { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

/* ───────────────────────────────────────────────────────────── układ */

.app { min-height: 100svh; display: flex; flex-direction: column; }

.main {
  flex: 1;
  padding: 16px 16px calc(var(--tabbar-h) + 28px);
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
}

.view { animation: fade 160ms ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.stack        { display: flex; flex-direction: column; gap: 16px; }
.stack--tight { gap: 8px; }
.row          { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--tight   { gap: 6px; flex-wrap: nowrap; }
.row--end     { justify-content: flex-end; }
.row--between { justify-content: space-between; flex-wrap: nowrap; }
.row--thin    { padding: 6px 0; border-bottom: 1px solid var(--line); }
.grid         { display: grid; gap: 12px; }
.grid--2      { grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid--2 { grid-template-columns: 1fr 1fr; } }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.muted  { color: var(--ink-soft); font-size: 0.9rem; }
.empty  { color: var(--ink-soft); font-size: 0.9rem; padding: 18px; text-align: center;
          border: 1px dashed var(--line); border-radius: var(--radius); }
.mono   { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }

/* ──────────────────────────────────────────────────────── górny pasek */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px 8px;
  padding-top: max(10px, env(safe-area-inset-top));
}

.demo-bar {
  margin: -10px -16px 8px;
  padding: 7px 16px;
  background: var(--danger); color: #fff;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-align: center;
}

.topbar__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { font-size: 1.1rem; letter-spacing: -0.02em; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips--scroll {
  margin-top: 8px; flex-wrap: nowrap; overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips--scroll::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 0.85rem; cursor: pointer;
}
.chip.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.is-active .dot { outline: 2px solid var(--bg); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot, var(--ink-soft)); flex: none; }
.dot--empty { background: transparent; border: 1.5px dashed var(--ink-soft); }

/* ──────────────────────────────────────────────────────── nawigacja */

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(var(--tabs, 5), 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 2px; border: 0; background: none; cursor: pointer;
  color: var(--ink-soft); font-size: 0.68rem;
}
.tab.is-active { color: var(--accent); }
.tab__icon { font-size: 1.1rem; line-height: 1; }
.tab__badge {
  position: absolute; top: 4px; right: 50%; translate: 18px 0;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-size: 0.65rem; line-height: 17px; text-align: center;
}

/* ─────────────────────────────────────────────────────────── elementy */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card--soft { box-shadow: none; background: var(--surface-2); }
.card__title { font-weight: 600; }

.card--collapsible { padding: 0; }
.card--collapsible > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 14px; cursor: pointer; list-style: none;
}
.card--collapsible > summary::-webkit-details-marker { display: none; }
.card--collapsible > summary::after { content: '⌄'; margin-left: auto; color: var(--ink-soft); }
.card--collapsible[open] > summary::after { content: '⌃'; }
.card--collapsible > .stack { padding: 0 14px 14px; }

.sub-details > summary { cursor: pointer; font-size: 0.9rem; padding: 6px 0; }

.badge {
  display: inline-block; min-width: 20px; padding: 1px 7px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink-soft);
  font-size: 0.75rem; text-align: center;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 0.9rem; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn--small { padding: 6px 10px; font-size: 0.82rem; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex: none;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--ink-soft); cursor: pointer; font-size: 1rem;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

input[type="text"], input[type="email"], input[type="date"], input[type="password"],
input[type="search"], input[type="number"], textarea, select {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
}
textarea { resize: vertical; min-height: 44px; }
input:focus-visible, textarea:focus-visible, select:focus-visible,
button:focus-visible, .idea-card:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

/* Menedżer haseł przeglądarki maluje pola na biało — w ciemnym motywie
   wygląda to jak usterka. Przywracamy własne kolory. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input[type="password"]:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  caret-color: var(--ink);
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field__label { font-size: 0.78rem; font-weight: 600; color: var(--ink-soft);
                text-transform: uppercase; letter-spacing: 0.04em; }
.field__hint  { font-size: 0.78rem; color: var(--ink-soft); }

.mini-select { width: auto; padding: 6px 8px; font-size: 0.82rem; border-radius: 8px; }
.num-input   { width: 72px; text-align: center; }
.ghost-input { border-color: transparent; background: transparent; padding: 6px 8px; }
.ghost-input:hover { border-color: var(--line); }
.search { background: var(--surface); }

.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 0.9rem; }
.switch input { width: auto; accent-color: var(--accent); }

.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  background: var(--dot); border: 2px solid transparent;
}
.swatch.is-active { border-color: var(--ink); }

.note { padding: 10px 12px; border-radius: 10px; font-size: 0.86rem; }
.note--warn { background: color-mix(in srgb, var(--accent) 12%, var(--surface));
              border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }

/* ──────────────────────────────────────────────── skrzynka i listy */

.capture { padding: 12px; }
.capture__input {
  border: 0; padding: 4px 2px; font-size: 1.02rem; background: transparent;
}
.capture__input:focus-visible { outline: none; }
.capture__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line);
}
.capture__foot .chips { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
.capture__foot .chips::-webkit-scrollbar { display: none; }

.row-card {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 10px;
}
.row-card--thin { padding: 3px 6px; }
.row-card--pick { width: 100%; cursor: pointer; text-align: left; }
.row-card--pick:hover { background: var(--surface-2); }
.row-card__main {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
  border: 0; background: none; padding: 4px 0; cursor: pointer; text-align: left;
}
.row-card__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-card__side { display: flex; align-items: center; gap: 6px; flex: none; }

/* Na wąskim ekranie tytuł dostaje całą szerokość, a przypisanie schodzi pod niego —
   inaczej z „5 błędów przy ostrzeniu noża" zostaje „5 błędów pr…". */
@media (max-width: 520px) {
  .row-card { flex-wrap: wrap; }
  .row-card__main { flex-basis: 100%; }
  .row-card__side { margin-left: auto; }
  .row-card__side .mini-select { max-width: 42vw; }
}

.scroll-box { max-height: 44svh; overflow-y: auto; }

.filters { display: flex; flex-direction: column; gap: 8px; }
.filters__row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px;
                scrollbar-width: none; }
.filters__row::-webkit-scrollbar { display: none; }

.idea-card {
  display: flex; flex-direction: column; gap: 7px;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--accent, var(--line));
  border-radius: var(--radius); padding: 12px; cursor: pointer;
}
.idea-card:hover { background: var(--surface-2); }
.idea-card__head  { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.idea-card__title { font-size: 0.98rem; font-weight: 600; }
.idea-card__tags  { display: flex; gap: 5px; flex-wrap: wrap; }
.idea-card__date  { margin-left: auto; font-size: 0.78rem; color: var(--ink-soft); }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-soft); font-size: 0.74rem;
}
.tag--project { font-weight: 600; color: var(--ink); }
.tag--shared  { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.tag--mode    { font-size: 0.7rem; }

.pill { padding: 2px 8px; border-radius: 999px; font-size: 0.72rem;
        background: var(--surface-2); color: var(--ink-soft); }
.pill--gotowe       { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill--opublikowane { background: var(--ink); color: var(--bg); }

.task-note { font-size: 0.86rem; padding: 7px 10px; border-radius: 8px;
             background: var(--surface-2); white-space: pre-wrap; }
.idea-card--done { opacity: 0.68; }

.read-field { padding: 9px 11px; border-radius: 10px; background: var(--surface); }
.read-field p { margin-top: 4px; white-space: pre-wrap; font-size: 0.92rem; }

.comment { font-size: 0.86rem; padding: 8px 10px; border-radius: 8px; background: var(--surface);
           white-space: pre-wrap; }
.comment--mine { border-left: 3px solid var(--accent); }
.tag--guest { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.verdict { font-size: 0.84rem; font-weight: 600; }
.verdict--zatwierdzone { color: var(--ok); }
.verdict--poprawki     { color: var(--accent); }

/* ───────────────────────────────────────────────────────── kalendarz */

.week-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .week-grid { grid-template-columns: 1fr 1fr; } }

.week-card { padding: 10px; border-radius: 10px; background: var(--surface-2); }
.week-card__head { display: flex; align-items: center; gap: 7px; font-weight: 600;
                   font-size: 0.9rem; margin-bottom: 8px; }

.target { display: grid; grid-template-columns: 1fr 70px 34px; align-items: center; gap: 8px;
          font-size: 0.8rem; }
.target__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
                 color: var(--ink-soft); }
.target__bar   { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.target__fill  { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.target__count { text-align: right; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.calendar { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
            background: var(--surface); }
.calendar__head {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.calendar__head span { padding: 6px 4px; text-align: center; font-size: 0.72rem;
                       color: var(--ink-soft); }
.calendar__grid { display: grid; grid-template-columns: repeat(7, 1fr); }

.day {
  min-height: 74px; padding: 4px; cursor: pointer;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 3px;
}
.day:nth-child(7n) { border-right: 0; }
.day:hover { background: var(--surface-2); }
.day--outside { opacity: 0.4; }
.day--today .day__num { background: var(--accent); color: var(--accent-ink); }
.day__num {
  align-self: flex-start; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; font-size: 0.74rem; line-height: 20px; text-align: center;
  color: var(--ink-soft); font-variant-numeric: tabular-nums;
}
.day__items { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.day__item {
  border: 0; border-left: 3px solid var(--accent, var(--ink-soft));
  background: var(--surface-2); color: var(--ink);
  border-radius: 4px; padding: 2px 4px; cursor: pointer;
  font-size: 0.66rem; line-height: 1.25; text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.day__item:hover { filter: brightness(0.96); }

/* ───────────────────────────────────────────────────── panel boczny */

.sheet { position: fixed; inset: 0; z-index: 40; display: none; }
.sheet.is-open { display: block; }
.sheet__scrim { position: absolute; inset: 0; background: rgb(0 0 0 / 42%); }
.sheet__panel {
  position: absolute; inset: auto 0 0 0;
  max-height: 92svh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 40px rgb(0 0 0 / 22%);
  animation: rise 200ms cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }

@media (min-width: 720px) {
  .sheet__panel {
    inset: 50% auto auto 50%; translate: -50% -50%;
    width: min(680px, 92vw); max-height: 86svh; border-radius: var(--radius);
  }
  .sheet__panel--wide { width: min(760px, 94vw); }
}

.sheet__head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.sheet__head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet__body {
  padding: 16px; overflow-y: auto;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.editor .field__label { letter-spacing: 0.03em; }

/* ───────────────────────────────────────────────── logowanie, toast */

.login { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.login__card { width: min(380px, 100%); text-align: center; gap: 12px; }
.login__card input { text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px);
  translate: -50% 10px; z-index: 60;
  padding: 10px 16px; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-size: 0.86rem;
  opacity: 0; pointer-events: none; transition: opacity 160ms, translate 160ms;
}
.toast.is-visible { opacity: 1; translate: -50% 0; }
.toast--warn { background: var(--danger); color: #fff; }

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