/* Guide (#/guide). Only theme variables from app.css, so light and dark both work. */

/* Search */
.g-search { position: relative; max-width: 560px; }
.g-search > svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--text-3); pointer-events: none;
}
.g-search .input { padding-left: 40px; padding-right: 40px; height: 46px; font-size: 15px; }
.g-search-key { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.g-result { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; color: var(--text-2); font-size: 14px; margin-top: -8px; }
.g-result:empty { display: none; }

/* Contents + topics */
.g-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 22px; align-items: start; }
.g-toc { position: sticky; top: 20px; padding: 14px 10px; scroll-margin-top: 80px; }
.g-toc-head { padding: 2px 10px 10px; }
.g-toc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.g-toc-list a {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 6px 10px;
  border-radius: 10px; color: var(--text-2); font-size: 14px; font-weight: 500;
}
.g-toc-list a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.g-toc-list a:focus-visible { outline: none; box-shadow: var(--focus); }
.g-toc-list a.active { background: var(--teal-soft); color: var(--text); }
.g-toc-list a.active svg { color: var(--teal); }
.g-toc-list a.none { opacity: .45; }
.g-toc-list svg { width: 15px; height: 15px; flex: none; color: var(--text-3); }
.g-toc-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.g-toc-n { font: 500 12px var(--font-mono); color: var(--text-3); }

.g-content { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.g-topic { scroll-margin-top: 20px; overflow: hidden; }
.g-topic-head {
  display: flex; align-items: flex-start; gap: 14px; padding: 22px 26px 18px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.g-topic-icon {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 12px;
  background: var(--teal-soft); color: var(--teal);
}
.g-topic-title { font-family: var(--font-display); font-weight: 400; font-size: 32px; line-height: 1.05; letter-spacing: -.01em; }
.g-anchor { color: var(--text); }
.g-anchor:hover { color: var(--teal); text-decoration: none; }
.g-topic-lead { margin-top: 6px; color: var(--text-2); font-size: 14.5px; line-height: 1.5; max-width: 72ch; }
.g-topic-foot { padding: 12px 26px 16px; border-top: 1px solid var(--line); }
.g-topic-foot a { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); }
.g-topic-foot a:hover { color: var(--teal); text-decoration: none; }

/* One section of a topic (class name g-part) */
.g-part { padding: 20px 26px 22px; display: flex; flex-direction: column; gap: 12px; scroll-margin-top: 20px; }
.g-part + .g-part { border-top: 1px solid var(--line); }
.g-part.owner { box-shadow: inset 3px 0 0 var(--teal); }
.g-part-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 17px; font-weight: 600; color: var(--text); }
.g-part p { color: var(--text-2); font-size: 15px; line-height: 1.65; max-width: 74ch; }
.g-part b { color: var(--text); font-weight: 600; }
.g-part a { color: var(--teal); }

.g-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 7px; max-width: 74ch; }
.g-list li { color: var(--text-2); font-size: 15px; line-height: 1.6; padding-left: 2px; }
.g-list li::marker { color: var(--teal); }

.g-steps { list-style: none; margin: 0; padding: 0; counter-reset: gstep; display: flex; flex-direction: column; gap: 10px; max-width: 74ch; }
.g-steps li { counter-increment: gstep; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start; }
.g-steps li::before {
  content: counter(gstep); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--lime-soft); color: var(--text); font: 600 13px var(--font-mono);
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.g-steps li > span { color: var(--text-2); font-size: 15px; line-height: 1.6; padding-top: 3px; }

.g-note {
  display: flex; gap: 10px; align-items: flex-start; max-width: 74ch;
  padding: 12px 14px; border-radius: 12px; background: var(--teal-soft); color: var(--text); font-size: 14.5px; line-height: 1.55;
}
.g-note svg { width: 17px; height: 17px; flex: none; margin-top: 2px; color: var(--teal); }
.g-note.warn { background: var(--warn-soft); }
.g-note.warn svg { color: var(--warn); }

.g-formula {
  max-width: 74ch; padding: 16px 18px; border-radius: 12px;
  background: var(--lime-soft); border: 1px solid var(--line-2);
  font: 600 16px/1.5 var(--font-mono); color: var(--text); overflow-wrap: anywhere;
}

.g-example {
  max-width: 74ch; padding: 12px 16px; border-radius: 12px;
  border: 1px dashed var(--line-2); background: var(--surface-2);
  display: flex; flex-direction: column; gap: 4px;
}
.g-example-title {
  display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--text-3);
}
.g-example-title svg { color: var(--lime-text); }
.g-example-line { font: 500 14px/1.55 var(--font-mono); color: var(--text); overflow-wrap: anywhere; }

.g-code {
  font: 500 .92em var(--font-mono); padding: 1px 6px; border-radius: 6px;
  background: var(--surface-3); color: var(--text); overflow-wrap: anywhere;
}
.g-mark { background: var(--lime-soft); color: var(--text); border-radius: 3px; box-shadow: 0 0 0 1px var(--lime-soft); }

/* Tables (become small cards on phones) */
.g-table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.g-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.g-table th {
  text-align: left; padding: 10px 14px; white-space: nowrap; background: var(--surface-2);
  font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3);
  border-bottom: 1px solid var(--line);
}
.g-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--text-2); line-height: 1.5; }
.g-table tr:last-child td { border-bottom: 0; }
.g-table td:first-child { color: var(--text); }

/* Word list */
.g-words { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.g-words dt, .g-words dd { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--line); line-height: 1.5; }
.g-words dt { font-weight: 600; color: var(--text); background: var(--surface-2); }
.g-words dd { color: var(--text-2); }
.g-words dt:nth-last-of-type(1), .g-words dd:last-of-type { border-bottom: 0; }

/* Middle screens: contents above the topics */
@media (max-width: 1100px) {
  .g-layout { grid-template-columns: minmax(0, 1fr); }
  .g-toc { position: static; }
  .g-toc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 8px; }
  .g-topic, .g-part { scroll-margin-top: 80px; }
}

/* Phones */
@media (max-width: 700px) {
  .g-topic-head { padding: 16px; gap: 12px; }
  .g-topic-icon { width: 36px; height: 36px; }
  .g-topic-title { font-size: 27px; }
  .g-part { padding: 16px; }
  .g-topic-foot { padding: 12px 16px 14px; }
  .g-part p, .g-list li, .g-steps li > span { font-size: 15px; }
  .g-search-key { display: none; }
  .g-search .input { padding-right: 12px; }

  .g-table-wrap { border: 0; border-radius: 0; overflow: visible; }
  .g-table thead { display: none; }
  .g-table, .g-table tbody, .g-table tr, .g-table td { display: block; width: 100%; }
  .g-table tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; background: var(--surface-2); }
  .g-table tr:last-child { margin-bottom: 0; }
  .g-table td { padding: 4px 0; border: 0; }
  .g-table td::before {
    content: attr(data-label); display: block;
    font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3);
  }

  .g-words { grid-template-columns: minmax(0, 1fr); }
  .g-words dt { border-bottom: 0; padding-bottom: 2px; }
  .g-words dd { padding-top: 2px; background: var(--surface-2); }
  .g-words dt { background: var(--surface-2); }
}
@media (max-width: 420px) {
  .g-toc-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-toc-list a { padding: 6px 8px; gap: 8px; font-size: 13.5px; }
}
