/* AutoRootArchitect Mini App — kolory z motywu Telegrama (--tg-theme-*), z zapasowymi wartościami */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f3f6);
  --text: var(--tg-theme-text-color, #1b2230);
  --hint: var(--tg-theme-hint-color, #7d8593);
  --link: var(--tg-theme-link-color, #2f80ed);
  --btn: var(--tg-theme-button-color, #2f80ed);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --card: var(--tg-theme-section-bg-color, var(--bg));
  --sep: color-mix(in srgb, var(--hint) 22%, transparent);
  --navy: #1e2a3b;
  --gold: #e0a526;
  --free: #1f9d55;
  --busy: #d97706;
  --radius: 16px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tg]) { --bg: #17212b; --bg2: #0e1621; --text: #f2f4f7; --hint: #8796a8; --card: #17212b; }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg2);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
[hidden] { display: none !important; }

#view { padding: 12px 12px calc(var(--tab-h) + var(--safe-b) + 20px); max-width: 720px; margin: 0 auto; min-height: 100vh; }

/* --- pasek nawigacji ---------------------------------------------------------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--sep);
}
#tabbar button {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--hint); font-size: 11.5px; font-weight: 600; cursor: pointer;
}
#tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabbar button.active { color: var(--btn); }

/* --- elementy ogólne --------------------------------------------------------------- */
.loading { display: grid; place-items: center; min-height: 60vh; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--sep); border-top-color: var(--btn); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card h3, .section-title { margin: 0 0 10px; font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--hint); font-weight: 700; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 4px 12px; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.pre { white-space: pre-wrap; word-break: break-word; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.empty { text-align: center; color: var(--hint); padding: 28px 12px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

.btn {
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 650; cursor: pointer;
  background: var(--btn); color: var(--btn-text); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.block { width: 100%; }
.btn.soft { background: color-mix(in srgb, var(--btn) 12%, transparent); color: var(--btn); }
.btn.ghost { background: transparent; color: var(--btn); padding: 8px 10px; }
.btn.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn.small { padding: 8px 12px; font-size: 13.5px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: default; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px;
  font-size: 12.5px; font-weight: 650; white-space: nowrap; border: 0; cursor: default;
  background: color-mix(in srgb, var(--hint) 16%, transparent); color: var(--hint);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.free { background: color-mix(in srgb, var(--free) 15%, transparent); color: var(--free); }
.chip.busy { background: color-mix(in srgb, var(--busy) 16%, transparent); color: var(--busy); }
.chip.none::before { display: none; }
.chip.click { cursor: pointer; }
.chip.phase-active { background: color-mix(in srgb, var(--free) 15%, transparent); color: var(--free); }
.chip.phase-planned { background: color-mix(in srgb, var(--btn) 14%, transparent); color: var(--btn); }
.chip.phase-done, .chip.phase-cancelled { }
.tag { display: inline-block; border-radius: 8px; padding: 4px 9px; margin: 0 6px 6px 0; font-size: 13px; background: var(--bg2); }

/* --- profil / CV ------------------------------------------------------------------ */
.cv-hero {
  position: relative; overflow: hidden; border-radius: 20px; padding: 22px 18px 18px; margin-bottom: 12px;
  background: linear-gradient(150deg, #1e2a3b 0%, #2b3c55 100%); color: #eef2f7;
}
.cv-hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; border: 18px solid rgba(224,165,38,.18); }
.cv-top { display: flex; gap: 16px; align-items: center; position: relative; z-index: 1; }
.avatar {
  width: 84px; height: 84px; border-radius: 50%; flex: none; overflow: hidden; display: grid; place-items: center;
  background: #34465f; color: #fff; font-weight: 700; font-size: 28px; box-shadow: 0 0 0 3px var(--gold);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 40px; height: 40px; font-size: 15px; box-shadow: none; }
.cv-name { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: -.01em; }
.cv-headline { margin: 3px 0 8px; color: #b9c4d3; font-size: 14.5px; }
.cv-hero .chip { background: rgba(255,255,255,.12); color: #e8ecf2; }
.cv-hero .chip.free { background: rgba(46,204,113,.2); color: #7ee2a8; }
.cv-hero .chip.busy { background: rgba(224,165,38,.22); color: #f5c560; }
.cv-contacts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; position: relative; z-index: 1; font-size: 13.5px; color: #d0d8e3; }
.cv-contacts span { display: inline-flex; gap: 6px; align-items: center; }
.cv-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 18px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.timeline li::after { content: ""; position: absolute; left: 3.5px; top: 18px; bottom: 2px; width: 1px; background: var(--sep); }
.timeline li:last-child::after { display: none; }
.timeline b { display: block; }
.timeline .meta { color: var(--hint); font-size: 13px; }
.hint-box { border: 1.5px dashed var(--sep); border-radius: 14px; padding: 14px; color: var(--hint); text-align: center; font-size: 14px; cursor: pointer; }

/* --- formularze --------------------------------------------------------------------- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--hint); margin: 0 0 5px 2px; font-weight: 600; }
.input, textarea.input, select.input {
  width: 100%; border: 1px solid var(--sep); border-radius: 12px; padding: 11px 12px; background: var(--bg); outline: none;
}
.input:focus { border-color: var(--btn); }
textarea.input { resize: vertical; min-height: 90px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.item-box { border: 1px solid var(--sep); border-radius: 14px; padding: 12px 12px 2px; margin-bottom: 10px; position: relative; }
.item-box .remove { position: absolute; right: 6px; top: 4px; }
.sticky-save { position: sticky; bottom: calc(var(--tab-h) + var(--safe-b) + 8px); z-index: 5; margin-top: 6px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 2px 12px; }
.switch input { width: 46px; height: 26px; appearance: none; -webkit-appearance: none; border-radius: 99px; background: var(--sep); position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch input::after { content: ""; position: absolute; width: 22px; height: 22px; top: 2px; left: 2px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked { background: var(--btn); }
.switch input:checked::after { left: 22px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg2); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 12px; }
.seg button { border: 0; border-radius: 9px; padding: 8px 6px; background: none; font-weight: 600; font-size: 13.5px; color: var(--hint); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.palette { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.palette button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.palette button.on { border-color: var(--text); }

/* --- kalendarz ----------------------------------------------------------------------- */
.cal-head { display: flex; align-items: center; gap: 6px; margin: 4px 4px 12px; }
.cal-head h1 { margin: 0; font-size: 22px; flex: 1; text-transform: capitalize; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 0; background: var(--card); cursor: pointer; display: grid; place-items: center; font-size: 18px; color: var(--text); }
.cal { background: var(--card); border-radius: var(--radius); padding: 8px 6px 6px; margin-bottom: 12px; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11.5px; font-weight: 700; color: var(--hint); padding-bottom: 6px; text-transform: uppercase; }
.cal-week { position: relative; border-top: 1px solid var(--sep); }
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-day { text-align: center; font-size: 13px; padding: 5px 0 0; height: 100%; }
.cal-day .n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; }
.cal-day.out { color: color-mix(in srgb, var(--hint) 60%, transparent); }
.cal-day.wknd .n { color: var(--danger); opacity: .8; }
.cal-day.today .n { background: var(--btn); color: var(--btn-text); font-weight: 700; opacity: 1; }
.cal-bars { position: absolute; left: 0; right: 0; top: 32px; }
.cal-bar {
  position: absolute; height: 17px; border-radius: 6px; color: #fff; font-size: 11px; font-weight: 650; line-height: 17px;
  padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; border: 0; text-align: left;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.cal-bar.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-bar.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-more { position: absolute; font-size: 10.5px; color: var(--hint); font-weight: 700; text-align: center; }
.legend-item { display: flex; gap: 12px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--sep); cursor: pointer; }
.legend-item:last-child { border-bottom: 0; }
.dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }

/* --- projekty --------------------------------------------------------------------------- */
.p-card { position: relative; background: var(--card); border-radius: var(--radius); padding: 14px 14px 14px 20px; margin-bottom: 10px; cursor: pointer; overflow: hidden; }
.p-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--pc, var(--btn)); }
.p-card h2 { margin: 0 0 4px; font-size: 16.5px; line-height: 1.3; }
.p-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--hint); font-size: 13px; margin-top: 6px; }
.p-desc { margin: 6px 0 0; font-size: 14px; color: color-mix(in srgb, var(--text) 82%, transparent); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.p-hero { border-radius: 20px; padding: 18px; margin-bottom: 12px; color: #fff; background: var(--pc, var(--btn)); position: relative; overflow: hidden; }
.p-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(140deg, rgba(0,0,0,0) 30%, rgba(0,0,0,.28)); pointer-events: none; }
.p-hero > * { position: relative; z-index: 1; }
.p-hero h1 { margin: 6px 0 8px; font-size: 21px; line-height: 1.25; }
.p-hero .chip { background: rgba(255,255,255,.22); color: #fff; }
.p-hero .meta { font-size: 14px; opacity: .92; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kv .card { margin: 0; }
.kv .v { font-size: 17px; font-weight: 700; margin-top: 2px; }
.person { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--sep); }
.person:last-child { border-bottom: 0; }
.notice { border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; background: color-mix(in srgb, var(--btn) 10%, transparent); }
.notice.ok { background: color-mix(in srgb, var(--free) 13%, transparent); }
.notice.warn { background: color-mix(in srgb, var(--busy) 14%, transparent); }
details summary { cursor: pointer; color: var(--link); font-weight: 600; }

/* --- arkusz i powiadomienia ---------------------------------------------------------- */
#sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.42); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
#sheet .panel { width: 100%; max-width: 720px; background: var(--bg); border-radius: 20px 20px 0 0; padding: 10px 16px calc(18px + var(--safe-b)); animation: up .2s ease; max-height: 88vh; overflow: auto; }
#sheet .grab { width: 38px; height: 5px; border-radius: 9px; background: var(--sep); margin: 0 auto 12px; }
#sheet h2 { margin: 0 0 12px; font-size: 18px; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + var(--safe-b) + 14px); z-index: 50; background: #1e2a3b; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 90vw; }
.lock { text-align: center; padding: 60px 20px; }
.lock .ic { font-size: 44px; margin-bottom: 10px; }
.lock h1 { font-size: 21px; margin: 0 0 8px; }
