:root {
  --paper: #fbf8f1;
  --paper-deep: #f8f4ea;
  --graphite: #2e2e2e;
  --graphite-soft: #5c5c5c;
  --ink: #1f9a55;
  --ink-wash: rgba(31, 154, 85, 0.1);
  --stroke: 1.5px;
  --font: "IBM Plex Sans", sans-serif;
  --shell-pad: clamp(1.25rem, 4vw, 2.25rem);
  --nav-mobile-h: 4.25rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--graphite);
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255, 255, 255, 0.4), transparent 45%),
    radial-gradient(ellipse at 80% 90%, rgba(180, 160, 120, 0.1), transparent 40%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(90, 80, 60, 0.02) 2px,
      rgba(90, 80, 60, 0.02) 3px
    ),
    linear-gradient(165deg, var(--paper), var(--paper-deep));
  line-height: 1.45;
}

.shell {
  --shell-max: 40rem;
  min-height: 100dvh;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: var(--shell-pad);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

@media (min-width: 720px) {
  .shell {
    --shell-max: 52rem;
  }
}

@media (min-width: 960px) {
  .shell {
    --shell-max: 64rem;
  }
}

.load-error {
  margin: 0;
  color: var(--graphite);
  border: var(--stroke) dashed var(--graphite);
  border-radius: 0.55rem;
  padding: 0.75rem 0.9rem;
  background: rgba(255, 255, 255, 0.35);
}

.area {
  display: flex;
  gap: 0.65rem;
}

.area:empty {
  display: none;
}

.area-top,
.area-nav,
.area-bottom {
  flex-wrap: wrap;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border: var(--stroke) solid var(--graphite);
  border-radius: 0.7rem 1.1rem 0.6rem 1rem / 1rem 0.55rem 1.05rem 0.65rem;
  background: rgba(255, 255, 255, 0.4);
}

.area-main {
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
}

.area-main .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.25rem;
}

.area-nav {
  order: 1;
  width: 100%;
}

.area-nav > .nav-logo-link {
  margin-right: auto;
}

.nav-logo-link {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.15rem;
  margin: 0;
  cursor: pointer;
}

.nav-logo-link:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.15rem;
}

.nav-logo-link:focus-visible {
  outline: 2px dashed var(--ink);
  outline-offset: 2px;
  border-radius: 0.2rem;
}

.btn-icon {
  display: none;
  filter: grayscale(1);
}

.area-top {
  order: 2;
}

.area-main,
.load-error {
  order: 3;
}

.area-bottom {
  order: 4;
}

.el-text {
  margin: 0;
  font-size: 1rem;
  color: var(--graphite);
}

.el-text.is-muted {
  color: var(--graphite-soft);
}

.el-title {
  margin: 0;
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.25;
  color: var(--graphite);
}

.btn {
  appearance: none;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.35);
  border: var(--stroke) solid var(--ink);
  border-radius: 0.55rem 0.85rem 0.45rem 0.9rem / 0.75rem 0.5rem 0.85rem 0.55rem;
  padding: 0.4rem 0.9rem 0.35rem;
  cursor: pointer;
  box-shadow: 1px 2px 0 rgba(31, 154, 85, 0.18);
}

.btn:hover {
  background: var(--ink-wash);
}

.btn:active {
  transform: translateY(1px);
}

.btn.is-primary {
  background: rgba(31, 154, 85, 0.14);
  font-weight: 600;
}

.sketch-box {
  border: var(--stroke) solid var(--graphite);
  border-radius: 0.7rem 1.1rem 0.6rem 1rem / 1rem 0.55rem 1.05rem 0.65rem;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.35);
}

.note {
  font-size: 0.95rem;
  color: var(--graphite-soft);
  white-space: pre-wrap;
}

.sketch-box.is-sheet {
  width: 100%;
  aspect-ratio: 210 / 297;
  background: rgba(255, 255, 255, 0.7);
}

.sketch-box.is-overlay {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  width: min(calc(100% - 2rem), var(--shell-max, 40rem));
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 0 rgba(46, 46, 46, 0.1);
}

