/* KernelInk 1.0.3 feature layer: compact, low-cost IDE interactions. */

/* ---------- Article card compile state ---------- */
.nb-card {
  isolation: isolate;
}

.nb-card-build {
  position: absolute;
  z-index: 4;
  top: 0;
  right: 18px;
  display: flex;
  min-width: 154px;
  height: 24px;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  background: var(--editor-code);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.48rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-7px);
  transition: opacity 150ms var(--ease-ui), transform 180ms var(--ease);
}

.nb-card-build i {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.08);
}

.nb-card-build code {
  min-width: 0;
  overflow: hidden;
  color: var(--syntax-blue);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nb-card-build b {
  margin-left: auto;
  color: var(--accent-strong);
  font-size: 0.46rem;
}

.nb-card::before {
  position: absolute;
  z-index: 5;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  content: "";
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

.nb-card:hover .nb-card-build,
.nb-card:focus-within .nb-card-build {
  opacity: 1;
  transform: none;
}

.nb-card:hover::before,
.nb-card:focus-within::before {
  animation: nb-card-compile 620ms var(--ease) both;
  opacity: 0.68;
}

@keyframes nb-card-compile {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ---------- Structured ad slots ---------- */
.nb-ad {
  margin: 12px 0 16px;
}

.nb-ad-card {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: 84px;
  overflow: hidden;
  padding: 10px 13px;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background:
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.035), transparent 38%),
    var(--editor-code);
  color: var(--text-soft);
  box-shadow: var(--shadow-inner);
}

a.nb-ad-card:hover,
a.nb-ad-card:focus-visible {
  border-color: var(--line-accent);
  outline: 0;
  background-color: var(--editor-active);
  transform: translateY(-1px);
}

.nb-ad-visual {
  display: grid;
  width: 96px;
  height: 62px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.nb-ad-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nb-ad-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.nb-ad-copy small {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nb-ad-copy small i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--syntax-amber);
}

.nb-ad-copy strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nb-ad-copy > span {
  color: var(--text-soft);
  font-size: 0.69rem;
  line-height: 1.45;
}

.nb-ad-open {
  color: var(--syntax-blue);
  font-family: var(--font-mono);
}

.nb-sidebar-content > .nb-ad {
  margin: 0 0 10px;
}

.nb-sidebar-content > .nb-ad .nb-ad-card {
  grid-template-columns: 58px minmax(0, 1fr);
  min-height: 72px;
  padding: 8px;
  gap: 9px;
}

.nb-sidebar-content > .nb-ad .nb-ad-visual {
  width: 58px;
  height: 52px;
}

.nb-sidebar-content > .nb-ad .nb-ad-open,
.nb-sidebar-content > .nb-ad .nb-ad-copy > span {
  display: none;
}

/* ---------- Comment client and composer tools ---------- */
.nb-comment-byline {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.nb-comment-client,
.nb-comment-os,
.nb-comment-ip {
  display: inline-flex;
  align-items: center;
}

.nb-comment-client {
  flex: 0 1 auto;
  gap: 6px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.51rem;
}

.nb-comment-os,
.nb-comment-ip {
  min-height: 22px;
  padding: 0 7px;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--editor-code);
}

.nb-comment-os svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  fill: currentColor;
  color: var(--syntax-blue);
}

.nb-comment-ip > span {
  color: var(--syntax-amber);
  font-size: 0.45rem;
  font-weight: 800;
}

.comment-content img {
  width: auto;
  max-width: min(100%, 520px);
  max-height: 440px;
  margin-top: 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--editor-code);
  object-fit: contain;
}

.nb-comment-compose-tools {
  position: relative;
  display: flex;
  min-height: 38px;
  align-items: center;
  flex-wrap: wrap;
  padding: 5px 7px;
  gap: 5px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  background: var(--editor-bar);
}

.nb-comment-tool {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  gap: 5px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.56rem;
  cursor: pointer;
}

.nb-comment-tool:hover,
.nb-comment-tool:focus-visible,
.nb-comment-tool[aria-expanded="true"] {
  border-color: var(--line);
  outline: 0;
  background: var(--editor-active);
  color: var(--accent-strong);
}

.nb-comment-upload-hint,
.nb-comment-tool-status {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.49rem;
}

.nb-comment-tool-status {
  margin-left: auto;
}

.nb-comment-tool-status.has-error {
  color: var(--danger);
}

.nb-comment-emoji-wrap {
  position: relative;
}

.nb-comment-emoji-panel {
  position: absolute;
  z-index: 20;
  bottom: calc(100% + 8px);
  left: 0;
  display: grid;
  width: 222px;
  grid-template-columns: repeat(8, 1fr);
  padding: 7px;
  gap: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--glass-strong);
  box-shadow: var(--shadow-float);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}

.nb-comment-emoji-panel[hidden] {
  display: none;
}

.nb-comment-emoji-panel button {
  display: grid;
  width: 23px;
  height: 27px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.nb-comment-emoji-panel button:hover,
.nb-comment-emoji-panel button:focus-visible {
  outline: 1px solid var(--line-accent);
  background: var(--editor-active);
}

.nb-comment-upload-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 8px;
  gap: 7px;
}

.nb-comment-upload-list:empty {
  display: none;
}

.nb-comment-upload-item {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-columns: 48px minmax(0, 1fr) 26px;
  align-items: center;
  min-height: 58px;
  padding: 5px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--editor-code);
}

.nb-comment-upload-item img {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
}

.nb-comment-upload-item > span {
  display: grid;
  min-width: 0;
}

.nb-comment-upload-item strong,
.nb-comment-upload-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nb-comment-upload-item strong {
  color: var(--text-soft);
  font-size: 0.62rem;
}

.nb-comment-upload-item small {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.49rem;
}

.nb-comment-upload-item.is-uploading::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--syntax-blue);
  content: "";
  animation: nb-upload-progress 1.1s ease-in-out infinite;
  transform-origin: left;
}

.nb-comment-upload-item.is-ready { border-color: rgba(var(--accent-rgb), 0.25); }
.nb-comment-upload-item.is-ready small { color: var(--accent-strong); }
.nb-comment-upload-item.has-error { border-color: rgba(255, 107, 122, 0.35); }
.nb-comment-upload-item.has-error small { color: var(--danger); }

