body {
  background: var(--bg-main);
  color: var(--text-main);
  /* Типографика задаётся в tokens.css (Caveat/размеры) */
  font-family: inherit;
}

body.v2-no-scroll {
  overflow: hidden;
}

.v2-mobile-topbar,
.v2-fab-yuli,
.v2-mobile-backdrop,
.v2-app-header,
.v2-yuli-sheet__header {
  display: none;
}

.v2-app-shell {
  display: grid;
  grid-template-columns: 60% 40%;
  min-height: 100vh;
}

.v2-left, .v2-center, .v2-right {
  padding: 10px;
}

.v2-left, .v2-right {
  background: var(--bg-surface);
}

/* Desktop header */
@media (min-width: 768px) {
  .v2-app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-surface);
    border-bottom: 1px solid rgba(0, 0, 0, .08);
    position: sticky;
    top: 0;
    z-index: 1300;
  }

  /* Dashboard header: make it shorter (do not touch logo/search) */
  .v2-app-shell .v2-app-header {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
    min-height: 36px !important;
    gap: 8px !important;
  }

  .v2-app-shell .v2-app-header__nav {
    gap: 8px !important;
  }
  .v2-app-shell .v2-app-header__nav .v2-nav-link {
    font-family: "Caveat", cursive !important;
    font-weight: 600 !important;
    font-size: 18px !important;
  }

  /* /app/*: ultra-specific override for nav buttons only */
  .v2-app-shell .v2-app-header .v2-app-header__nav a.v2-nav-link.v2-nav-link {
    font-size: 18px !important;
    font-family: "Caveat", cursive !important;
    font-weight: 600 !important;
  }

  /* Username on the right: same as nav (do not touch the icon button) */
  .v2-app-header .v2-user__name {
    font-family: "Caveat", cursive !important;
    font-weight: 600 !important;
    font-size: 1.3rem !important;
    line-height: 1 !important;
  }
  .v2-app-header .v2-user__toggle {
    gap: 0.5rem !important;
    padding-top: 0.2rem !important;
    padding-bottom: 0.2rem !important;
  }

  .v2-brand {
    font-family: "Caveat", cursive;
    font-weight: 700;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
  }
  .v2-brand:hover { text-decoration: underline; }

  /* /app/*: exact sizes */
  .v2-app-shell .v2-app-header .v2-brand {
    font-family: "Caveat", cursive !important;
    font-weight: 700 !important;
    font-size: 24px !important;
  }

  .v2-app-header__nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: center;
  }
  .v2-nav-link {
    color: var(--text);
    text-decoration: none;
    padding: 6px 8px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1rem;
  }
  .v2-nav-link:hover {
    background: rgba(0, 0, 0, .04);
  }
  .v2-nav-link.is-active {
    background: rgba(194, 73, 53, 0.10);
    color: var(--accent-dark);
  }

  .v2-app-header__right {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .v2-icon-btn {
    border: 1px solid rgba(31, 47, 42, 0.18);
    background: #fff;
    border-radius: 10px;
    min-height: 38px;
    padding: 0 10px;
    font-size: 18px;
    cursor: pointer;
  }

  .v2-search { position: relative; }
  .v2-search__field {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: min(520px, 56vw);
    background: var(--bg-surface);
    border: 1px solid rgba(0, 0, 0, .10);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 10px 24px rgba(0,0,0,.14);
    z-index: 1400;
  }
  .v2-search__results {
    position: relative;
    margin-top: 8px;
    max-height: 340px;
    overflow: auto;
  }

  .v2-user { position: relative; }
  .v2-user__toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(31, 47, 42, 0.18);
    background: #fff;
    border-radius: 999px;
    padding: 6px 10px 6px 6px;
    cursor: pointer;
  }
  .v2-user__avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(194, 73, 53, 0.14);
    color: var(--accent-dark);
    font-weight: 700;
  }
  .v2-user__name {
    color: var(--text);
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .v2-user__dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 180px;
    background: var(--bg-surface);
    border: 1px solid rgba(0, 0, 0, .10);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 10px 24px rgba(0,0,0,.14);
    z-index: 1400;
  }

  /* Left sidebar is removed on desktop/tablet; still used on mobile (fixed sheet). */
  .v2-left {
    display: none;
  }

  .v2-app-shell {
    min-height: calc(100vh - 56px);
  }
}

[data-v2-panel] {
  opacity: 1;
  transition: opacity .22s ease;
}

[data-v2-panel].is-hidden-fade {
  opacity: 0;
}

/* Steps tree (project page): remove default list markers */
.task-tree {
  list-style: none;
  margin: 0;
  padding-left: 0;
}
.task-tree li,
.task-node {
  list-style: none;
}
.task-tree li::marker,
.task-node::marker {
  content: "";
}
.task-tree .task-tree {
  padding-left: 18px;
  border-left: 2px solid rgba(194, 73, 53, 0.22);
  margin-left: 10px;
}
.task-node {
  list-style: none;
  margin: 6px 0;
}

