/* ty-tools.css — 9Minecraft Toys Browser Makers & DIY Tools (THIET KE TOOL 9MINECRAFT 01/12).
   Model 10 soft gradient surfaces, light-mode default, ZERO single-edge color bars, flush mobile bottom dock. */

.mk {
  display: grid;
  grid-template-columns: minmax(290px, 370px) 1fr;
  gap: 18px;
  align-items: start;
  margin: 14px 0 24px;
}

.mk__ctl {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(165deg, color-mix(in srgb, var(--tc, #0ea5e9) 11%, var(--ty-surface, #fff)) 0%, var(--ty-surface, #fff) 60%);
  box-shadow: var(--ty-shadow, 0 1px 3px rgba(15, 23, 42, .08));
}

.mk__ctl label,
.mkd-sheet__b label,
#ty-tool-root .ty-panel label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ty-muted, #64748b);
  min-width: 0;
  max-width: 100%;
}

.mk__ctl input,
.mk__ctl select,
.mk__ctl textarea,
.mkd-sheet__b input,
.mkd-sheet__b select,
.mkd-sheet__b textarea,
#ty-tool-root .ty-panel input,
#ty-tool-root .ty-panel select,
#ty-tool-root .ty-panel textarea {
  font: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--ty-line-2, #cbd5e1);
  background: var(--ty-surface, #fff);
  color: var(--ty-ink, #1e293b);
  min-height: 44px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  text-overflow: ellipsis;
}

.mk__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.mk__row > * {
  min-width: 0;
}

#ty-tool-root,
#ty-tool-root .ty-panel,
#ty-tool-root .mk__view {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Fallback crisp card surface for login popover when external n9acc.css has not painted yet */
.n9s-vaopop {
  background: var(--ty-surface, #fff);
  color: var(--ty-ink, #1e293b);
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--ty-line, #e2e8f0);
  box-shadow: 0 14px 36px rgba(15, 23, 42, .22);
}

.n9s-vaopop b {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}

.n9s-vaopop p,
.n9s-vaopop small {
  display: block;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ty-muted, #64748b);
  margin: 0 0 10px;
}

.n9s-vaopop a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  margin: 4px 6px 0 0;
  border-radius: 10px;
  border: 1px solid var(--ty-line-2, #cbd5e1);
  background: var(--ty-soft, #f8fafc);
  color: var(--ty-ink, #1e293b);
  font-weight: 700;
  font-size: 13.5px;
  text-decoration: none;
}

.mk__btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mk__btns .ty-btn {
  flex: 1 1 auto;
  min-height: 44px;
  justify-content: center;
}

.mk__chk {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}

.mk__chk input {
  width: 20px;
  height: 20px;
  min-height: 20px;
}

.mk__err {
  color: #dc2626;
  font-size: 13.5px;
  font-weight: 700;
  margin: 0;
}

.mk__err[hidden] {
  display: none !important;
}

.mk__view {
  border-radius: 18px;
  padding: 12px;
  background: var(--ty-surface, #fff);
  box-shadow: var(--ty-shadow, 0 1px 3px rgba(15, 23, 42, .08)), 0 0 0 1px rgba(15, 23, 42, .05);
}

.mk__view canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: #f8fafc;
}

.mk__view canvas.is-pixel {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.mk__note {
  font-size: 13px;
  color: var(--ty-muted, #64748b);
  margin: 10px 2px 0;
}

.mk__legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.mk__sw {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--ty-soft, #f1f5f9);
  font-size: 13px;
  font-weight: 700;
}

.mk__sw i {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex: none;
  border: 1px solid rgba(15, 23, 42, .18);
}

.mk__sw span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mk__sw b {
  font-variant-numeric: tabular-nums;
  color: var(--ty-ink, #1e293b);
}

.mk__code {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--ty-soft, #f1f5f9);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  max-height: 280px;
  overflow: auto;
}

.mk__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.mk__stat {
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(165deg, color-mix(in srgb, var(--tc, #0ea5e9) 10%, var(--ty-surface, #fff)) 0%, var(--ty-surface, #fff) 75%);
  box-shadow: var(--ty-shadow, 0 1px 2px rgba(15, 23, 42, .06));
}

.mk__stat span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ty-muted, #64748b);
  text-transform: uppercase;
}

.mk__stat b {
  display: block;
  font-size: 24px;
  font-weight: 800;
  color: var(--ty-ink, #1e293b);
  margin-top: 2px;
}

/* Desktop Save & Share button */
.mkd-save-desk {
  width: 100%;
  min-height: 50px;
  font-size: 16px;
  justify-content: center;
  gap: 8px;
}

.mkd-save-desk svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Mobile bottom dock bar (TikTok style, flush to bottom edge) */
.mkd-bar {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 9990;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  background: var(--ty-surface, #fff);
  box-shadow: 0 -1px 0 rgba(15, 23, 42, .12), 0 -6px 18px rgba(15, 23, 42, .08);
}

.mkd-bar--bot {
  bottom: 0;
  padding: 4px 2px calc(2px + env(safe-area-inset-bottom));
}

.mkd-bar--top {
  top: 52px;
  padding: 3px 2px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .12), 0 6px 18px rgba(15, 23, 42, .08);
}

.mkd-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--ty-muted, #64748b);
  font: 700 11px/1.1 system-ui, sans-serif;
  cursor: pointer;
}

.mkd-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.mkd-btn.on {
  color: var(--tc, #0284c7);
}

.mkd-save {
  flex: 0 0 auto;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 0 4px;
  padding: 7px 14px;
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--tc, #0284c7);
  color: #fff;
  font: 800 11px/1.1 system-ui, sans-serif;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--tc, #0284c7) 42%, transparent);
  cursor: pointer;
}

.mkd-save svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

html.mkd-on body {
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}

html.mkd-top-on body {
  padding-top: 48px;
}

html.mkd-on .mk__ctl {
  display: none;
}

html.mkd-on .mk {
  grid-template-columns: 1fr;
  scroll-margin-top: 64px;
}

html.mkd-on .mk__view {
  position: static;
  padding: 6px;
  order: 0;
}

.mkd-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(60px + env(safe-area-inset-bottom));
  z-index: 9989;
  max-height: 62vh;
  display: flex;
  flex-direction: column;
  border-radius: 20px 20px 0 0;
  background: linear-gradient(165deg, color-mix(in srgb, var(--tc, #0ea5e9) 10%, var(--ty-surface, #fff)) 0%, var(--ty-surface, #fff) 55%);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .18);
  transform: translateY(110%);
  transition: transform .22s ease;
}

.mkd-sheet.mo {
  transform: none;
}

.mkd-sheet.gon .mkd-sheet__b {
  display: none;
}

.mkd-sheet.gon .mkd-sheet__h [data-gon] svg {
  transform: rotate(180deg);
}

.mkd-sheet__h {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 6px 18px;
}

.mkd-sheet__h b {
  flex: 1;
  font-size: 16px;
  cursor: pointer;
}

.mkd-ic {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(127, 127, 127, .12);
  color: inherit;
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mkd-ic svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  transition: transform .2s;
}

.mkd-sheet__b {
  overflow: auto;
  padding: 4px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Collection Map matrix (horizontal scroll contained, 0 page overflow) */
.ty-map-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
  border: 1px solid var(--ty-line, #e2e8f0);
  background: var(--ty-surface, #fff);
}

.ty-map-tbl {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 13px;
}

.ty-map-tbl th,
.ty-map-tbl td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--ty-line, #e2e8f0);
  vertical-align: top;
  text-align: left;
}

.ty-map-tbl th {
  background: var(--ty-soft, #f1f5f9);
  font-weight: 800;
  position: sticky;
  top: 0;
  z-index: 1;
}

.ty-map-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ty-map-dot {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: none;
  background: var(--ty-soft, #f1f5f9);
  color: var(--ty-ink, #1e293b);
  border: 1px solid var(--ty-line, #e2e8f0);
}

.ty-map-dot.is-owned {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

html[data-theme="dark"] .ty-map-dot.is-owned {
  background: #14532d;
  color: #bbf7d0;
  border-color: #22c55e;
}

@media (max-width: 860px) {
  .mk {
    grid-template-columns: 1fr;
  }
  .mk__view {
    order: -1;
    padding: 6px;
  }
  .mk__row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mkd-sheet,
  .mkd-ic svg {
    transition: none;
  }
}

@media print {
  header.h,
  footer.n9-ft,
  .mk__ctl,
  .mkd-bar,
  .mkd-sheet,
  .n9ad,
  .g-vun {
    display: none !important;
  }
  .mk {
    display: block;
  }
  .mk__view {
    box-shadow: none;
    padding: 0;
  }
}