@keyframes nb-upload-progress {
  0% { transform: scaleX(0.05); }
  65% { transform: scaleX(0.82); }
  100% { transform: scaleX(0.05); transform-origin: right; }
}

.nb-comment-upload-remove {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.nb-comment-upload-remove:hover,
.nb-comment-upload-remove:focus-visible {
  outline: 1px solid var(--line-accent);
  color: var(--danger);
}

/* ---------- Friend links actions and guard ---------- */
.nb-footer-links-actions {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.nb-friend-apply-link {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  padding: 0 8px;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 0.53rem;
}

.nb-friend-apply-link span {
  color: var(--accent-strong);
  font-size: 0.78rem;
}

.nb-friend-apply-link:hover,
.nb-friend-apply-link:focus-visible {
  border-color: var(--line-accent);
  outline: 0;
  color: var(--accent-strong);
}

.nb-friend-guard {
  position: fixed;
  z-index: 1100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  visibility: hidden;
  opacity: 0;
  transition: opacity 140ms var(--ease-ui), visibility 140ms var(--ease-ui);
}

.nb-friend-guard[hidden] { display: none; }
.nb-friend-guard.is-open { visibility: visible; opacity: 1; }

.nb-friend-guard-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 7, 5, 0.84);
}

.nb-friend-guard-dialog {
  position: relative;
  width: min(430px, 100%);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: 0;
  background: var(--surface);
  box-shadow: var(--shadow-float), var(--shadow-inner);
  opacity: 0.96;
  transform: translateY(7px) scale(0.99);
  transition: transform 150ms var(--ease), opacity 150ms var(--ease-ui);
}

.nb-friend-guard.is-open .nb-friend-guard-dialog { opacity: 1; transform: none; }

.nb-friend-guard-dialog > header,
.nb-friend-guard-dialog > footer {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  gap: 8px;
  background: var(--editor-bar);
}

.nb-friend-guard-dialog > header {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.nb-friend-guard-dialog > header span {
  color: var(--syntax-blue);
  font-family: var(--font-mono);
  font-size: 0.54rem;
}

.nb-friend-guard-dialog > header button,
.nb-float-contact-card header button {
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.nb-friend-guard-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  padding: 18px 17px 12px;
  gap: 12px;
}

.nb-friend-guard-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 203, 107, 0.25);
  border-radius: 8px;
  background: rgba(255, 203, 107, 0.06);
  color: var(--syntax-amber);
}

.nb-friend-guard-body h2 { margin: 0; color: var(--text); font-size: 1rem; }
.nb-friend-guard-body p { margin: 4px 0 0; color: var(--text-soft); font-size: 0.72rem; line-height: 1.6; }

.nb-friend-guard-dialog dl {
  display: grid;
  margin: 0 17px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--editor-code);
}

.nb-friend-guard-dialog dl div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  padding: 7px 9px;
  gap: 8px;
}

.nb-friend-guard-dialog dl div + div { border-top: 1px solid var(--line); }
.nb-friend-guard-dialog dt { color: var(--text-dim); font-family: var(--font-mono); font-size: 0.52rem; }
.nb-friend-guard-dialog dd { margin: 0; overflow: hidden; color: var(--text-soft); font-size: 0.64rem; text-overflow: ellipsis; white-space: nowrap; }
.nb-friend-guard-dialog > footer { justify-content: flex-end; border-top: 1px solid var(--line); }

/* ---------- Floating contact QR cards ---------- */
.nb-float-contact { position: relative; }

.nb-float-contact-card {
  position: absolute;
  right: calc(100% + 10px);
  bottom: 0;
  width: 222px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--glass-strong);
  box-shadow: var(--shadow-float);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}

.nb-float-contact-card[hidden] { display: none; }

.nb-float-contact-card header {
  display: flex;
  min-height: 35px;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px 3px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--editor-bar);
  color: var(--syntax-blue);
  font-family: var(--font-mono);
  font-size: 0.5rem;
}

.nb-float-contact-card > div {
  display: grid;
  padding: 11px;
  place-items: center;
}

.nb-float-contact-card img {
  width: 188px;
  height: 188px;
  padding: 6px;
  border-radius: 6px;
  background: #fff;
  object-fit: contain;
}

.nb-float-contact-card strong { margin-top: 8px; color: var(--text); font-size: 0.7rem; }
.nb-float-contact-card small { color: var(--text-dim); font-family: var(--font-mono); font-size: 0.49rem; }
.nb-float-contact.is-open > .nb-float-btn { border-color: var(--line-accent); color: var(--accent-strong); }

/* ---------- Special page shell ---------- */
.nb-special-page {
  padding-block: 12px 34px;
}

.nb-special-page-head {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  overflow: hidden;
  margin-bottom: 16px;
  padding: 26px clamp(18px, 4vw, 36px);
  gap: 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-shell);
  background:
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.04), transparent 36%),
    var(--editor-code);
  box-shadow: var(--shadow-reader), var(--shadow-inner);
}

.nb-special-page-route {
  position: absolute;
  top: 9px;
  left: 13px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.49rem;
}

.nb-special-page-head h1 { margin: 4px 0 0; color: var(--text); font-size: clamp(1.7rem, 4vw, 2.8rem); line-height: 1.2; }
.nb-special-page-head p { max-width: 720px; margin: 8px 0 0; color: var(--text-soft); font-size: 0.79rem; }

.nb-special-empty {
  display: grid;
  min-height: 280px;
  padding: 30px;
  place-items: center;
  align-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-panel);
  background: var(--editor-code);
  text-align: center;
}

.nb-special-empty > span { color: var(--syntax-blue); font-family: var(--font-mono); font-size: 2rem; }
.nb-special-empty h2 { margin: 8px 0 0; font-size: 1rem; }
.nb-special-empty p { margin: 6px 0 0; color: var(--text-dim); font-size: 0.72rem; }

/* ---------- Friend application page ---------- */
.nb-friend-apply-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.35fr) minmax(0, 1fr);
  gap: 14px;
}

.nb-friend-apply-guide,
.nb-friend-apply-form {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-panel);
  background: var(--editor-code);
  box-shadow: var(--shadow-inner);
}

