/* ============================================================
   Panel Hermesa - style
   Priorytety: wysoki kontrast, wyrazny fokus, duze cele dotyku,
   układ dwustrefowy (przewijana lista + przypiety pasek dodawania).
   ============================================================ */

:root {
  --bg:         #eef2f5;
  --surface:    #ffffff;
  --surface-2:  #f4f7f9;
  --border:     #cbd6dd;
  --text:       #10222b;
  --muted:      #45565f;
  --brand:      #0c3b4a;
  --brand-text: #ffffff;
  --accent:     #0b6bcb;   /* interakcja / fokus */
  --success:    #15803d;   /* odhaczanie */
  --success-bg: #e7f4ec;
  --danger:     #b42318;   /* usuwanie */
  --shadow:     0 1px 2px rgba(16, 34, 43, .06), 0 4px 12px rgba(16, 34, 43, .05);
  --radius:     10px;
  --tap:        44px;      /* minimalny cel dotyku */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #0d151a;
    --surface:    #16232b;
    --surface-2:  #1c2c35;
    --border:     #34474f;
    --text:       #e8eff2;
    --muted:      #a9bac2;
    --brand:      #08303c;
    --brand-text: #eaf3f6;
    --accent:     #5eb2ff;
    --success:    #56d68e;
    --success-bg: #12321f;
    --danger:     #ff8a7a;
    --shadow:     none;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;          /* 17px - czytelnie */
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

/* ---------- fokus i pomijanie ---------- */

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: .75rem 1rem;
  z-index: 100;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus {
  left: 0;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- nagłowek + zakładki ---------- */

.app-header {
  background: var(--brand);
  color: var(--brand-text);
  padding: env(safe-area-inset-top) .75rem 0;
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .7rem .25rem .55rem;
}
.brand-mark { font-size: 1.1rem; opacity: .85; }
.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .01em;
  margin: 0;
}

.tablist {
  display: flex;
  gap: .35rem;
  overflow-x: auto;
  padding-bottom: .55rem;
  scrollbar-width: thin;
}

.tab {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: .5rem .9rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: var(--brand-text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: rgba(255, 255, 255, .22); }
.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--surface);
}
@media (prefers-color-scheme: dark) {
  .tab[aria-selected="true"] { color: var(--text); }
}

/* ---------- główna strefa: lista + pasek ---------- */

main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.scroll-area {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem .85rem 1.25rem;
  -webkit-overflow-scrolling: touch;
}

.refresh {
  float: right;
  min-height: 36px;
  padding: .35rem .8rem;
  margin: -.25rem 0 .25rem 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
}
.refresh:hover { color: var(--text); }

h2 {
  font-size: 1.35rem;
  margin: 0 0 .15rem;
  color: var(--text);
}

.count {
  margin: 0 0 .9rem;
  color: var(--muted);
  font-size: .95rem;
}

/* ---------- listy i elementy ---------- */

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .7rem .75rem;
}

.item-row {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
}

.item-body { flex: 1 1 auto; min-width: 0; }

.item-title {
  display: block;
  font-weight: 650;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}
.item-notes {
  display: block;
  color: var(--muted);
  font-size: .95rem;
  margin-top: .15rem;
  overflow-wrap: anywhere;
}
.item-meta {
  display: block;
  color: var(--muted);
  font-size: .85rem;
  margin-top: .25rem;
}
.prio {
  display: inline-block;
  font-weight: 700;
  color: var(--brand);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 .4rem;
  margin-right: .4rem;
  font-size: .8rem;
}
@media (prefers-color-scheme: dark) { .prio { color: var(--accent); } }

/* przyciski akcji na elemencie */
.actions { display: flex; gap: .4rem; flex: 0 0 auto; }

.btn {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: .4rem .7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  line-height: 1.1;
}
.btn:hover { background: var(--bg); }

.btn-check {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-bg);
}
.btn-check:hover { filter: brightness(.97); }
.btn-check .glyph { font-weight: 800; }