.sketch-box.has-close {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.box-body {
  flex: 1 1 auto;
  min-width: 0;
}

.box-close {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.1rem 0.45rem;
  border: var(--stroke) solid var(--ink);
  border-radius: 0.45rem;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  font: inherit;
  line-height: 1.2;
  cursor: pointer;
}

.el-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.el-list-item {
  color: var(--graphite);
}

.el-feed {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  width: 100%;
}

@media (min-width: 560px) {
  .el-feed {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .el-feed {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.el-feed.is-horizontal {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.85rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.35rem;
  scroll-snap-type: x proximity;
}

.el-feed.is-horizontal .feed-card {
  flex: 0 0 min(220px, 72vw);
  width: min(220px, 72vw);
  scroll-snap-align: start;
}

.feed-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  height: 100%;
  min-width: 0;
}

.feed-card.is-clickable {
  cursor: pointer;
  border-color: var(--ink);
  background: var(--ink-wash);
}

.feed-card.is-clickable:hover {
  background: rgba(31, 154, 85, 0.16);
}

.feed-card.is-clickable:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.feed-card-lead {
  align-items: center;
  justify-content: center;
  min-height: 8.5rem;
  border-style: dashed;
}

.feed-card-lead .btn {
  width: 100%;
  height: 100%;
  min-height: 7.5rem;
  justify-content: center;
}

.feed-card-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--graphite);
}

.feed-card-text {
  margin: 0;
  font-size: 1rem;
  color: var(--graphite);
  flex: 1 1 auto;
}

.feed-card-meta {
  margin: 0;
}

.feed-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

.btn-qty {
  min-width: 2.4rem;
  padding-left: 0.55rem;
  padding-right: 0.55rem;
  font-weight: 600;
}

.note[hidden],
.el-text[hidden],
.sketch-box[hidden],
.el-title[hidden],
.area [hidden] {
  display: none !important;
}

.popup-root {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  z-index: 20;
}

.popup-root[hidden] {
  display: none;
}

.popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(46, 46, 46, 0.2);
  cursor: pointer;
}

.popup {
  position: relative;
  width: min(100%, 26rem);
  background: var(--paper);
  animation: popup-in 0.28s ease both;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.service-root {
  z-index: 30;
  align-items: center;
  padding: max(0.75rem, env(safe-area-inset-top))
    max(0.75rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom))
    max(0.75rem, env(safe-area-inset-left));
}

.service-root .popup,
.service-popup {
  width: min(100%, 52rem);
  max-height: calc(100dvh - 1.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: hidden;
}

.service-popup > .popup-title {
  flex: 0 0 auto;
}

.service-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.85rem;
  min-height: 0;
  overflow: hidden;
}

.service-sidebar {
  flex: 0 0 15rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 0;
  min-width: 0;
  padding: 0.55rem 0.65rem 0.55rem 0;
  border-right: var(--stroke) dashed var(--graphite);
  overflow: auto;
  overscroll-behavior: contain;
}

.service-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 0.15rem;
}

@media (max-width: 720px) {
  .service-root .popup,
  .service-popup {
    width: min(100%, 34rem);
  }

  .service-body {
    flex-direction: column;
    overflow: auto;
  }

  .service-sidebar {
    flex: 0 0 auto;
    max-height: 11rem;
    padding: 0 0 0.65rem;
    border-right: none;
    border-bottom: var(--stroke) dashed var(--graphite);
  }

  .service-main {
    overflow: visible;
  }
}

.popup-close {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 1;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: var(--stroke) solid var(--ink);
  border-radius: 0.45rem;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.popup-close:hover {
  background: var(--ink-wash);
}

.popup-title {
  margin: 0;
  padding-right: 2rem;
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--graphite);
}

.popup-body {
  margin: 0;
  font-size: 1rem;
  color: var(--graphite);
}

.popup-body[hidden],
.popup-elements[hidden],
.popup-actions[hidden] {
  display: none !important;
}