.nb-friend-apply-guide { padding: 20px; }
.nb-friend-guide-status { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-strong); font-family: var(--font-mono); font-size: 0.53rem; }
.nb-friend-guide-status i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.nb-friend-apply-guide h2 { margin: 12px 0 17px; color: var(--syntax-blue); font-family: var(--font-mono); font-size: 0.9rem; }
.nb-friend-apply-guide ol { display: grid; gap: 14px; list-style: none; }
.nb-friend-apply-guide li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 9px; }
.nb-friend-apply-guide li > span { color: var(--text-dim); font-family: var(--font-mono); font-size: 0.55rem; }
.nb-friend-apply-guide li div { display: grid; }
.nb-friend-apply-guide li strong { color: var(--text); font-size: 0.7rem; }
.nb-friend-apply-guide li small { color: var(--text-dim); font-size: 0.6rem; line-height: 1.5; }
.nb-friend-apply-guide > p { margin: 19px 0 0; padding-top: 13px; border-top: 1px solid var(--line); color: var(--text-dim); font-size: 0.6rem; }

.nb-friend-apply-form { position: relative; overflow: hidden; }
.nb-form-terminal-bar { display: grid; min-height: 42px; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; padding: 0 12px; gap: 10px; border-bottom: 1px solid var(--line); background: var(--editor-bar); }
.nb-form-terminal-bar > span { display: flex; gap: 5px; }
.nb-form-terminal-bar i { width: 7px; height: 7px; border-radius: 50%; background: var(--syntax-red); }
.nb-form-terminal-bar i:nth-child(2) { background: var(--syntax-amber); }
.nb-form-terminal-bar i:nth-child(3) { background: var(--accent); }
.nb-form-terminal-bar strong { color: var(--text-soft); font-family: var(--font-mono); font-size: 0.62rem; }
.nb-form-terminal-bar small { color: var(--text-dim); font-family: var(--font-mono); font-size: 0.48rem; }

.nb-honeypot { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; overflow: hidden !important; }
.nb-friend-form-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 18px; gap: 12px; }
.nb-friend-form-fields label { display: grid; gap: 5px; }
.nb-friend-form-fields label.is-wide { grid-column: 1 / -1; }
.nb-friend-form-fields label > span { color: var(--syntax-blue); font-family: var(--font-mono); font-size: 0.56rem; }
.nb-friend-form-fields .nb-input { width: 100%; border-radius: 5px; background: var(--surface); font-family: var(--font-mono); font-size: 0.69rem; }
.nb-friend-form-fields textarea { min-height: 116px; resize: vertical; }
.nb-friend-form-footer { display: flex; min-height: 58px; align-items: center; justify-content: space-between; padding: 9px 13px; gap: 12px; border-top: 1px solid var(--line); background: var(--surface); }
.nb-friend-form-footer > span { color: var(--text-dim); font-family: var(--font-mono); font-size: 0.55rem; }
.nb-friend-apply-form.is-success .nb-friend-form-footer > span { color: var(--accent-strong); }
.nb-friend-apply-form.has-error .nb-friend-form-footer > span { color: var(--danger); }
.nb-friend-apply-form.is-busy::after { position: absolute; right: 0; bottom: 0; left: 0; height: 2px; background: var(--syntax-blue); content: ""; animation: nb-upload-progress 1.1s infinite; }

/* ---------- Masonry photo wall ---------- */
.nb-gallery-summary { display: grid; justify-items: end; color: var(--text-dim); font-family: var(--font-mono); }
.nb-gallery-summary span { display: flex; align-items: baseline; gap: 6px; }
.nb-gallery-summary b { color: var(--accent-strong); font-size: 1.55rem; }
.nb-gallery-summary small { font-size: 0.48rem; }
.nb-gallery-toolbar { display: flex; min-height: 38px; align-items: center; justify-content: space-between; margin-bottom: 10px; padding: 0 12px; gap: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--editor-code); color: var(--text-dim); font-family: var(--font-mono); font-size: 0.55rem; }
.nb-gallery-toolbar span { display: inline-flex; align-items: center; gap: 6px; }
.nb-gallery-toolbar i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.nb-gallery-toolbar code { color: var(--syntax-blue); }

.nb-gallery-stream {
  column-count: 4;
  column-gap: 11px;
}

.nb-gallery-item {
  display: inline-block;
  width: 100%;
  margin: 0 0 11px;
  break-inside: avoid;
}

.nb-gallery-item > button {
  display: block;
  width: 100%;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: var(--editor-code);
  color: var(--text-soft);
  text-align: left;
  cursor: zoom-in;
  transition: border-color 160ms var(--ease-ui), transform 180ms var(--ease), box-shadow 180ms var(--ease-ui);
}

