:root {
  --tgkb-accent: #e75925;
  --tgkb-text: #202123;
  --tgkb-muted: #676b72;
  --tgkb-border: #e5e7eb;
  --tgkb-surface: #f7f7f8;
  --tgkb-hover: rgba(0, 0, 0, .035);
  --tgkb-active: rgba(0, 0, 0, .055);
}

.tgkb-shell,
.tgkb-shell * { box-sizing: border-box; }

.tgkb-shell {
  display: grid;
  grid-template-columns: minmax(220px, 270px) minmax(0, 820px);
  gap: clamp(28px, 4vw, 54px);
  align-items: start;
  width: min(100%, 1160px);
  margin: 28px auto 60px;
  color: var(--tgkb-text);
}

.tgkb-sidebar {
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding: 14px 10px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--tgkb-surface);
  scrollbar-width: thin;
}

.tgkb-sidebar-title {
  padding: 8px 10px 12px;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: -.015em;
}

.tgkb-sidebar-search { margin: 0 2px 10px; }
.tgkb-sidebar-search .tgkb-search { display: block; }
.tgkb-sidebar-search .tgkb-search button { display: none; }

.tgkb-topic-nav { display: grid; gap: 2px; }
.tgkb-topic-nav a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 8px 10px 8px 13px;
  border-radius: 3px;
  color: #454950;
  font-size: 13.5px;
  line-height: 1.3;
  font-weight: 600;
  text-decoration: none !important;
}

.tgkb-topic-nav a:hover,
.tgkb-topic-nav a:focus-visible { background: var(--tgkb-hover); color: var(--tgkb-text); outline: none; }
.tgkb-topic-nav a.is-active { background: var(--tgkb-active); color: var(--tgkb-text); font-weight: 750; }
.tgkb-topic-nav a.is-active::before { content: ""; position: absolute; left: 4px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--tgkb-accent); }
.tgkb-topic-nav small { color: #898e96; font-size: 11px; font-weight: 650; }
.tgkb-topic-home { margin-bottom: 5px; background: var(--tgkb-active); }

.tgkb-article {
  min-width: 0;
  color: #2d3035;
  font-size: 16.5px;
  line-height: 1.72;
}

.tgkb-article > *:first-child { margin-top: 0; }
.tgkb-article p,
.tgkb-article ul,
.tgkb-article ol,
.tgkb-article blockquote { max-width: 760px; }
.tgkb-article h2,
.tgkb-article h3,
.tgkb-article h4 { color: var(--tgkb-text); line-height: 1.2; letter-spacing: -.025em; font-weight: 750; }
.tgkb-article h2 { margin: 1.65em 0 .55em; font-size: clamp(24px, 2.2vw, 30px); }
.tgkb-article h3 { margin: 1.5em 0 .5em; font-size: clamp(20px, 1.8vw, 24px); }
.tgkb-article img { max-width: 100%; height: auto; border-radius: 12px; }

.tgkb-teaser {
  max-width: 760px;
  margin: 36px 0;
  padding: 22px 24px;
  border: 1px solid var(--tgkb-border);
  border-left: 3px solid var(--tgkb-accent);
  border-radius: 0 10px 10px 0;
  background: var(--tgkb-surface);
}

.tgkb-teaser small { display: block; margin-bottom: 7px; color: var(--tgkb-muted); font-size: 11px; line-height: 1; font-weight: 800; letter-spacing: .1em; }
.tgkb-teaser h3 { margin: 0 0 7px; font-size: 21px; }
.tgkb-teaser p { margin: 0 0 15px; color: var(--tgkb-muted); font-size: 15px; line-height: 1.55; }
.tgkb-teaser a,
.tgkb-search button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--tgkb-accent);
  color: #fff !important;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 700;
  text-decoration: none !important;
  cursor: pointer;
}