.popup-elements {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.popup-actions {
  margin-top: 0;
}

.popup.is-centered {
  text-align: center;
  align-items: center;
}

.popup.is-centered .popup-title,
.popup.is-centered .popup-body,
.popup.is-centered .popup-elements {
  width: 100%;
  text-align: center;
}

.popup.is-centered .popup-elements {
  align-items: stretch;
}

.popup.is-centered .popup-actions {
  justify-content: center;
  width: 100%;
}

@keyframes popup-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Мобильное меню: nav снизу фиксированной полосой */
@media (max-width: 720px) {
  .shell:has(.area-nav:not(:empty)) {
    padding-bottom: calc(var(--shell-pad) + var(--nav-mobile-h));
  }

  .area-nav:not(:empty) {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: min(100%, var(--shell-max));
    z-index: 15;
    order: 6;
    border-radius: 1rem 1rem 0 0;
    border-bottom: none;
    justify-content: space-around;
    padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom));
    background: rgba(251, 248, 241, 0.96);
    box-shadow: 0 -2px 0 rgba(46, 46, 46, 0.08);
  }

  .area-nav > .nav-logo-link {
    display: none;
  }

  .area-nav .btn {
    flex: 1 1 auto;
    text-align: center;
  }

  .area-nav .btn.has-icon {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding-block: 0.3rem;
  }

  .area-nav .btn.has-icon .btn-icon {
    display: block;
    font-size: 1.35rem;
    line-height: 1;
  }

  .area-nav .btn.has-icon .btn-label {
    font-size: 0.7rem;
  }

  .service-fab {
    bottom: calc(var(--nav-mobile-h) + 0.85rem + env(safe-area-inset-bottom));
  }
}

.service-fab {
  position: fixed;
  right: max(0.85rem, env(safe-area-inset-right));
  bottom: max(0.85rem, env(safe-area-inset-bottom));
  z-index: 25;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(79, 143, 212, 0.55);
  color: #fff;
  cursor: pointer;
  box-shadow: none;
}

.service-fab-dots {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
}

.service-fab-dots > span {
  display: block;
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 999px;
  background: currentColor;
}

.service-fab:hover {
  background: rgba(63, 127, 196, 0.7);
  color: #fff;
}

.service-fab:active {
  transform: translateY(1px);
}

.service-subtitle {
  margin: 0.35rem 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--graphite);
}

.service-mcp-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.65rem;
  margin: 0;
  min-height: 2.35rem;
}

.service-copy-status {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.9rem;
  color: var(--graphite-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.service-snippet {
  width: 100%;
  min-height: 8rem;
  max-height: 12rem;
  margin: 0;
  padding: 0.75rem 0.85rem;
  border: var(--stroke) solid var(--graphite);
  border-radius: 0.7rem 1.1rem 0.6rem 1rem / 1rem 0.55rem 1.05rem 0.65rem;
  background: rgba(255, 255, 255, 0.55);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: var(--graphite);
  resize: vertical;
  white-space: pre;
  overflow-x: auto;
  overflow-wrap: normal;
  word-break: normal;
}

.service-role-badge {
  margin: 0;
  font-weight: 500;
}

.service-share {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.service-share-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.service-share-row-secondary {
  justify-content: flex-start;
}

.service-share-url {
  flex: 1 1 12rem;
  min-width: 0;
  margin: 0;
  padding: 0.45rem 0.6rem;
  border: var(--stroke) solid var(--graphite);
  border-radius: 0.55rem 0.85rem 0.5rem 0.75rem / 0.75rem 0.45rem 0.85rem 0.5rem;
  background: rgba(255, 255, 255, 0.55);
  font: inherit;
  font-size: 0.8rem;
  color: var(--graphite);
}

.service-share-role {
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.85rem;
  border: var(--stroke) solid var(--graphite);
  border-radius: 0.4rem;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.35rem 0.45rem;
  color: var(--graphite);
}

.scenarios-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1 1 auto;
  min-height: 0;
}

.scenarios-empty {
  margin: 0;
}

.scenario-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.55rem 0.6rem;
  border: var(--stroke) dashed var(--graphite);
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.4);
  cursor: pointer;
}

.scenario-item:hover {
  background: var(--ink-wash);
}

.scenario-item.is-active {
  border-style: solid;
  border-color: var(--ink);
  background: var(--ink-wash);
}

.scenario-item-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.scenario-item-title {
  font-weight: 500;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scenario-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--graphite-soft);
}

.scenario-role {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border: var(--stroke) solid var(--graphite);
  border-radius: 999px;
  font-size: 0.7rem;
  line-height: 1.3;
  color: var(--graphite);
  background: rgba(255, 255, 255, 0.6);
}

.scenario-item-actions {
  display: flex;
  gap: 0.35rem;
}

.scenario-item-actions .btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
}