.nb-gallery-item > button:hover,
.nb-gallery-item > button:focus-visible { border-color: var(--line-accent); box-shadow: var(--shadow-compact); transform: translateY(-2px); }
.nb-gallery-image { position: relative; display: block; overflow: hidden; background: var(--surface); }
.nb-gallery-image img { width: 100%; min-height: 120px; object-fit: cover; transition: transform 420ms var(--ease); }
.nb-gallery-item > button:hover img { transform: scale(1.018); }
.nb-gallery-image > span { position: absolute; right: 8px; bottom: 8px; display: inline-flex; min-height: 25px; align-items: center; padding: 0 7px; gap: 6px; border: 1px solid rgba(255,255,255,.16); border-radius: 4px; background: rgba(4,9,8,.7); color: #dce9e5; font-family: var(--font-mono); font-size: .51rem; }
.nb-gallery-image > span b { color: var(--accent); }
.nb-gallery-caption { display: block; padding: 9px 10px; overflow: hidden; color: var(--text-soft); font-size: .67rem; text-overflow: ellipsis; white-space: nowrap; }

.nb-gallery-lightbox { position: fixed; z-index: 1150; inset: 0; display: grid; place-items: center; padding: 16px; visibility: hidden; opacity: 0; transition: opacity 140ms var(--ease-ui), visibility 140ms var(--ease-ui); }
.nb-gallery-lightbox[hidden] { display: none; }
.nb-gallery-lightbox[aria-hidden="false"] { visibility: visible; }
.nb-gallery-lightbox.is-open { visibility: visible; opacity: 1; }
.nb-gallery-lightbox-backdrop { position: absolute; inset: 0; background: rgba(2,7,5,.92); }
.nb-gallery-lightbox > section { position: relative; display: grid; width: min(1120px, 100%); max-height: calc(100dvh - 32px); overflow: hidden; border: 1px solid var(--line-strong); border-radius: 10px; outline: 0; background: var(--editor-code); box-shadow: var(--shadow-float); }
.nb-gallery-lightbox header,
.nb-gallery-lightbox footer { display: flex; min-height: 40px; align-items: center; justify-content: space-between; padding: 0 11px; gap: 10px; background: var(--editor-bar); color: var(--text-dim); font-family: var(--font-mono); font-size: .55rem; }
.nb-gallery-lightbox header { border-bottom: 1px solid var(--line); }
.nb-gallery-lightbox footer { border-top: 1px solid var(--line); }
.nb-gallery-lightbox header button { display: grid; width: 29px; height: 29px; padding: 0; place-items: center; border: 0; border-radius: 4px; background: transparent; color: var(--text-dim); cursor: pointer; }
.nb-gallery-lightbox-stage { display: grid; min-height: 300px; grid-template-columns: 42px minmax(0, 1fr) 42px; align-items: center; overflow: hidden; background: #050808; }
.nb-gallery-lightbox-stage img { width: 100%; height: min(76vh, 760px); object-fit: contain; opacity: 1; transition: opacity 120ms; }
.nb-gallery-lightbox-stage img.is-loading { opacity: .34; }
.nb-gallery-lightbox-stage button { position: relative; z-index: 2; width: 34px; height: 54px; margin: 4px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: rgba(10,16,15,.82); color: var(--text-soft); cursor: pointer; }
.nb-gallery-lightbox-stage button:hover,
.nb-gallery-lightbox-stage button:focus-visible { border-color: var(--line-accent); outline: 0; color: var(--accent); }
.nb-gallery-lightbox footer p { margin: 0; overflow: hidden; color: var(--text-soft); text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Compact footer monitoring ---------- */
.nb-footer-telemetry-head { min-height: 30px; padding-inline: 12px; }
.nb-footer-metric,
.nb-footer-metric-link { min-height: 72px; }
.nb-footer-metric { grid-template-columns: 22px minmax(0, 1fr); align-content: center; padding: 8px 10px; gap: 1px 7px; }
.nb-footer-metric-icon { width: 22px; height: 22px; grid-row: 1 / span 2; border-radius: 4px; }
.nb-footer-metric-icon svg { width: 14px; height: 14px; }
.nb-footer-metric-sub { margin-top: 1px; font-size: .46rem; line-height: 1.25; }

/* ---------- QR share dialog refinement ---------- */
[data-reader-qr-modal] .nb-qr-dialog { width: min(330px, 100%); }
[data-reader-qr-modal] .nb-qr-head { min-height: 50px; padding-block: 7px; }
[data-reader-qr-modal] .nb-qr-stage {
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  justify-items: center;
  margin: 10px 14px 9px;
  padding: 10px 12px 14px;
  gap: 9px;
}
[data-reader-qr-modal] .nb-qr-stage canvas { width: 168px; height: 168px; max-width: min(168px, calc(100% - 28px)); max-height: 168px; aspect-ratio: 1; }
[data-reader-qr-modal] .nb-qr-stage-label {
  position: static;
  z-index: auto;
  display: inline-flex;
  min-height: 20px;
  align-items: center;
  justify-self: start;
  padding: 0 7px;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: .43rem;
  letter-spacing: .06em;
}
[data-reader-qr-modal] .nb-qr-stage-label::before {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  content: "";
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .07);
}
[data-reader-qr-modal] .nb-qr-article { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; margin: 0 14px 9px; padding: 7px 9px; gap: 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--editor-code); }
[data-reader-qr-modal] .nb-qr-article > span { color: var(--accent-strong); font-family: var(--font-mono); font-size: .52rem; }
[data-reader-qr-modal] .nb-qr-article strong { overflow: hidden; color: var(--text-soft); font-size: .62rem; text-overflow: ellipsis; white-space: nowrap; }
[data-reader-qr-modal] .nb-qr-article small { color: var(--syntax-blue); font-family: var(--font-mono); font-size: .44rem; }
[data-reader-qr-modal] .nb-qr-dialog > p { padding-inline: 14px; font-size: .68rem; }
[data-reader-qr-modal] .nb-qr-url { margin: 8px 14px 10px; }
[data-reader-qr-modal] .nb-qr-actions { padding: 9px 14px 12px; }

/* ---------- Navigation hierarchy ---------- */
@media (min-width: 821px) {
  .nb-dropdown { padding-top: 28px; }
  .nb-dropdown::before { position: absolute; top: 7px; right: 10px; left: 10px; color: var(--text-dim); content: "./submenu"; font-family: var(--font-mono); font-size: .47rem; letter-spacing: .06em; }
  .nb-dropdown > .nb-nav-item { position: relative; }
  .nb-dropdown > .nb-nav-item + .nb-nav-item { border-top: 1px solid rgba(188,213,207,.07); }
  .nb-dropdown .nb-nav-link::before { width: 10px; color: var(--text-dim); content: "›"; font-family: var(--font-mono); }
  .nb-dropdown .nb-nav-link:hover::before { color: var(--accent-strong); }
}

/* ---------- Weather placement inside the first-screen editor ---------- */
.nb-workbench-main .nb-weather-slot { margin: 9px 10px 0; }
.nb-workbench-main .nb-weather-widget { min-height: 190px; }

@media (max-width: 1020px) {
  .nb-gallery-stream { column-count: 3; }
  .nb-friend-apply-grid { grid-template-columns: minmax(0, 1fr); }
  .nb-friend-apply-guide { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
  .nb-friend-apply-guide ol { grid-column: 1 / -1; }
  .nb-friend-apply-guide > p { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .nb-nav::before { display: block; margin: -52px 2px 18px; padding-bottom: 10px; border-bottom: 1px solid var(--line); color: var(--syntax-blue); content: "navigation.tree"; font-family: var(--font-mono); font-size: .58rem; letter-spacing: .07em; }
  .nb-nav-list { gap: 6px; }
  .nb-nav-list > .nb-nav-item { overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--editor-code); }
  .nb-nav-list > .nb-nav-item.is-open { border-color: var(--line-strong); background: var(--surface); }
  .nb-nav-list > .nb-nav-item > .nb-nav-link::before { width: 16px; color: var(--text-dim); content: "›"; font-family: var(--font-mono); }
  .nb-nav-list > .nb-nav-item.is-open > .nb-nav-link::before { color: var(--accent); content: "⌄"; }
  .nb-dropdown { margin: 0 9px 9px; padding: 4px 0 4px 10px; border-left-color: var(--line-accent); }
  .nb-dropdown .nb-nav-link { min-height: 39px; font-family: var(--font-mono); font-size: .72rem; }
  .nb-dropdown .nb-nav-link::before { color: var(--text-dim); content: "./"; font-size: .55rem; }
  .nb-card-build { display: none; }
}

@media (max-width: 720px) {
  .nb-ad-card { grid-template-columns: 64px minmax(0, 1fr); min-height: 72px; padding: 8px; gap: 9px; }
  .nb-ad-visual { width: 64px; height: 54px; }
  .nb-ad-open { display: none; }
  .nb-comment-byline { align-items: flex-start; flex-direction: column; gap: 5px; }
  .nb-comment-client { flex-wrap: wrap; }
  .nb-comment-upload-list { grid-template-columns: minmax(0, 1fr); }
  .nb-comment-upload-hint { display: none; }
  .nb-comment-tool-status { width: 100%; margin-left: 0; }
  .nb-float-contact-card { position: fixed; right: 13px; bottom: calc(70px + env(safe-area-inset-bottom)); width: min(232px, calc(100vw - 26px)); }
  .nb-special-page-head { grid-template-columns: minmax(0, 1fr); align-items: start; padding-top: 34px; }
  .nb-special-page-head .nb-btn { justify-self: start; }
  .nb-friend-form-fields { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .nb-friend-form-fields label.is-wide { grid-column: auto; }
  .nb-friend-form-footer { align-items: stretch; flex-direction: column; }
  .nb-friend-form-footer .nb-btn { width: 100%; }
  .nb-gallery-summary { justify-items: start; }
  .nb-gallery-stream { column-count: 2; column-gap: 8px; }
  .nb-gallery-item { margin-bottom: 8px; }
  .nb-gallery-caption { padding: 7px 8px; font-size: .61rem; }
  .nb-gallery-lightbox { padding: 8px; }
  .nb-gallery-lightbox > section { max-height: calc(100dvh - 16px); }
  .nb-gallery-lightbox-stage { grid-template-columns: 34px minmax(0, 1fr) 34px; }
  .nb-gallery-lightbox-stage img { height: min(72vh, 680px); }
  .nb-gallery-lightbox-stage button { width: 28px; margin: 3px; }
  .nb-footer-links-head { align-items: flex-start; }
  .nb-footer-links-actions { align-items: flex-end; flex-direction: column; }
  .nb-footer-telemetry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nb-friend-guard-dialog dl div { grid-template-columns: 72px minmax(0, 1fr); }
}

@media (max-width: 390px) {
  .nb-gallery-stream { column-count: 2; }
  .nb-comment-emoji-panel { width: 202px; grid-template-columns: repeat(7, 1fr); }
  .nb-footer-metric { min-height: 68px; padding-inline: 8px; }
  .nb-footer-metric-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .nb-card:hover::before,
  .nb-card:focus-within::before,
  .nb-comment-upload-item.is-uploading::after,
  .nb-friend-apply-form.is-busy::after { animation: none; transform: scaleX(1); }
  .nb-gallery-item > button,
  .nb-gallery-image img,
  .nb-friend-guard-dialog { transition: none; }
}

/* ---------- Contact-sheet photo wall ---------- */
.nb-gallery-toolbar [data-gallery-status-text] {
  color: inherit;
  font: inherit;
  font-weight: 600;
}

.nb-gallery-toolbar [data-gallery-status].has-error { color: var(--danger); }
.nb-gallery-toolbar [data-gallery-status].has-error i { background-color: var(--danger); }

.nb-gallery-wall {
  position: relative;
  isolation: isolate;
  overflow: clip;
  padding: clamp(12px, 1.7vw, 24px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-shell);
  background:
    linear-gradient(rgba(188, 213, 207, 0.035) 1px, transparent 1px) 0 0 / 30px 30px,
    linear-gradient(90deg, rgba(188, 213, 207, 0.035) 1px, transparent 1px) 0 0 / 30px 30px,
    var(--editor-code);
  contain: paint;
}

.nb-gallery-ribbons {
  position: absolute;
  z-index: 0;
  inset: -2%;
  width: 104%;
  height: 104%;
  pointer-events: none;
}

.nb-gallery-ribbon {
  fill: none;
  stroke-width: 18;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  opacity: 0.1;
  transform-box: fill-box;
  transform-origin: center;
  will-change: auto;
}

.nb-gallery-ribbon.is-cyan { stroke: var(--syntax-cyan); }
.nb-gallery-ribbon.is-amber { stroke: var(--syntax-amber); opacity: 0.08; }
.nb-gallery-ribbon.is-coral { stroke: var(--syntax-red); opacity: 0.065; }

@media (min-width: 721px) and (hover: hover) and (pointer: fine) {
  .nb-gallery-wall.is-ribbon-active .nb-gallery-ribbon { will-change: transform; }
  .nb-gallery-wall.is-ribbon-active .nb-gallery-ribbon.is-cyan { animation: nb-gallery-ribbon-drift 13s ease-in-out infinite alternate; }
  .nb-gallery-wall.is-ribbon-active .nb-gallery-ribbon.is-amber { animation: nb-gallery-ribbon-drift 17s ease-in-out -4s infinite alternate-reverse; }
  .nb-gallery-wall.is-ribbon-active .nb-gallery-ribbon.is-coral { animation: nb-gallery-ribbon-rise 19s ease-in-out -7s infinite alternate; }
}

@keyframes nb-gallery-ribbon-drift {
  from { transform: translate3d(-1.4%, 0, 0) rotate(-0.35deg); }
  to { transform: translate3d(1.4%, 0.7%, 0) rotate(0.35deg); }
}

@keyframes nb-gallery-ribbon-rise {
  from { transform: translate3d(0, 1%, 0) scaleX(0.99); }
  to { transform: translate3d(0.8%, -1%, 0) scaleX(1.01); }
}

.nb-gallery-wall .nb-gallery-stream {
  position: relative;
  z-index: 1;
  column-gap: clamp(10px, 1.25vw, 18px);
}

.nb-gallery-wall .nb-gallery-item {
  margin-bottom: clamp(10px, 1.25vw, 18px);
  content-visibility: auto;
  contain-intrinsic-size: auto 300px;
}

.nb-gallery-print {
  position: relative;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-2);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2), var(--shadow-inner);
  transform: rotate(var(--photo-tilt));
  transform-origin: 50% 32%;
  transition: transform 190ms var(--ease-ui), border-color 170ms var(--ease-ui), box-shadow 170ms var(--ease-ui);
}

.nb-gallery-print::before {
  position: absolute;
  z-index: 3;
  top: -5px;
  left: 50%;
  width: clamp(34px, 25%, 58px);
  height: 10px;
  border: 1px solid rgba(var(--accent-rgb), 0.13);
  background: rgba(var(--accent-rgb), 0.12);
  content: "";
  pointer-events: none;
  transform: translateX(-50%) rotate(-1deg);
}

.nb-gallery-photo-open {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 5px 5px 2px 2px;
  outline: 0;
  background: var(--editor-code);
  color: inherit;
  cursor: zoom-in;
}

.nb-gallery-wall .nb-gallery-image {
  aspect-ratio: var(--photo-ratio);
  background: var(--surface);
}

.nb-gallery-wall .nb-gallery-image img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
  transition: transform 380ms var(--ease), filter 180ms var(--ease-ui);
}

