/* MindHub — styl: spokojny, minimalistyczny, jasny i ciemny. Bez zewnętrznych czcionek i zasobów. */
:root {
  --bg: #f5f6fa; --surface: #ffffff; --surface-2: #eef0f6; --line: #dfe3ec;
  --text: #151a24; --muted: #596277;
  --accent: #4b57d2; --accent-ink: #ffffff; --accent-soft: #e6e8fb;
  --teal: #0b8a7c; --teal-soft: #dcf3ef;
  --warn: #8a5a00; --warn-soft: #fbefd5;
  --danger: #b3261e; --danger-soft: #fbe4e2;
  --shadow: 0 1px 2px rgba(20, 26, 40, .06), 0 6px 20px rgba(20, 26, 40, .05);
  --r: 16px; --gut: 16px; --nav-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0e1117; --surface: #171b24; --surface-2: #1f2430; --line: #2a3140;
  --text: #e8ebf3; --muted: #9aa3b6;
  --accent: #98a1ff; --accent-ink: #0e1117; --accent-soft: #252a4d;
  --teal: #4fd1bf; --teal-soft: #14332f;
  --warn: #f1c46a; --warn-soft: #3a2e12;
  --danger: #ff8d85; --danger-soft: #3d1b19;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1117; --surface: #171b24; --surface-2: #1f2430; --line: #2a3140;
    --text: #e8ebf3; --muted: #9aa3b6;
    --accent: #98a1ff; --accent-ink: #0e1117; --accent-soft: #252a4d;
    --teal: #4fd1bf; --teal-soft: #14332f;
    --warn: #f1c46a; --warn-soft: #3a2e12;
    --danger: #ff8d85; --danger-soft: #3d1b19;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.5 var(--font); -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

/* --- układ: telefon = dolny pasek, komputer = panel boczny --- */
.shell { min-height: 100vh; min-height: 100dvh; }
.col { min-width: 0; }
.rail { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.rail .brand, .rail-note { display: none; }
#nav { display: grid; grid-template-columns: repeat(5, 1fr); height: var(--nav-h); }
#nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; min-width: 0; }
#nav a .ico { width: 24px; height: 24px; }
#nav a[aria-current="page"] { color: var(--accent); }
#nav a[aria-current="page"] .nico { background: var(--accent-soft); }
.nico { display: grid; place-items: center; width: 52px; height: 30px; border-radius: 15px; }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) var(--gut) 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.top-actions { margin-left: auto; display: flex; gap: 4px; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
main { display: block; padding: 6px var(--gut) calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); max-width: 880px; margin: 0 auto; outline: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; }
.logo { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, #5b63e0, #14a394); color: #fff; font-weight: 800; }
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 248px 1fr; }
  .rail { position: sticky; top: 0; height: 100vh; height: 100dvh; border-top: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 22px 14px; }
  .rail .brand { display: flex; padding: 4px 10px 22px; font-size: 20px; }
  .brand-top { display: none; }
  #nav { display: flex; flex-direction: column; gap: 4px; height: auto; }
  #nav a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 12px; border-radius: 12px; font-size: 15px; }
  #nav a:hover { background: var(--surface-2); }
  #nav a[aria-current="page"] { background: var(--accent-soft); }
  .nico { width: auto; height: auto; background: none !important; }
  .rail-note { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 10px; font-size: 13px; color: var(--muted); }
  .top { padding-left: 32px; padding-right: 32px; }
  main { padding: 10px 32px 56px; }
}

