/* Нічна майстерня: темний теплий фон, бурштиновий акцент. Без градієнтів і неону. */
:root {
  --bg: #15120e;
  --surface: #1e1914;
  --surface-2: #29221a;
  --line: #3a3128;
  --text: #efe6d8;
  --muted: #a1937f;
  --amber: #e8a33d;
  --amber-ink: #1a1307;      /* текст на бурштиновому */
  --red: #d9644a;
  /* кольори статусів */
  --st-active: #e8a33d;
  --st-idea: #8f8370;
  --st-paused: #6f7c88;
  --st-done: #7fa76a;
  --radius: 14px;
  --head: "Montserrat", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--body);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--head); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 700; line-height: 1.2; }
[hidden] { display: none !important; }

.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}
.eyebrow {
  margin: 0 0 2px;
  font: 600 11px/1.3 var(--head);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
}
.muted { color: var(--muted); margin: 4px 0 0; }

/* ---------- головний екран ---------- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}
.counter {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font: 600 13px var(--head);
  color: var(--muted);
  white-space: nowrap;
}
.counter.full { border-color: var(--amber); color: var(--amber); }

.filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 0 -16px 16px;
  padding: 0 16px 2px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.chip .n { margin-left: 4px; opacity: 0.7; }

.cards { display: grid; gap: 10px; }
.card {
  display: block;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.card:active { background: var(--surface-2); }
.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-name { flex: 1; min-width: 0; font: 600 16px/1.3 var(--head); overflow-wrap: break-word; }
.badge {
  flex: none;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
}
.badge.client { border-color: #5a4a33; color: #d9b97f; }
.dot { flex: none; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--st-idea); }
.dot.active { background: var(--st-active); }
.dot.paused { background: var(--st-paused); }
.dot.done { background: var(--st-done); }

.progress-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--amber); border-radius: 3px; transition: width 0.3s; }
.pct { min-width: 38px; text-align: right; font: 600 14px var(--head); }
.card-foot { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.overdue { color: var(--red); }
.empty { padding: 32px 8px; text-align: center; color: var(--muted); }

/* ---------- екран проєкту ---------- */
.project-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  align-items: start;
  margin-bottom: 20px;
}
.back {
  width: 44px; height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 20px;
  cursor: pointer;
}
.project-title { min-width: 0; }
.project-title h1 { overflow-wrap: break-word; }
/* % і статус — окремим рядком під назвою, щоб на 320px назві вистачало місця */
.project-meta {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.big-pct { font: 700 26px/1 var(--head); color: var(--amber); }
.project-head .bar { grid-column: 1 / -1; margin-top: 8px; }
.deadline { grid-column: 1 / -1; margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.deadline:empty { display: none; }
.pill {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.pill::after { content: " ▾"; color: var(--muted); }

.group { margin-bottom: 18px; }
.group-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 44px;
  margin: 0 0 2px;
  padding: 0;
  border: 0;
  background: none;
  font: 600 12px var(--head);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}
button.group-title { cursor: pointer; }
.task {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  margin-bottom: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.task:active { background: var(--surface-2); }
.task .icon { flex: none; width: 22px; text-align: center; }
.task .title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.task.done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.task .note { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); white-space: pre-line; }

.btn {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.btn:disabled { opacity: 0.5; }
.wide { display: block; width: 100%; }

.section-title {
  margin: 28px 0 10px;
  font: 600 12px var(--head);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.events { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.events li { position: relative; padding: 0 0 12px 16px; font-size: 14px; }
.events li::before {
  content: "";
  position: absolute; left: -4px; top: 7px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--line);
}
.events time { display: block; font-size: 12px; color: var(--muted); }

/* ---------- шторка ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(8, 6, 4, 0.6); z-index: 10; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 11;
  max-width: 640px;
  max-height: 85vh;
  margin: 0 auto;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
}
.sheet h3 { margin-bottom: 14px; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.sheet p { margin: -6px 0 14px; color: var(--muted); }
.sheet .options { display: grid; gap: 8px; }
.sheet .option { display: flex; align-items: center; gap: 10px; text-align: left; font-weight: 500; }
.sheet .option.current { border-color: var(--amber); }
.sheet input {
  width: 100%;
  min-height: 48px;
  margin-bottom: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;   /* 16px — щоб iOS не збільшував сторінку при фокусі */
}
.sheet input:focus { outline: none; border-color: var(--amber); }
.sheet .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed;
  left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  text-align: center;
}

.message { display: grid; place-items: center; min-height: 80vh; text-align: center; color: var(--muted); }


/* ---------- схема зв'язків ---------- */
.top-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.graph-btn { min-height: 40px; }
.screen-wide { max-width: none; }
.graph-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: -4px 0 12px; font-size: 13px; color: var(--muted); }
.legend .lg { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; border: 2px solid var(--line); }
.legend .lg.doing { border-color: var(--amber); }
.legend .lg.plan { border-color: var(--muted); }
.legend .lg.done { border-color: var(--st-done); background: var(--st-done); }
.graph-wrap {
  overflow: auto;
  margin: 0 -16px;
  padding: 0 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  max-height: calc(100vh - 210px);
}
.graph-canvas { position: relative; }
.graph-canvas svg { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.edge { fill: none; stroke: var(--line); stroke-width: 1.6; }
.edge.open { stroke: var(--amber); stroke-opacity: 0.75; }
.edge.done { stroke: var(--st-done); stroke-opacity: 0.45; }
.gnode {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 6px 10px;
  text-align: left;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.gnode:active { background: var(--surface-2); }
.gnode.doing { border-color: var(--amber); }
.gnode.plan { border-color: #5b5042; }
.gnode.paused { border-style: dashed; }
.gnode.done { border-color: #3f5236; opacity: 0.6; }
.gnode.blocked { opacity: 0.75; }
.gnode .gp { display: flex; align-items: center; gap: 5px; font-size: 11px; line-height: 1.2; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gnode .gp i { flex: none; width: 7px; height: 7px; border-radius: 50%; }
.gnode .gt { font-size: 13px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gnode.done .gt { text-decoration: line-through; }
.hint { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

/* зв'язки в шторці задачі */
.deps { display: grid; gap: 6px; margin: 14px 0 10px; }
.deps-title { margin: 14px 0 6px !important; font: 600 13px var(--head); color: var(--muted) !important; }
.dep { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 4px 4px 12px;
  border: 1px solid var(--line); border-radius: 10px; }
.dep .t { flex: 1; min-width: 0; font-size: 14px; }
.dep .t small { display: block; color: var(--muted); font-size: 12px; }
.dep .x { flex: none; width: 40px; height: 40px; border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.picker { display: grid; gap: 6px; max-height: 50vh; overflow-y: auto; margin-top: 10px; }
.picker .ph { margin: 8px 0 2px; font: 600 12px var(--head); color: var(--amber); letter-spacing: 0.04em; }
.task .lock { flex: none; }
.edge.tip { stroke: none; }
.edge.open.tip { fill: var(--amber); }
.edge.done.tip { fill: var(--st-done); fill-opacity: 0.6; }