.nb-gallery-index,
.nb-gallery-image > .nb-gallery-index {
  position: absolute;
  right: 7px;
  bottom: 7px;
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 7px;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  background: rgba(4, 9, 8, 0.76);
  color: #dce9e5;
  font-family: var(--font-mono);
  font-size: 0.47rem;
}

.nb-gallery-index b { color: var(--accent); }
.nb-gallery-index i { color: var(--syntax-blue); font-style: normal; }

.nb-gallery-label {
  display: grid;
  min-height: 55px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 7px 5px 3px 7px;
  gap: 6px;
}

.nb-gallery-label-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.nb-gallery-label-copy small {
  color: var(--syntax-blue);
  font-family: var(--font-mono);
  font-size: 0.43rem;
  letter-spacing: 0.06em;
}

.nb-gallery-label-copy strong {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 0.64rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nb-gallery-actions,
.nb-gallery-lightbox-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.nb-gallery-action {
  display: inline-grid;
  min-width: 36px;
  min-height: 36px;
  grid-auto-flow: column;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  gap: 4px;
  border: 0;
  border-radius: 5px;
  outline: 0;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.52rem;
  cursor: pointer;
  transition: color 140ms var(--ease-ui), background-color 140ms var(--ease-ui), transform 120ms var(--ease-ui);
}

.nb-gallery-action svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.nb-gallery-action:hover,
.nb-gallery-action:focus-visible {
  background: var(--editor-active);
  color: var(--text-soft);
}

.nb-gallery-action:focus-visible { box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.28); }
.nb-gallery-action:active { transform: translateY(1px); }
.nb-gallery-action:disabled { cursor: wait; opacity: 0.44; }
.nb-gallery-like.is-liked { color: var(--accent-strong); }
.nb-gallery-like.is-liked svg { fill: rgba(var(--accent-rgb), 0.22); }