/* --- elementy --- */
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.page-head { padding: 10px 0 18px; }
.page-head h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; margin-top: 2px; }
.lead { color: var(--muted); margin-top: 8px; max-width: 60ch; }
.stack { display: grid; gap: 14px; }
.grid2 { display: grid; gap: 14px; }
@media (min-width: 720px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.card h2 { font-size: 17px; letter-spacing: -.01em; }
.card h2 + p, .card .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.ok { background: var(--teal-soft); color: var(--teal); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.ico { width: 22px; height: 22px; flex: none; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.tile .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 26px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; margin-top: 2px; }
.tile .v small { font-size: 14px; font-weight: 600; color: var(--muted); }
.note { font-size: 13.5px; color: var(--muted); margin-top: 12px; }
.callout { display: flex; gap: 12px; padding: 14px; border-radius: 12px; background: var(--teal-soft); color: var(--text); font-size: 14.5px; }
.callout .ico { color: var(--teal); margin-top: 1px; }
.callout.warn { background: var(--warn-soft); } .callout.warn .ico { color: var(--warn); }
.callout.danger { background: var(--danger-soft); } .callout.danger .ico { color: var(--danger); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.list li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.list li:first-child { border-top: 0; }
.list.bullets li::before { content: ""; width: 6px; height: 6px; margin-top: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.modrow { display: flex; align-items: center; gap: 14px; padding: 12px 4px; border-top: 1px solid var(--line); text-decoration: none; color: var(--text); border-radius: 8px; }
.modrow:first-of-type { border-top: 0; }
.modrow:hover { background: var(--surface-2); }
.modrow .ico { color: var(--accent); }
.modrow .t { font-weight: 650; } .modrow .d { color: var(--muted); font-size: 14px; }
.modrow .chip { margin-left: auto; flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 650; cursor: pointer; text-decoration: none; color: var(--text); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
:root[data-theme="dark"] .btn.danger { color: #1a0a09; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 12px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 8px 16px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 15px; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; text-align: right; font-weight: 600; }

/* --- historia pomiarów --- */
.run { padding: 10px 0; border-top: 1px solid var(--line); }
.run:first-of-type { border-top: 0; }
.run-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.run-name { font-weight: 650; } .run-score { font-weight: 750; font-variant-numeric: tabular-nums; }
.run-score small { color: var(--muted); font-weight: 600; }
.bar { display: block; width: 100%; height: 8px; margin-top: 6px; }
.bar .bg { fill: var(--surface-2); } .bar .fg { fill: var(--accent); }
.meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* --- okno dialogowe, powiadomienie --- */
dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 22px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(8, 10, 16, .55); }
dialog h2 { font-size: 20px; margin-bottom: 10px; }
dialog p { margin-bottom: 10px; }
dialog ul { margin: 6px 0 10px; padding-left: 20px; font-size: 14.5px; }
dialog input[type=text] { width: 100%; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); margin-top: 6px; }
dialog label.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; margin-top: 12px; }
dialog label.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); max-width: min(92vw, 460px); padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 14.5px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) { .toast { bottom: 24px; left: calc(50% + 124px); } }
.noscript { padding: 20px; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .ico { width: 32px; height: 32px; margin-bottom: 8px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

.mt12 { margin-top: 12px; } .mt14 { margin-top: 14px; } .btn-row.center { justify-content: center; }

/* --- Sleep Lab --- */
.field { display: grid; gap: 6px; margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }
.field label, .field legend { font-size: 14px; font-weight: 600; padding: 0; }
.fields { display: grid; gap: 0 14px; }
@media (min-width: 560px) { .fields { grid-template-columns: repeat(3, 1fr); } }
.input { width: 100%; min-height: 46px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg span { min-width: 44px; text-align: center; }
.tiles3 { grid-template-columns: repeat(3, 1fr); }
.tiles3 .tile .v { font-size: 20px; }
.chart { display: block; width: 100%; height: auto; margin-top: 4px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 9px; }
.chart .sbar { fill: var(--accent); }
.chart .avg { stroke: var(--teal); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .nodata { stroke: var(--muted); stroke-width: 1.5; }
.slist .srow { align-items: center; justify-content: space-between; gap: 12px; }
.slist .srow .btn { min-height: 38px; padding: 0 14px; flex: none; }

.slist .srow .meta { display: block; margin-top: 2px; }
.slist .srow > div { min-width: 0; }