.btn-restore { border-color: var(--accent); color: var(--accent); background: transparent; }
.btn-delete  { border-color: var(--border); color: var(--danger); background: transparent; }
.btn-delete:hover { background: var(--surface-2); }

.btn-ghost {
  min-height: 38px; min-width: auto;
  padding: .3rem .6rem;
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
  font-size: .9rem;
}
.btn-ghost:hover { color: var(--text); }

/* ---------- cele: postep, kamienie, kroki ---------- */

.progress-wrap { margin-top: .5rem; }
.progress-text { font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
progress {
  width: 100%;
  height: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: var(--success); }
progress::-moz-progress-bar { background: var(--success); }

.goal-details {
  margin-top: .7rem;
  padding-top: .7rem;
  border-top: 1px dashed var(--border);
}
.milestone-list, .step-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.milestone {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .55rem;
}
.milestone.is-done > .item-row .item-title { text-decoration: line-through; color: var(--muted); }
.step-list { margin-top: .45rem; padding-left: .3rem; }
.step {
  display: flex; align-items: center; gap: .5rem;
  padding: .3rem .1rem;
  border-top: 1px solid var(--border);
}
.step:first-child { border-top: 0; }
.step.is-done .step-title { text-decoration: line-through; color: var(--muted); }
.step-title { flex: 1 1 auto; overflow-wrap: anywhere; }

/* mini-formularze do dodawania kamieni/krokow */
.inline-add {
  display: flex; gap: .4rem; margin-top: .5rem;
}
.inline-add input {
  flex: 1 1 auto;
  min-height: 40px;
  padding: .4rem .6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: .95rem;
}
.inline-add button {
  min-height: 40px;
  padding: .4rem .75rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-weight: 650;
  cursor: pointer;
}

.empty {
  color: var(--muted);
  font-style: italic;
  padding: .5rem 0;
}

/* ---------- pasek dodawania (przypiety) ---------- */

.add-bar {
  flex: 0 0 auto;
  display: flex;
  gap: .5rem;
  padding: .6rem .7rem calc(.6rem + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(16, 34, 43, .06);
}
.add-bar[hidden] { display: none; }

#add-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--tap);
  padding: .55rem .75rem;
  font-size: 1.05rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}
#add-input::placeholder { color: var(--muted); }

.add-submit {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: .55rem 1.15rem;
  font-size: 1.05rem;
  font-weight: 700;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: var(--brand-text);
  cursor: pointer;
}
.add-submit:hover { filter: brightness(1.08); }

/* ---------- filtr zrealizowanych ---------- */

.filter {
  display: flex;
  gap: .4rem;
  margin: 0 0 .8rem;
  flex-wrap: wrap;
}
.filter-btn {
  min-height: 40px;
  padding: .4rem .9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.filter-btn[aria-checked="true"] {
  background: var(--brand);
  color: var(--brand-text);
  border-color: var(--brand);
}

/* ---------- ograniczenie ruchu ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* wieksze ekrany: wysrodkowana kolumna */
@media (min-width: 720px) {
  .scroll-area, .add-bar { max-width: 760px; margin-left: auto; margin-right: auto; width: 100%; }
  .brand, .tablist { max-width: 760px; margin-left: auto; margin-right: auto; width: 100%; }
}

/* ---------- przenoszenie miedzy zakladkami ---------- */

.btn-move { border-color: var(--accent); color: var(--accent); background: transparent; }
.btn-move:hover { background: var(--surface-2); }

.move-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  margin-top: .6rem;
  padding-top: .6rem;
  border-top: 1px dashed var(--border);
}
.move-menu[hidden] { display: none; }
.move-menu-label { font-size: .9rem; color: var(--muted); margin-right: .1rem; }

.btn-move-dest {
  min-height: var(--tap);
  padding: .4rem .85rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 650;
  cursor: pointer;
}
.btn-move-dest:hover { background: var(--surface-2); }