@media (hover: hover) and (pointer: fine) {
  .nb-gallery-item:hover .nb-gallery-print,
  .nb-gallery-item:focus-within .nb-gallery-print {
    border-color: var(--line-accent);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.25), var(--shadow-inner);
    transform: translateY(-3px) rotate(0);
  }

  .nb-gallery-item:hover .nb-gallery-image img,
  .nb-gallery-item:focus-within .nb-gallery-image img { transform: scale(1.018); }
}

.nb-gallery-lightbox {
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  overscroll-behavior: contain;
}

.nb-gallery-lightbox > section {
  grid-template-rows: auto minmax(0, 1fr) auto;
  overscroll-behavior: contain;
}

.nb-gallery-lightbox header button {
  width: 44px;
  height: 44px;
  color: var(--text-soft);
}

.nb-gallery-lightbox header button:hover,
.nb-gallery-lightbox header button:focus-visible {
  outline: 0;
  background: var(--editor-active);
  color: var(--accent-strong);
}

.nb-gallery-lightbox-stage {
  position: relative;
  display: grid;
  min-height: min(66vh, 620px);
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
}

.nb-gallery-lightbox-stage img {
  width: 100%;
  height: min(76vh, 760px);
  padding: 10px 54px;
}

.nb-gallery-lightbox-stage button {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 44px;
  height: 58px;
  margin: 0;
  transform: translateY(-50%);
}

.nb-gallery-lightbox-stage [data-gallery-prev] { left: 9px; }
.nb-gallery-lightbox-stage [data-gallery-next] { right: 9px; }

.nb-gallery-lightbox footer {
  min-height: 52px;
  padding: 6px 9px 6px 13px;
}