.tgkb-related { max-width: 760px; margin: 38px 0 0; padding-top: 24px; border-top: 1px solid var(--tgkb-border); }
.tgkb-related h3 { margin: 0 0 13px; font-size: 18px; }
.tgkb-related-links { display: flex; flex-wrap: wrap; gap: 7px; }
.tgkb-related a { display: inline-flex; padding: 7px 10px; border: 1px solid var(--tgkb-border); border-radius: 6px; background: #fff; color: #454950; font-size: 13px; line-height: 1.2; font-weight: 600; text-decoration: none !important; }
.tgkb-related a:hover,
.tgkb-related a:focus-visible { background: var(--tgkb-surface); color: var(--tgkb-text); }

.tgkb-search { display: flex; gap: 8px; width: 100%; }
.tgkb-search input {
  min-width: 0;
  min-height: 44px;
  flex: 1;
  padding: 10px 13px;
  border: 1px solid var(--tgkb-border);
  border-radius: 9px;
  background: #fff;
  color: var(--tgkb-text);
  font: inherit;
  font-size: 14px;
  outline: none;
}
.tgkb-search input:focus { border-color: color-mix(in srgb, var(--tgkb-accent) 40%, #d1d5db); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tgkb-accent) 11%, transparent); }

.tgkb-az { width: min(100%, 920px); margin: 24px auto 60px; }
.tgkb-az h2 { position: sticky; top: 80px; z-index: 2; margin: 34px 0 5px; padding: 7px 0; background: #fff; color: var(--tgkb-muted); font-size: 13px; font-weight: 800; letter-spacing: .08em; }
.tgkb-az > a { display: block; padding: 12px 4px; border-bottom: 1px solid var(--tgkb-border); color: var(--tgkb-text); font-size: 15px; font-weight: 600; text-decoration: none !important; }
.tgkb-az > a:hover,
.tgkb-az > a:focus-visible { background: var(--tgkb-hover); }

.tgkb-topics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tgkb-topics a { display: flex; justify-content: space-between; gap: 12px; padding: 16px; border: 1px solid var(--tgkb-border); border-radius: 10px; color: var(--tgkb-text); font-weight: 700; text-decoration: none !important; }
.tgkb-topics a:hover,
.tgkb-topics a:focus-visible { background: var(--tgkb-surface); }
.tgkb-topics small { color: var(--tgkb-muted); }

.tgkb-mobile-nav { display: none; }

@media (max-width: 900px) {
  .tgkb-shell { grid-template-columns: minmax(0, 1fr); gap: 20px; margin-top: 16px; }
  .tgkb-sidebar { display: none; }
  .tgkb-mobile-nav { display: block; position: sticky; top: 8px; z-index: 20; }
  .tgkb-mobile-nav details { overflow: hidden; border: 1px solid var(--tgkb-border); border-radius: 8px; background: rgba(247, 247, 248, .97); box-shadow: 0 6px 18px rgba(15, 23, 42, .05); }
  .tgkb-mobile-nav summary { display: flex; align-items: center; gap: 9px; min-height: 48px; padding: 11px 14px; color: var(--tgkb-text); font-size: 14px; font-weight: 750; cursor: pointer; list-style: none; }
  .tgkb-mobile-nav summary::-webkit-details-marker { display: none; }
  .tgkb-mobile-nav .tgkb-sidebar-title { display: none; }
  .tgkb-mobile-nav .tgkb-sidebar-search { margin: 0 12px 10px; }
  .tgkb-mobile-nav .tgkb-topic-nav { max-height: min(62vh, 520px); overflow: auto; padding: 0 10px 12px; }
  .tgkb-topic-nav a { min-height: 44px; }
}

@media (max-width: 600px) {
  .tgkb-shell { margin-bottom: 42px; }
  .tgkb-article { font-size: 16px; line-height: 1.68; }
  .tgkb-teaser { margin: 30px 0; padding: 18px; }
  .tgkb-search:not(.tgkb-sidebar-search .tgkb-search) { display: grid; }
  .tgkb-search:not(.tgkb-sidebar-search .tgkb-search) button { width: 100%; }
  .tgkb-topics { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .tgkb-topic-nav a,
  .tgkb-teaser a,
  .tgkb-related a { transition: none !important; }
}

/* v1.2.0: shared TG Knowledge Shell */
.tgkb-single-template {
  width: 100%;
  background: #fff;
}

.tgkb-shell.tgks-workspace {
  --tgks-left-column: minmax(250px, 286px);
  --tgks-panel-width: 330px;
  --tgks-open-gap: clamp(24px, 2.6vw, 38px);
  width: min(100%, 1580px);
  max-width: 1580px;
  margin: 0 auto;
  padding: 48px 24px 72px;
  display: grid;
  grid-template-columns: var(--tgks-left-column) minmax(0, 1fr);
  gap: clamp(28px, 3.5vw, 50px);
  align-items: start;
}

.tgkb-shell.tgks-workspace.tgks-has-context.is-context-open {
  grid-template-columns: var(--tgks-left-column) minmax(0, 1fr) var(--tgks-panel-width);
}

.tgkb-nav-shell { min-width: 0; }

.tgkb-sidebar {
  display: block;
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding: 14px 10px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--tgkb-surface);
  box-shadow: none;
}

.tgkb-sidebar-mobile-head { display: none; }
.tgkb-mobile-toggle,
.tgkb-nav-backdrop { display: none; }

.tgkb-topic-home {
  display: flex;
  align-items: center;
  min-height: 40px;
  margin-bottom: 7px;
  padding: 8px 10px 8px 13px;
  border-radius: 3px;
  background: rgba(0, 0, 0, .045);
  color: #35393e;
  font-size: 13.5px;
  font-weight: 750;
  text-decoration: none !important;
}

.tgkb-topic-group { margin-top: 2px; }

.tgkb-topic-heading {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #535861;
  text-align: left;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.25;
  font-weight: 750;
  cursor: pointer;
}

.tgkb-topic-heading:hover,
.tgkb-topic-heading:focus-visible,
.tgkb-topic-group.is-open > .tgkb-topic-heading { background: #eceeef; color: var(--tgkb-text); outline: none; }
.tgkb-topic-heading small { margin-left: auto; color: #92979e; font-size: 10.5px; font-style: normal; }
.tgkb-topic-heading i { width: 7px; height: 7px; margin-left: 9px; border-right: 1.5px solid #8b9198; border-bottom: 1.5px solid #8b9198; transform: rotate(45deg) translateY(-2px); transition: transform 180ms ease; }
.tgkb-topic-group.is-open > .tgkb-topic-heading i { transform: rotate(225deg) translate(-1px, -1px); }

.tgkb-article-list {
  display: none;
  gap: 2px;
  margin: 3px 0 8px;
  padding-left: 8px;
}

.tgkb-topic-group.is-open .tgkb-article-list { display: grid; }

.tgkb-article-list a {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px 8px 13px;
  border-radius: 3px;
  color: #454950;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 600;
  text-decoration: none !important;
}

.tgkb-article-list a:hover,
.tgkb-article-list a:focus-visible { background: #eceeef; color: var(--tgkb-text); outline: none; }
.tgkb-article-list a.is-active { background: #e5e7e9; color: #24272b; font-weight: 750; box-shadow: inset 3px 0 0 #9aa0a6; }

.tgkb-article {
  width: 100%;
  max-width: none;
  min-width: 0;
  color: #2d3035;
  font-size: 16.5px;
  line-height: 1.72;
}

.tgkb-article-header { margin: 0 0 30px; }
.tgkb-eyebrow { margin: 0 0 9px; color: #858b92; font-size: 11px; line-height: 1; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.tgkb-article-header h1 { margin: 0; color: var(--tgkb-text); font-size: clamp(34px, 4vw, 54px); line-height: 1.06; font-weight: 850; letter-spacing: -.038em; }
.tgkb-entry { max-width: 820px; }
.tgkb-entry > *:first-child { margin-top: 0; }
.tgkb-entry p,
.tgkb-entry ul,
.tgkb-entry ol,
.tgkb-entry blockquote { max-width: 760px; }

.tgkb-context-practice { border-left: 3px solid var(--tgkb-accent); padding-left: 15px; }

@media (max-width: 1099px) {
  .tgkb-shell.tgks-workspace,
  .tgkb-shell.tgks-workspace.tgks-has-context.is-context-open {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
    padding: 28px 20px 56px;
  }

  .tgkb-nav-shell { min-height: 50px; }
  .tgkb-mobile-toggle {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 46px;
    position: sticky;
    top: 10px;
    z-index: 30;
    padding: 10px 14px;
    border: 1px solid var(--tgkb-border);
    border-radius: 9px;
    background: rgba(247, 247, 248, .98);
    color: var(--tgkb-text);
    font: inherit;
    font-size: 13.5px;
    font-weight: 750;
    cursor: pointer;
  }

  .tgkb-sidebar {
    position: fixed;
    z-index: 100000;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(390px, 90vw);
    max-height: none;
    padding: 18px 14px 24px;
    border-radius: 0 18px 18px 0;
    transform: translateX(-103%);
    transition: transform 280ms var(--tgks-ease);
    box-shadow: 18px 0 44px rgba(22, 27, 33, .12);
  }

  .tgkb-nav-shell.is-open .tgkb-sidebar { transform: translateX(0); }
  .tgkb-sidebar-mobile-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 12px 10px; }
  .tgkb-sidebar-title { display: none; }
  .tgkb-nav-backdrop { position: fixed; inset: 0; z-index: 99999; background: rgba(20,24,28,.34); opacity: 0; visibility: hidden; transition: opacity 220ms ease, visibility 220ms ease; }
  .tgkb-nav-shell.is-open .tgkb-nav-backdrop { display: block; opacity: 1; visibility: visible; }
  .tgkb-topic-heading,
  .tgkb-article-list a { min-height: 44px; }
}

@media (max-width: 600px) {
  .tgkb-shell.tgks-workspace { padding: 22px 16px 48px; }
  .tgkb-article-header h1 { font-size: clamp(31px, 10vw, 42px); }
}