/* Steps panel: ограничиваем высоту и даём прокрутку, чтобы блок не рос бесконечно */
.v2-steps-panel .card-body {
  max-height: 60vh;
  overflow: auto;
}

/* Dashboard: project card titles larger + handwritten */
.project-grid .project-card-sk .card-title,
.project-grid .project-card-sk .card-title a {
  font-family: "Caveat", cursive !important;
  font-size: 1.7rem !important;
  font-weight: 600;
  line-height: 1.05;
}

@media (min-width: 768px) and (max-width: 1200px) {
  .v2-app-shell {
    grid-template-columns: 1fr;
  }
  .v2-right {
    position: fixed;
    right: 8px;
    top: 8px;
    bottom: 8px;
    width: min(420px, 44vw);
    z-index: 1200;
    transform: translateX(110%);
    transition: transform .25s ease;
    box-shadow: 0 10px 24px rgba(0,0,0,.18);
    border-radius: 12px;
  }
  .v2-right.open {
    transform: translateX(0);
  }
  .v2-fab-yuli {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 54px;
    height: 54px;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,.12);
    background: var(--accent-thread);
    color: #fff;
    z-index: 1210;
    font-size: 24px;
    box-shadow: 0 8px 20px rgba(0,0,0,.22);
  }
}

@media (max-width: 768px) {
  .v2-mobile-topbar {
    display: grid;
    grid-template-columns: 48px 1fr 48px;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
    background: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 1300;
  }
  .v2-mobile-topbar__btn {
    border: 1px solid rgba(31, 47, 42, 0.22);
    border-radius: 10px;
    background: #fff;
    min-height: 40px;
    font-size: 18px;
  }
  .v2-mobile-topbar__title {
    text-align: center;
    font-family: var(--font-title);
    font-size: 0.95rem;
    line-height: 1.2;
  }

  .v2-mobile-backdrop {
    /* Backdrop должен появляться только когда JS снимает атрибут hidden.
       Иначе он перекрывает весь экран, затемняет контент и блокирует клики. */
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 1190;
  }
  .v2-mobile-backdrop:not([hidden]) {
    display: block;
  }

  .v2-app-shell {
    display: block;
    min-height: calc(100vh - 56px);
  }
  .v2-left,
  .v2-center,
  .v2-right {
    padding: 12px;
  }

  .v2-left {
    display: block;
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    z-index: 1200;
    transform: translateX(-110%);
    transition: transform .25s ease;
    overflow: auto;
    box-shadow: 8px 0 24px rgba(0,0,0,.2);
  }
  .v2-left.open {
    transform: translateX(0);
  }

  .v2-center {
    width: 100%;
  }

  .v2-right {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: min(84vh, 680px);
    z-index: 1200;
    transform: translateY(110%);
    transition: transform .25s ease;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -10px 24px rgba(0,0,0,.24);
    overflow: hidden;
    min-height: 0;
  }
  #v2-yuli-sheet .v2-yuli-sheet__header {
    flex-shrink: 0;
  }
  #v2-yuli-sheet > .v2-yuli {
    flex: 1 1 auto;
    min-height: 0;
  }
  .v2-right.open {
    transform: translateY(0);
  }
  .v2-yuli-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(31, 47, 42, .12);
    margin-bottom: 8px;
    background: var(--bg-surface);
  }
  .v2-fab-yuli {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 56px;
    height: 56px;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,.12);
    background: var(--accent-thread);
    color: #fff;
    font-size: 24px;
    z-index: 1210;
    box-shadow: 0 8px 20px rgba(0,0,0,.22);
  }
}

/* Minimal utility/grid compatibility for migrated templates */
.container { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.row > [class*="col-"] { padding: 0 8px; width: 100%; }
.col-md-6, .col-lg-6, .col-lg-4, .col-lg-8, .col-lg-3 { width: 100%; }
@media (min-width: 768px) {
  .col-md-6 { width: 50%; }
}
@media (min-width: 992px) {
  .col-lg-3 { width: 25%; }
  .col-lg-4 { width: 33.3333%; }
  .col-lg-6 { width: 50%; }
  .col-lg-8 { width: 66.6666%; }
}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:1rem}.mb-4{margin-bottom:1.5rem}.mb-5{margin-bottom:2rem}
.mt-0{margin-top:0}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:1rem}.mt-4{margin-top:1.5rem}.mt-5{margin-top:2rem}
.py-4{padding-top:1.5rem;padding-bottom:1.5rem}.py-5{padding-top:2rem;padding-bottom:2rem}
.small{font-size:.875rem}.text-center{text-align:center}.text-start{text-align:left}
.d-inline{display:inline}.d-inline-block{display:inline-block}.d-block{display:block}
.flex{display:flex}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:.25rem}.gap-2{gap:.5rem}.gap-3{gap:1rem}
.w-100{width:100%}.h-100{height:100%}.min-h-screen{min-height:100vh}