.nb-gallery-lightbox-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.nb-gallery-lightbox-meta p {
  margin: 0;
  overflow: hidden;
  color: var(--text-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nb-gallery-lightbox-meta small {
  flex: 0 0 auto;
  color: var(--syntax-blue);
  font-family: var(--font-mono);
}

.nb-gallery-lightbox-actions .nb-gallery-action { min-width: 42px; min-height: 40px; }

.nb-gallery-share-panel {
  position: absolute;
  z-index: 5;
  right: 10px;
  bottom: 58px;
  display: grid;
  width: min(440px, calc(100% - 20px));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow-float), var(--shadow-inner);
}

.nb-gallery-share-panel[hidden] { display: none; }
.nb-gallery-share-panel > header { min-height: 44px; }
.nb-gallery-share-body { display: grid; grid-template-columns: 176px minmax(0, 1fr); align-items: center; padding: 13px; gap: 13px; }
.nb-gallery-qr-stage { position: relative; display: grid; min-height: 176px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #f4faf6; place-items: center; }
.nb-gallery-qr-stage canvas { width: 158px; height: 158px; max-width: calc(100% - 12px); image-rendering: pixelated; }
.nb-gallery-share-panel.has-error .nb-gallery-qr-stage canvas { opacity: 0.2; }
.nb-gallery-share-copy { display: grid; min-width: 0; gap: 8px; }
.nb-gallery-share-copy strong { color: var(--text); font-size: 0.8rem; }
.nb-gallery-share-copy code { display: -webkit-box; overflow: hidden; color: var(--syntax-blue); font-family: var(--font-mono); font-size: 0.56rem; line-height: 1.55; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.nb-gallery-share-copy p { margin: 0; color: var(--text-dim); font-size: 0.68rem; line-height: 1.55; }
.nb-gallery-share-actions { display: flex; justify-content: flex-end; padding: 8px 10px; gap: 7px; border-top: 1px solid var(--line); background: var(--editor-bar); }
.nb-gallery-share-actions button { min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--editor-code); color: var(--text-soft); cursor: pointer; }
.nb-gallery-share-actions button:hover,
.nb-gallery-share-actions button:focus-visible { border-color: var(--line-accent); outline: 0; color: var(--accent-strong); }

/* ---------- Desktop workbench proportion and list rhythm ---------- */
@media (min-width: 821px) {
  .nb-main > .nb-container > .nb-hero {
    height: calc(100vh - var(--header-h) - 18px - 12px);
    height: calc(100dvh - var(--header-h) - 18px - 12px);
    min-height: 0;
  }

  .nb-main > .nb-container > .nb-hero > .nb-workbench {
    height: 100%;
    min-height: 0;
  }

  .nb-workbench-main {
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
  }

  .nb-workbench-main > .nb-hero-grid {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .nb-workbench-main .nb-hero-copy {
    max-height: calc(100% - 20px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  .nb-workbench-main .nb-editor {
    display: grid;
    max-height: calc(100% - 20px);
    grid-template-rows: auto auto auto auto;
    overflow: hidden;
  }

  .nb-workbench-main .nb-code-block-compact {
    max-height: none;
    overflow: hidden;
    overscroll-behavior: auto;
  }

  .nb-workbench-main #nb-devbot-canvas.nb-devbot-canvas {
    width: auto;
    max-width: 100%;
    height: clamp(150px, calc(70vh - 340px), 360px);
    height: clamp(150px, calc(70dvh - 340px), 360px);
    max-height: none;
    aspect-ratio: 13 / 9;
    margin-inline: auto;
    object-fit: contain;
  }
}

@media (min-width: 1200px) and (max-width: 1439px) {
  .nb-workbench-main > .nb-hero-grid {
    grid-template-columns: minmax(340px, 0.86fr) 42px minmax(500px, 1.14fr);
  }

  .nb-workbench-main .nb-editor {
    width: calc(100% - 20px);
    max-width: none;
    margin: 10px;
    justify-self: stretch;
  }
}

@media (min-width: 1440px) {
  .nb-workbench-main > .nb-hero-grid {
    grid-template-columns: minmax(430px, 0.82fr) 42px minmax(640px, 1.18fr);
  }

  .nb-workbench-main .nb-editor {
    width: calc(100% - 20px);
    max-width: none;
    margin: 10px;
    justify-self: stretch;
  }
}

@media (min-width: 1440px) and (max-height: 900px) {
  .nb-workbench-main .nb-editor {
    width: calc(100% - 20px);
    max-width: none;
    margin: 10px;
    justify-self: stretch;
  }
}

@media (min-width: 821px) and (max-height: 1120px) {
  .nb-workbench-main .nb-editor-head {
    min-height: 36px;
  }

  .nb-workbench-main .nb-weather-slot {
    margin: 7px 10px 0;
  }

  .nb-editor .nb-devbot {
    margin: 8px 10px 0;
  }

  .nb-workbench-main .nb-devbot-head {
    min-height: 34px;
    padding-inline: 12px;
    font-size: 0.62rem;
  }

  .nb-workbench-main #nb-devbot-canvas.nb-devbot-canvas {
    height: clamp(145px, calc(70vh - 340px), 350px);
    height: clamp(145px, calc(70dvh - 340px), 350px);
  }

  .nb-workbench-main .nb-devbot-caption {
    min-height: 32px;
    padding: 6px 11px;
  }

  .nb-workbench-main .nb-code-block-compact {
    padding-block: 6px 8px;
    font-size: 0.62rem;
    line-height: 1.32;
  }

  .nb-workbench-main .nb-code-block-compact .nb-code-row {
    min-height: 17px;
  }
}

@media (min-width: 821px) and (max-height: 850px) {
  .nb-workbench-main .nb-editor-head {
    min-height: 32px;
    padding-inline: 11px;
  }

  .nb-workbench-main .nb-weather-slot {
    margin: 4px 8px 0;
  }

  .nb-editor .nb-devbot {
    margin: 5px 8px 0;
  }

  .nb-workbench-main .nb-devbot-head {
    min-height: 30px;
    padding-inline: 10px;
    font-size: 0.59rem;
  }

  .nb-workbench-main #nb-devbot-canvas.nb-devbot-canvas {
    height: clamp(132px, calc(70vh - 350px), 200px);
    height: clamp(132px, calc(70dvh - 350px), 200px);
  }

  .nb-workbench-main .nb-devbot-caption {
    min-height: 28px;
    padding: 5px 9px;
    font-size: 0.58rem;
  }

  .nb-workbench-main .nb-code-block-compact {
    padding-block: 4px 6px;
    font-size: 0.59rem;
    line-height: 1.2;
  }

  .nb-workbench-main .nb-code-block-compact .nb-code-row {
    min-height: 15px;
    grid-template-columns: 36px minmax(0, 1fr);
  }
}

@media (min-width: 821px) and (max-height: 680px) {
  .nb-workbench-main .nb-editor-head {
    min-height: 30px;
    padding-inline: 9px;
    font-size: 0.61rem;
  }

  .nb-workbench-main .nb-weather-slot {
    margin: 3px 7px 0;
  }

  .nb-editor .nb-devbot {
    margin: 4px 7px 0;
  }

  .nb-workbench-main .nb-devbot-head {
    min-height: 26px;
    padding-inline: 8px;
    font-size: 0.56rem;
  }

  .nb-workbench-main #nb-devbot-canvas.nb-devbot-canvas {
    height: clamp(104px, calc(60vh - 250px), 132px);
    height: clamp(104px, calc(60dvh - 250px), 132px);
  }

  .nb-workbench-main .nb-devbot-caption {
    min-height: 24px;
    padding: 3px 8px;
    font-size: 0.54rem;
  }

  .nb-workbench-main .nb-code-block-compact {
    padding-block: 2px 4px;
    font-size: 0.56rem;
    line-height: 1.1;
  }

  .nb-workbench-main .nb-code-block-compact .nb-code-row {
    min-height: 13px;
    grid-template-columns: 32px minmax(0, 1fr);
  }
}

@media (min-width: 1721px) {
  body.nb-body:has(.nb-home-feed),
  .nb-home-container { --max: 2000px; }
}

.nb-posts {
  display: grid;
  padding: 10px;
  gap: 10px;
}

.nb-posts > .nb-card,
.nb-posts > .nb-card:first-child,
.nb-posts > .nb-card:last-child,
.nb-posts > .nb-card:only-child {
  border: 1px solid var(--line);
  border-radius: 8px;
}

@media (min-width: 1021px) {
  .nb-layout:not(.nb-layout-reading) { align-items: stretch; }

  .nb-layout:not(.nb-layout-reading) > .nb-sidebar {
    position: relative;
    top: auto;
    display: flex;
    flex-direction: column;
    align-self: stretch;
    min-height: clamp(560px, 72dvh, 760px);
    max-height: none;
    overflow: visible;
    overscroll-behavior: auto;
  }

  .nb-layout:not(.nb-layout-reading) > .nb-sidebar > .nb-sidebar-chrome {
    top: 8px;
  }

  .nb-layout:not(.nb-layout-reading) > .nb-sidebar > .nb-sidebar-content {
    flex: 1 0 auto;
  }

  .nb-layout:not(.nb-layout-reading) > .nb-sidebar > .nb-sidebar-foot {
    position: static;
    margin-top: auto;
  }
}

@media (max-width: 720px) {
  .nb-gallery-wall { padding: 9px; }
  .nb-gallery-wall .nb-gallery-stream { column-gap: 9px; }
  .nb-gallery-wall .nb-gallery-item { margin-bottom: 9px; }
  .nb-gallery-print { padding: 3px; transform: none; }
  .nb-gallery-print::before { height: 7px; }
  .nb-gallery-label { min-height: 49px; padding: 5px 2px 2px 5px; }
  .nb-gallery-label-copy small { display: none; }
  .nb-gallery-label-copy strong { font-size: 0.58rem; }
  .nb-gallery-action { min-width: 42px; min-height: 42px; padding-inline: 5px; }
  .nb-gallery-lightbox { padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); }
  .nb-gallery-lightbox > section { max-height: calc(100dvh - 12px); }
  .nb-gallery-lightbox-stage { min-height: 240px; grid-template-columns: minmax(0, 1fr); }
  .nb-gallery-lightbox-stage img { height: min(66vh, 600px); padding-inline: 42px; }
  .nb-gallery-lightbox-stage button { width: 44px; height: 54px; }
  .nb-gallery-lightbox-stage [data-gallery-prev] { left: 3px; }
  .nb-gallery-lightbox-stage [data-gallery-next] { right: 3px; }
  .nb-gallery-lightbox footer { align-items: stretch; flex-direction: column; padding: 7px 9px; gap: 5px; }
  .nb-gallery-lightbox-meta { min-height: 28px; justify-content: space-between; }
  .nb-gallery-lightbox-actions { justify-content: flex-end; }
  .nb-gallery-share-panel { right: 6px; bottom: 8px; left: 6px; width: auto; max-height: calc(100% - 58px); overflow: auto; }
  .nb-gallery-share-body { grid-template-columns: 132px minmax(0, 1fr); padding: 10px; gap: 10px; }
  .nb-gallery-qr-stage { min-height: 132px; }
  .nb-gallery-qr-stage canvas { width: 120px; height: 120px; }
  .nb-posts { padding: 8px; gap: 8px; }
}

