:root {
  --cream: #faf9f5;
  --paper: #f3f1ea;
  --navy: #1c2b56;
  --navy-dark: #14203f;
  --accent: #3454a8;
  --ink: #23262b;
  --muted: #7a7c74;
  --line: #e4e0d4;
  --ok: #2f7d4f;
  --warn: #a9782f;
  --danger: #b3402f;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  height: 100%;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  position: relative;
}

/* ---------- header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 3px solid var(--navy);
  background: var(--cream);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 15px;
  color: var(--navy);
}

.brand svg { width: 22px; height: 22px; }

.status-pill {
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
}

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger);
}
.status-dot.online { background: var(--ok); }

/* ---------- views ---------- */

.view { display: none; flex: 1; flex-direction: column; padding-bottom: 84px; }
.view.active { display: flex; }

/* ---------- Rozmowa: hero / idle ---------- */

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 48px 28px 32px;
  gap: 14px;
  position: relative;
  background: url("toile-bg.jpg") center bottom / cover no-repeat, var(--cream);
  min-height: 600px;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, var(--cream) 0%, var(--cream) 58%, rgba(250,249,245,0.7) 72%, rgba(250,249,245,0.15) 88%, rgba(250,249,245,0) 100%);
  pointer-events: none;
}

.hero > * { position: relative; z-index: 1; }

.hero #start-convo { margin-top: auto; }

.hero .big-btn, .hero .link-btn { box-shadow: 0 2px 10px rgba(20,32,63,0.12); }
.hero .link-btn { background: rgba(255,255,255,0.92); }

.hero h1 {
  font-size: 28px;
  margin: 0;
  line-height: 1.25;
  color: var(--navy);
}
.hero h1 em { color: var(--accent); font-style: italic; }

.hero p { color: var(--muted); margin: 0; font-size: 15px; line-height: 1.5; max-width: 320px; }

.big-btn {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 600;
  width: 100%;
  max-width: 300px;
  cursor: pointer;
}
.big-btn:active { background: var(--navy-dark); }

.link-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 20px;
  color: var(--navy);
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  max-width: 300px;
}

/* ---------- Rozmowa: active conversation ---------- */

.convo { flex: 1; display: flex; flex-direction: column; }

