:root {
      --bg0: #dfe5df;
      --bg1: #cfd8d2;
      --panel: #f5f7f4;
      --panel-2: #eef1ec;
      --ink: #121714;
      --ink-soft: #3d4741;
      --muted: #6a756e;
      --line: #c9d2cb;
      --line-strong: #a8b5ad;
      --pine: #17604f;
      --pine-deep: #0e3f34;
      --pine-soft: #d4ebe3;
      --amber: #8a5a12;
      --amber-soft: #f0e2c4;
      --rose: #8f3d3d;
      --me: #dceee7;
      --agent: #ebefe9;
      --focus: #17604f;
      --radius: 14px;
      --radius-sm: 9px;
      --font: "Manrope", system-ui, sans-serif;
      --display: "Fraunces", Georgia, serif;
      --mono: "JetBrains Mono", ui-monospace, monospace;
      --shadow: 0 18px 40px rgba(18, 23, 20, 0.08);
      --inset: inset 0 1px 0 rgba(255, 255, 255, 0.65);
    }

    * { box-sizing: border-box; }
    html, body { height: 100%; }
    body {
      margin: 0;
      font-family: var(--font);
      color: var(--ink);
      background:
        radial-gradient(900px 520px at 8% -8%, #e8f0ea 0%, transparent 55%),
        radial-gradient(800px 480px at 92% 0%, #d7e0d9 0%, transparent 50%),
        linear-gradient(165deg, var(--bg0), var(--bg1));
      -webkit-font-smoothing: antialiased;
    }

    button, textarea { font: inherit; color: inherit; }
    button { cursor: pointer; }
    :focus-visible {
      outline: 2px solid var(--focus);
      outline-offset: 2px;
    }

    .app {
      height: 100%;
      max-width: 1440px;
      margin: 0 auto;
      padding: 16px;
      display: grid;
      grid-template-rows: auto 1fr;
      gap: 14px;
    }

    /* ——— top bar ——— */
    .top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      padding: 12px 16px;
      background: color-mix(in srgb, var(--panel) 88%, white);
      border: 1px solid var(--line);
      border-radius: calc(var(--radius) + 2px);
      box-shadow: var(--shadow), var(--inset);
      backdrop-filter: blur(10px);
      animation: rise 480ms ease both;
    }
    .brand {
      display: flex;
      align-items: center;
      gap: 12px;
      min-width: 0;
    }
    .mark {
      width: 36px;
      height: 36px;
      border-radius: 11px;
      background:
        linear-gradient(145deg, var(--pine) 0%, var(--pine-deep) 100%);
      color: #eef7f3;
      display: grid;
      place-items: center;
      font-family: var(--display);
      font-weight: 650;
      font-size: 1.05rem;
      letter-spacing: -0.04em;
      box-shadow: 0 8px 18px rgba(14, 63, 52, 0.28);
      flex: none;
    }
    .brand-text { min-width: 0; }
    .brand-text strong {
      display: block;
      font-family: var(--display);
      font-weight: 650;
      font-size: 1.2rem;
      letter-spacing: -0.03em;
      line-height: 1.1;
    }
    .brand-text span {
      color: var(--muted);
      font-size: 0.82rem;
    }
    .top-meta {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }
    .pill {
      font-family: var(--mono);
      font-size: 0.7rem;
      padding: 6px 10px;
      border-radius: 999px;
      border: 1px solid var(--line);
      background: var(--panel-2);
      color: var(--ink-soft);
    }
    .pill.live {
      background: var(--pine-soft);
      border-color: color-mix(in srgb, var(--pine) 25%, var(--line));
      color: var(--pine-deep);
    }
    .pill.warn {
      background: var(--amber-soft);
      border-color: color-mix(in srgb, var(--amber) 30%, var(--line));
      color: var(--amber);
    }

    .tabs {
      display: flex;
      gap: 6px;
      padding: 4px;
      border-radius: 999px;
      background: var(--panel-2);
      border: 1px solid var(--line);
    }
    .tab {
      border: 0;
      background: transparent;
      padding: 7px 14px;
      border-radius: 999px;
      font-size: 0.86rem;
      font-weight: 600;
      color: var(--muted);
    }
    .tab.active {
      background: var(--pine);
      color: #eef7f3;
    }

    .view.home {
      min-height: 0;
      display: grid;
      grid-template-rows: auto auto 1fr;
      gap: 14px;
      animation: rise 480ms ease both;
    }
    .view.home[hidden],
    .view.work[hidden] { display: none !important; }

    .stats {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
      gap: 10px;
    }
    .stat {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      padding: 14px 16px;
      box-shadow: var(--shadow), var(--inset);
    }
    .stat .label {
      font-size: 0.7rem;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--muted);
      font-weight: 700;
    }
    .stat .value {
      font-family: var(--display);
      font-size: 1.55rem;
      font-weight: 650;
      margin-top: 4px;
      color: var(--ink);
    }

    .home-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      flex-wrap: wrap;
    }
    .home-toolbar h2 {
      margin: 0;
      font-family: var(--display);
      font-size: 1.25rem;
      font-weight: 650;
    }
    .filters { display: flex; gap: 6px; flex-wrap: wrap; }
    .chip-btn {
      border: 1px solid var(--line);
      background: var(--panel);
      border-radius: 999px;
      padding: 6px 12px;
      font-size: 0.8rem;
      color: var(--ink-soft);
    }
    .chip-btn.active {
      background: var(--pine-soft);
      border-color: color-mix(in srgb, var(--pine) 30%, var(--line));
      color: var(--pine-deep);
      font-weight: 650;
    }

    .board {
      min-height: 0;
      overflow: auto;
      display: grid;
      gap: 14px;
      padding-bottom: 8px;
    }
    .group {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow), var(--inset);
      overflow: hidden;
    }
    .group-head {
      display: flex;
      justify-content: space-between;
      gap: 10px;
      padding: 12px 16px;
      border-bottom: 1px solid var(--line);
      background: linear-gradient(180deg, #fafbf8, var(--panel));
    }
    .group-head strong {
      font-family: var(--display);
      font-size: 1.05rem;
    }
    .group-head span {
      font-family: var(--mono);
      font-size: 0.75rem;
      color: var(--muted);
    }
    .group-tasks { display: grid; }
    .board-task {
      width: 100%;
      text-align: left;
      border: 0;
      border-bottom: 1px solid var(--line);
      background: transparent;
      padding: 12px 16px;
      display: grid;
      gap: 4px;
    }
    .board-task:last-child { border-bottom: 0; }
    .board-task:hover { background: #eef5f1; }
    .board-task .name { font-weight: 650; }
    .board-task .sub { color: var(--muted); font-size: 0.86rem; }
    .board-task .meta {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-top: 4px;
    }

    .estimate-row {
      display: flex;
      align-items: end;
      gap: 8px;
      margin: 0 0 10px;
    }
    .estimate-row label {
      display: grid;
      gap: 4px;
      font-size: 0.72rem;
      font-weight: 650;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      color: var(--muted);
    }
    .estimate-row input {
      width: 96px;
      border: 1px solid var(--line);
      border-radius: var(--radius-sm);
      padding: 8px 10px;
      font: inherit;
      background: #fff;
    }
    .files-block { margin-bottom: 12px; }
    .files-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 6px;
      font-size: 0.72rem;
      font-weight: 650;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      color: var(--muted);
    }
    .file-btn { display: inline-flex; align-items: center; }
    .files {
      list-style: none;
      margin: 0;
      padding: 0;
      display: grid;
      gap: 4px;
    }
    .files:empty::after {
      content: "Нет файлов";
      color: var(--muted);
      font-size: 0.82rem;
    }
    .files a {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      padding: 7px 10px;
      border-radius: var(--radius-sm);
      background: var(--panel-2);
      color: var(--pine-deep);
      text-decoration: none;
      font-size: 0.86rem;
    }
    .files a:hover { background: var(--pine-soft); }

    /* ——— shell ——— */
    .shell {
      min-height: 0;
      display: grid;
      grid-template-columns: 240px 320px minmax(0, 1fr);
      gap: 14px;
      animation: rise 560ms 60ms ease both;
    }

    .col {
      min-height: 0;
      display: flex;
      flex-direction: column;
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow), var(--inset);
      overflow: hidden;
    }

    .col-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding: 14px 16px 12px;
      border-bottom: 1px solid var(--line);
      background: linear-gradient(180deg, #fafbf8, var(--panel));
    }
    .col-actions {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .col-head h2 {
      margin: 0;
      font-size: 0.72rem;
      font-weight: 700;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--muted);
    }
    .count {
      font-family: var(--mono);
      font-size: 0.68rem;
      color: var(--pine-deep);
      background: var(--pine-soft);
      padding: 3px 7px;
      border-radius: 999px;
    }
    .btn.small {
      padding: 5px 10px;
      font-size: 0.78rem;
    }

    .new-task {
      display: grid;
      gap: 10px;
      padding: 12px 14px;
      border-bottom: 1px solid var(--line);
      background: var(--panel-2);
      animation: rise 280ms ease both;
    }
    .new-task[hidden] { display: none; }
    .field {
      display: grid;
      gap: 5px;
    }
    .field > span {
      font-size: 0.72rem;
      font-weight: 650;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      color: var(--muted);
    }
    .field input,
    .field textarea,
    .subtask-inputs input {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: var(--radius-sm);
      background: #fff;
      padding: 9px 11px;
      font: inherit;
      color: inherit;
    }
    .field textarea { resize: vertical; min-height: 72px; }
    .subtask-inputs {
      display: grid;
      gap: 6px;
      margin-bottom: 8px;
    }
    .new-task-actions {
      display: flex;
      justify-content: flex-end;
      gap: 8px;
    }

    .subtasks {
      list-style: none;
      margin: 0 0 10px;
      padding: 0;
      display: grid;
      gap: 6px;
    }
    .subtasks[hidden] { display: none; }
    .subtasks li {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      font-size: 0.88rem;
      color: var(--ink-soft);
      padding: 6px 10px;
      border-radius: var(--radius-sm);
      background: var(--panel-2);
      border: 1px solid transparent;
    }
    .subtasks li.done {
      color: var(--muted);
      text-decoration: line-through;
    }
    .subtasks .tick {
      width: 14px;
      height: 14px;
      margin-top: 2px;
      border-radius: 4px;
      border: 1.5px solid var(--line-strong);
      flex: 0 0 auto;
      background: transparent;
    }
    .subtasks li.done .tick {
      background: var(--pine);
      border-color: var(--pine);
    }

    .scroll {
      flex: 1;
      overflow: auto;
      padding: 10px;
      scrollbar-width: thin;
      scrollbar-color: var(--line-strong) transparent;
    }

    .nav-item,
    .task-item {
      width: 100%;
      text-align: left;
      border: 1px solid transparent;
      background: transparent;
      border-radius: var(--radius-sm);
      padding: 11px 12px;
      display: grid;
      gap: 3px;
      transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
    }
    .nav-item:hover,
    .task-item:hover {
      background: var(--panel-2);
      border-color: color-mix(in srgb, var(--line) 80%, transparent);
    }
    .nav-item.active,
    .task-item.active {
      background: var(--pine-soft);
      border-color: color-mix(in srgb, var(--pine) 28%, var(--line));
    }
    .nav-item .name,
    .task-item .name {
      font-weight: 650;
      font-size: 0.95rem;
      letter-spacing: -0.01em;
    }
    .nav-item .sub,
    .task-item .sub {
      color: var(--muted);
      font-size: 0.8rem;
      line-height: 1.35;
    }
    .task-item .sub {
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }
    .task-meta {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      margin-top: 6px;
    }
    .chip {
      font-family: var(--mono);
      font-size: 0.66rem;
      padding: 3px 7px;
      border-radius: 999px;
      background: #e4e9e4;
      color: var(--ink-soft);
    }
    .chip.pending { background: var(--amber-soft); color: var(--amber); }
    .chip.active { background: var(--pine-soft); color: var(--pine-deep); }
    .chip.done { background: #e2e6e2; color: var(--muted); }

    /* ——— chat ——— */
    .chat-head {
      padding: 16px 18px 14px;
      border-bottom: 1px solid var(--line);
      background:
        linear-gradient(135deg, color-mix(in srgb, var(--pine-soft) 55%, white), transparent 55%),
        linear-gradient(180deg, #fafbf8, var(--panel));
    }
    .chat-kicker {
      font-family: var(--mono);
      font-size: 0.68rem;
      color: var(--pine);
      margin-bottom: 6px;
    }
    .chat-head h1 {
      margin: 0 0 6px;
      font-family: var(--display);
      font-weight: 650;
      font-size: clamp(1.15rem, 1.6vw, 1.45rem);
      letter-spacing: -0.03em;
      line-height: 1.15;
    }
    .chat-head .lead {
      margin: 0;
      color: var(--ink-soft);
      font-size: 0.92rem;
      line-height: 1.45;
      max-width: 62ch;
    }
    .toolbar {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 14px;
    }
    .btn {
      border: 1px solid var(--line-strong);
      background: #fff;
      border-radius: 999px;
      padding: 8px 14px;
      font-size: 0.84rem;
      font-weight: 600;
      transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
    }
    .btn:hover:not(:disabled) {
      transform: translateY(-1px);
      background: var(--panel-2);
    }
    .btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
    .btn.primary {
      background: var(--pine);
      border-color: var(--pine-deep);
      color: #f3faf7;
    }
    .btn.primary:hover:not(:disabled) {
      background: var(--pine-deep);
    }
    .btn.ghost {
      background: transparent;
    }

    .thread {
      flex: 1;
      overflow: auto;
      padding: 18px;
      display: flex;
      flex-direction: column;
      gap: 12px;
      background:
        linear-gradient(180deg, rgba(223, 229, 223, 0.35), transparent 140px),
        repeating-linear-gradient(
          0deg,
          transparent,
          transparent 27px,
          rgba(18, 23, 20, 0.015) 28px
        );
    }
    .empty {
      margin: auto;
      text-align: center;
      color: var(--muted);
      max-width: 28ch;
      line-height: 1.45;
    }
    .empty strong {
      display: block;
      font-family: var(--display);
      color: var(--ink);
      font-size: 1.15rem;
      margin-bottom: 6px;
    }

    .bubble {
      max-width: min(560px, 92%);
      padding: 12px 14px;
      border-radius: 16px;
      border: 1px solid var(--line);
      line-height: 1.45;
      font-size: 0.93rem;
      animation: pop 220ms ease both;
    }
    .bubble.me {
      align-self: flex-end;
      background: var(--me);
      border-bottom-right-radius: 6px;
      border-color: color-mix(in srgb, var(--pine) 18%, var(--line));
    }
    .bubble.agent {
      align-self: flex-start;
      background: var(--agent);
      border-bottom-left-radius: 6px;
    }
    .bubble .who {
      font-family: var(--mono);
      font-size: 0.66rem;
      color: var(--muted);
      margin-bottom: 5px;
      letter-spacing: 0.02em;
    }

    .composer {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
      padding: 12px;
      border-top: 1px solid var(--line);
      background: color-mix(in srgb, var(--panel) 92%, var(--pine-soft));
    }
    .composer textarea {
      width: 100%;
      min-height: 56px;
      max-height: 160px;
      resize: vertical;
      border: 1px solid var(--line-strong);
      border-radius: 12px;
      padding: 12px 14px;
      background: #fff;
      line-height: 1.4;
    }
    .composer textarea:disabled {
      background: var(--panel-2);
      color: var(--muted);
    }
    .composer .send {
      align-self: end;
      min-width: 108px;
    }

    .hint {
      margin: 0 18px 12px;
      padding: 10px 12px;
      border-radius: 10px;
      border: 1px dashed var(--line-strong);
      background: #f0f3ef;
      color: var(--muted);
      font-size: 0.8rem;
      line-height: 1.4;
    }

    @keyframes rise {
      from { opacity: 0; transform: translateY(8px); }
      to { opacity: 1; transform: none; }
    }
    @keyframes pop {
      from { opacity: 0; transform: translateY(6px) scale(0.98); }
      to { opacity: 1; transform: none; }
    }
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation: none !important;
        transition: none !important;
      }
    }

    @media (max-width: 980px) {
      .top { flex-wrap: wrap; }
      .shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto minmax(420px, 1fr);
      }
      .app { height: auto; min-height: 100%; }
      .col { min-height: 220px; }
    }

    .login-overlay {
      position: fixed;
      inset: 0;
      z-index: 40;
      display: grid;
      place-items: center;
      padding: 24px;
      background: color-mix(in srgb, #121714 42%, transparent);
      backdrop-filter: blur(6px);
    }
    .login-overlay[hidden] { display: none !important; }
    .login-card {
      width: min(100%, 380px);
      padding: 28px 24px;
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      display: grid;
      gap: 14px;
    }
    .login-card h2 {
      margin: 0;
      font-family: var(--display);
      font-weight: 560;
      font-size: 1.55rem;
    }
    .login-lead {
      margin: -4px 0 4px;
      color: var(--muted);
      font-size: 0.92rem;
    }
    .login-error {
      margin: 0;
      color: var(--rose);
      font-size: 0.9rem;
    }
    .login-card .field {
      display: grid;
      gap: 6px;
    }
    .login-card .field span {
      font-size: 0.82rem;
      color: var(--ink-soft);
      font-weight: 600;
    }
    .login-card input {
      width: 100%;
      padding: 10px 12px;
      border: 1px solid var(--line-strong);
      border-radius: var(--radius-sm);
      background: #fff;
      font: inherit;
    }