@media (max-width: 420px) {
  .nb-gallery-actions { gap: 0; }
  .nb-gallery-label-copy { display: none; }
  .nb-gallery-label { display: flex; min-height: 46px; justify-content: flex-end; }
  .nb-gallery-share-body { grid-template-columns: minmax(0, 1fr); }
  .nb-gallery-qr-stage { width: 176px; min-height: 176px; justify-self: center; }
  .nb-gallery-qr-stage canvas { width: 158px; height: 158px; }
  .nb-gallery-share-copy { text-align: center; }
}

@media (prefers-reduced-motion: reduce), (update: slow) {
  .nb-gallery-ribbon { animation: none !important; will-change: auto; }
  .nb-gallery-print,
  .nb-gallery-photo-open,
  .nb-gallery-wall .nb-gallery-image img,
  .nb-gallery-lightbox,
  .nb-gallery-lightbox-stage img,
  .nb-gallery-action { transition: none !important; }
}

/* ---------- Desktop workbench density ---------- */
@media (min-width: 821px) {
  /* Keep only a narrow IDE gutter. The editor then owns the full available
     column height instead of centring an intrinsic-height panel. */
  .nb-workbench-main .nb-editor {
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    align-self: stretch;
    justify-self: stretch;
    margin: 5px;
    grid-template-rows: auto minmax(150px, 1fr) auto;
    overflow: hidden;
  }

  .nb-workbench-main .nb-editor:has(.nb-weather-slot) {
    grid-template-rows: auto minmax(104px, 0.48fr) minmax(150px, 1fr) auto;
  }

  .nb-workbench-main .nb-weather-slot,
  .nb-workbench-main .nb-devbot,
  .nb-workbench-main .nb-code-block-compact {
    min-height: 0;
    overflow: hidden;
  }

  .nb-editor .nb-devbot {
    display: grid;
    align-self: stretch;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .nb-workbench-main #nb-devbot-canvas.nb-devbot-canvas {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: auto;
    object-fit: contain;
  }
}

@media (min-width: 821px) and (max-height: 680px) {
  .nb-workbench-main .nb-editor {
    grid-template-rows: auto minmax(128px, 1fr) auto;
  }

  .nb-workbench-main .nb-editor:has(.nb-weather-slot) {
    grid-template-rows: auto minmax(96px, 0.42fr) minmax(128px, 1fr) auto;
  }
}