.convo-project {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.convo-project b { color: var(--ink); text-transform: none; letter-spacing: normal; font-size: 14px; }
.convo-project button {
  background: none; border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 10px; font-size: 12px; color: var(--navy); cursor: pointer;
}

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 8px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.45;
  max-width: 88%;
}
.bubble.user {
  background: var(--paper);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.bubble.agent {
  background: transparent;
  align-self: flex-start;
  color: var(--ink);
  padding-left: 0;
  display: flex;
  gap: 8px;
}
.bubble.agent .dot {
  flex: none;
  width: 18px; height: 18px; margin-top: 3px;
  border-radius: 50%;
  border: 2px solid var(--accent);
}

.mic-dock {
  padding: 18px 18px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
  background: linear-gradient(to bottom, rgba(250,249,245,0.75), rgba(250,249,245,0.92) 40%), url("toile-bg.jpg") center bottom / cover no-repeat;
}

.mic-btn {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--navy);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.mic-btn.listening { background: var(--danger); }
.mic-btn.speaking { background: var(--accent); }
.mic-btn svg { width: 26px; height: 26px; }

.mic-state { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.quick-actions {
  display: flex;
  gap: 8px;
  padding: 10px 18px 4px;
}
.quick-actions button {
  flex: 1;
  padding: 12px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  color: var(--navy);
  cursor: pointer;
}
.quick-actions button.primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* ---------- Zadania ---------- */

.list-header { padding: 18px 18px 8px; }
.list-header .eyebrow { font-size: 11px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.list-header h2 { margin: 4px 0 14px; font-size: 24px; color: var(--navy); }
.list-header h2 em { color: var(--accent); font-style: italic; }

.filter-row { display: flex; gap: 6px; padding: 0 18px 12px; }
.filter-row button {
  flex: 1;
  padding: 9px 6px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.filter-row button.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.task-list { padding: 0 18px; display: flex; flex-direction: column; gap: 10px; }

.task-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
}
.task-card .meta { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }
.task-card .title { font-size: 15px; margin-top: 2px; }
.task-card .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.task-card .badge {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); margin-top: 2px;
}
.task-card .badge.review { border-color: var(--accent); }
.task-card .badge.decision { border-color: var(--warn); }
.task-card .badge.merged, .task-card .badge.done { border-color: var(--ok); background: var(--ok); }
.task-card .badge.failed { border-color: var(--danger); }
.task-card .badge.running { border-color: var(--accent); background: repeating-conic-gradient(var(--accent) 0 90deg, transparent 0 360deg); }

.empty { padding: 40px 18px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- Szczegóły zadania ---------- */

.detail-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 4px; }
.detail-header .back { background: none; border: none; color: var(--navy); font-size: 14px; cursor: pointer; padding: 4px 0; }
.detail-header .num { color: var(--muted); font-size: 13px; }

.detail-body { padding: 8px 18px; }
.detail-body .tag { font-size: 11px; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }
.detail-body h2 { margin: 6px 0 8px; font-size: 22px; color: var(--navy); }
.detail-body h2 em { color: var(--accent); font-style: italic; }
.detail-status { font-size: 13px; color: var(--muted); margin-bottom: 16px; display: flex; align-items: center; gap: 6px; }
.detail-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.section-label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.summary-text { font-size: 15px; line-height: 1.5; }

.listen-btn {
  margin-top: 10px;
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 20px;
  padding: 8px 16px; background: #fff; cursor: pointer; font-size: 13px; color: var(--navy);
}
.listen-btn .play-dot {
  width: 24px; height: 24px; border-radius: 50%; background: var(--navy);
  display: flex; align-items: center; justify-content: center;
}
.listen-btn .play-dot svg { width: 10px; height: 10px; fill: #fff; }

.file-row {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid var(--line); font-size: 13px; font-family: ui-monospace, monospace;
}
.file-row .delta { color: var(--muted); }
.file-row .delta .add { color: var(--ok); }
.file-row .delta .rem { color: var(--danger); }

.preview-link {
  margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--navy);
  text-decoration: none;
}

.decision-box {
  margin-top: 12px; border: 1px solid var(--warn); border-radius: 12px; padding: 14px;
  background: #fdf7ec; font-size: 14px;
}

.action-row { display: flex; gap: 8px; padding: 18px; margin-top: auto; }
.action-row button {
  flex: 1; padding: 13px 8px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font-size: 14px; cursor: pointer;
}
.action-row button.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.action-row button.danger { color: var(--danger); border-color: var(--danger); }

/* ---------- Projekty ---------- */

.project-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-bottom: 1px solid var(--line);
}
.project-row input { accent-color: var(--navy); width: 18px; height: 18px; }
.project-row .name { font-size: 16px; font-weight: 600; }
.project-row .sub { font-size: 12px; color: var(--muted); }
.project-row .active-tag { margin-left: auto; font-size: 11px; color: var(--ok); letter-spacing: 0.05em; }

.card {
  margin: 14px 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden;
}

.keyword-section { padding: 16px 18px; }
.keyword-section .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.keyword-section .head span:first-child { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.keyword-section .head button { background: none; border: none; color: var(--accent); font-size: 13px; cursor: pointer; }
.keyword-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.keyword-tags .tag {
  border: 1px solid var(--line); border-radius: 16px; padding: 6px 12px; font-size: 13px;
  display: flex; align-items: center; gap: 6px; background: var(--paper);
}
.keyword-tags .tag button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0; }
.keyword-section .hint { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.4; }

/* ---------- bottom nav ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex;
  background: var(--cream);
  border-top: 1px solid var(--line);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}
.bottom-nav button {
  flex: 1;
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: 11px; padding: 4px 0;
}
.bottom-nav button svg { width: 20px; height: 20px; }
.bottom-nav button.active { color: var(--navy); }

/* ---------- toast ---------- */

#toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.2s;
  max-width: 90%; text-align: center;
}
#toast.show { opacity: 1; }

/* ---------- login gate ---------- */

#gate {
  position: fixed; inset: 0; background: var(--cream); z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 30px;
  overflow: hidden;
}
#gate input {
  width: 100%; max-width: 300px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  font-size: 15px; position: relative; z-index: 1;
}
#gate > *:not(.decor-strip) { position: relative; z-index: 1; }
#gate[hidden] { display: none; }

/* ---------- pasek dekoracyjny (ilustracja z mockupu) ---------- */

.decor-strip {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 220px;
  background:
    linear-gradient(to bottom, var(--cream) 0%, rgba(250,249,245,0.55) 30%, rgba(250,249,245,0) 55%),
    url("toile-bg.jpg") center bottom / cover no-repeat;
  pointer-events: none;
  z-index: 0;
}

.view#view-zadania, .view#view-projekty { position: relative; padding-bottom: calc(220px + 84px); }

@media (max-width: 400px) {
  .hero h1 { font-size: 24px; }
}
